mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 02:08:27 +00:00
chore: Enable more lint rules, disable some that trigger a lot. Will clean up later.
This commit is contained in:
@@ -98,7 +98,7 @@ describe("session-memory hook", () => {
|
||||
expect(files.length).toBe(1);
|
||||
|
||||
// Read the memory file and verify content
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]!), "utf-8");
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]), "utf-8");
|
||||
expect(memoryContent).toContain("user: Hello there");
|
||||
expect(memoryContent).toContain("assistant: Hi! How can I help?");
|
||||
expect(memoryContent).toContain("user: What is 2+2?");
|
||||
@@ -140,7 +140,7 @@ describe("session-memory hook", () => {
|
||||
|
||||
const memoryDir = path.join(tempDir, "memory");
|
||||
const files = await fs.readdir(memoryDir);
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]!), "utf-8");
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]), "utf-8");
|
||||
|
||||
// Only user/assistant messages should be present
|
||||
expect(memoryContent).toContain("user: Hello");
|
||||
@@ -185,7 +185,7 @@ describe("session-memory hook", () => {
|
||||
|
||||
const memoryDir = path.join(tempDir, "memory");
|
||||
const files = await fs.readdir(memoryDir);
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]!), "utf-8");
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]), "utf-8");
|
||||
|
||||
// Command messages should be filtered out
|
||||
expect(memoryContent).not.toContain("/help");
|
||||
@@ -236,7 +236,7 @@ describe("session-memory hook", () => {
|
||||
|
||||
const memoryDir = path.join(tempDir, "memory");
|
||||
const files = await fs.readdir(memoryDir);
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]!), "utf-8");
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]), "utf-8");
|
||||
|
||||
// Only last 3 messages should be present
|
||||
expect(memoryContent).not.toContain("user: Message 1\n");
|
||||
@@ -297,7 +297,7 @@ describe("session-memory hook", () => {
|
||||
|
||||
const memoryDir = path.join(tempDir, "memory");
|
||||
const files = await fs.readdir(memoryDir);
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]!), "utf-8");
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]), "utf-8");
|
||||
|
||||
// Should have exactly 3 user/assistant messages (the last 3)
|
||||
expect(memoryContent).not.toContain("First message");
|
||||
@@ -370,7 +370,7 @@ describe("session-memory hook", () => {
|
||||
|
||||
const memoryDir = path.join(tempDir, "memory");
|
||||
const files = await fs.readdir(memoryDir);
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]!), "utf-8");
|
||||
const memoryContent = await fs.readFile(path.join(memoryDir, files[0]), "utf-8");
|
||||
|
||||
// Both messages should be included
|
||||
expect(memoryContent).toContain("user: Only message 1");
|
||||
|
||||
@@ -129,7 +129,7 @@ const saveSessionToMemory: HookHandler = async (event) => {
|
||||
|
||||
// If no slug, use timestamp
|
||||
if (!slug) {
|
||||
const timeSlug = now.toISOString().split("T")[1]!.split(".")[0]!.replace(/:/g, "");
|
||||
const timeSlug = now.toISOString().split("T")[1].split(".")[0].replace(/:/g, "");
|
||||
slug = timeSlug.slice(0, 4); // HHMM
|
||||
console.log("[session-memory] Using fallback timestamp slug:", slug);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ const saveSessionToMemory: HookHandler = async (event) => {
|
||||
console.log("[session-memory] Full path:", memoryFilePath);
|
||||
|
||||
// Format time as HH:MM:SS UTC
|
||||
const timeStr = now.toISOString().split("T")[1]!.split(".")[0];
|
||||
const timeStr = now.toISOString().split("T")[1].split(".")[0];
|
||||
|
||||
// Extract context details
|
||||
const sessionId = (sessionEntry.sessionId as string) || "unknown";
|
||||
|
||||
@@ -11,7 +11,7 @@ const soulEvilHook: HookHandler = async (event) => {
|
||||
|
||||
const context = event.context;
|
||||
if (context.sessionKey && isSubagentSessionKey(context.sessionKey)) return;
|
||||
const cfg = context.cfg as OpenClawConfig | undefined;
|
||||
const cfg = context.cfg;
|
||||
const hookConfig = resolveHookConfig(cfg, HOOK_KEY);
|
||||
if (!hookConfig || hookConfig.enabled === false) return;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ export function resolveConfigPath(config: OpenClawConfig | undefined, pathStr: s
|
||||
export function isConfigPathTruthy(config: OpenClawConfig | undefined, pathStr: string): boolean {
|
||||
const value = resolveConfigPath(config, pathStr);
|
||||
if (value === undefined && pathStr in DEFAULT_CONFIG_VALUES) {
|
||||
return DEFAULT_CONFIG_VALUES[pathStr] === true;
|
||||
return DEFAULT_CONFIG_VALUES[pathStr];
|
||||
}
|
||||
return isTruthy(value);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ metadata:
|
||||
expect(typeof result.metadata).toBe("string");
|
||||
|
||||
// Verify the metadata is valid JSON
|
||||
const parsed = JSON.parse(result.metadata as string);
|
||||
const parsed = JSON.parse(result.metadata);
|
||||
expect(parsed.openclaw.emoji).toBe("💾");
|
||||
expect(parsed.openclaw.events).toEqual(["command:new"]);
|
||||
});
|
||||
@@ -82,7 +82,7 @@ metadata:
|
||||
expect(result.name).toBe("command-logger");
|
||||
expect(result.metadata).toBeDefined();
|
||||
|
||||
const parsed = JSON.parse(result.metadata as string);
|
||||
const parsed = JSON.parse(result.metadata);
|
||||
expect(parsed.openclaw.emoji).toBe("📝");
|
||||
expect(parsed.openclaw.events).toEqual(["command"]);
|
||||
expect(parsed.openclaw.requires.config).toEqual(["workspace.dir"]);
|
||||
|
||||
@@ -40,7 +40,7 @@ function parseInstallSpec(input: unknown): HookInstallSpec | undefined {
|
||||
}
|
||||
|
||||
const spec: HookInstallSpec = {
|
||||
kind: kind as HookInstallSpec["kind"],
|
||||
kind: kind,
|
||||
};
|
||||
|
||||
if (typeof raw.id === "string") spec.id = raw.id;
|
||||
@@ -69,7 +69,7 @@ export function resolveOpenClawMetadata(
|
||||
const raw = getFrontmatterValue(frontmatter, "metadata");
|
||||
if (!raw) return undefined;
|
||||
try {
|
||||
const parsed = JSON5.parse(raw) as Record<string, unknown>;
|
||||
const parsed = JSON5.parse(raw);
|
||||
if (!parsed || typeof parsed !== "object") return undefined;
|
||||
const metadataRawCandidates = [MANIFEST_KEY, ...LEGACY_MANIFEST_KEYS];
|
||||
let metadataRaw: unknown;
|
||||
|
||||
@@ -249,7 +249,7 @@ export async function ensureTailscaleEndpoint(params: {
|
||||
try {
|
||||
parsed = JSON.parse(status.stdout) as { Self?: { DNSName?: string } };
|
||||
} catch (err) {
|
||||
throw new Error(formatJsonParseFailure(statusCommand, status, err));
|
||||
throw new Error(formatJsonParseFailure(statusCommand, status, err), { cause: err });
|
||||
}
|
||||
const dnsName = parsed.Self?.DNSName?.replace(/\.$/, "");
|
||||
if (!dnsName) {
|
||||
|
||||
@@ -83,7 +83,7 @@ function loadHookFromDir(params: {
|
||||
return {
|
||||
name,
|
||||
description,
|
||||
source: params.source as Hook["source"],
|
||||
source: params.source,
|
||||
pluginId: params.pluginId,
|
||||
filePath: hookMdPath,
|
||||
baseDir: params.hookDir,
|
||||
|
||||
Reference in New Issue
Block a user