chore: Enable more lint rules, disable some that trigger a lot. Will clean up later.

This commit is contained in:
cpojer
2026-01-31 16:03:28 +09:00
parent 481f696a87
commit 15792b153f
292 changed files with 643 additions and 699 deletions
+2 -2
View File
@@ -45,8 +45,8 @@ export function registerPluginCliCommands(program: Command, cfg?: OpenClawConfig
workspaceDir,
logger,
});
if (result && typeof (result as Promise<void>).then === "function") {
void (result as Promise<void>).catch((err) => {
if (result && typeof result.then === "function") {
void result.catch((err) => {
log.warn(`plugin CLI register failed (${entry.pluginId}): ${String(err)}`);
});
}
+4 -4
View File
@@ -84,7 +84,7 @@ function getHooksForName<K extends PluginHookName>(
): PluginHookRegistration<K>[] {
return (registry.typedHooks as PluginHookRegistration<K>[])
.filter((h) => h.hookName === hookName)
.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
.toSorted((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
}
/**
@@ -116,7 +116,7 @@ export function createHookRunner(registry: PluginRegistry, options: HookRunnerOp
if (catchErrors) {
logger?.error(msg);
} else {
throw new Error(msg);
throw new Error(msg, { cause: err });
}
}
});
@@ -159,7 +159,7 @@ export function createHookRunner(registry: PluginRegistry, options: HookRunnerOp
if (catchErrors) {
logger?.error(msg);
} else {
throw new Error(msg);
throw new Error(msg, { cause: err });
}
}
}
@@ -353,7 +353,7 @@ export function createHookRunner(registry: PluginRegistry, options: HookRunnerOp
if (catchErrors) {
logger?.error(msg);
} else {
throw new Error(msg);
throw new Error(msg, { cause: err });
}
}
}
+1 -1
View File
@@ -405,7 +405,7 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
try {
const result = register(api);
if (result && typeof (result as Promise<void>).then === "function") {
if (result && typeof result.then === "function") {
registry.diagnostics.push({
level: "warn",
pluginId: record.id,
+1 -1
View File
@@ -33,7 +33,7 @@ const state: RegistryState = (() => {
key: null,
};
}
return globalState[REGISTRY_STATE] as RegistryState;
return globalState[REGISTRY_STATE];
})();
export function setActivePluginRegistry(registry: PluginRegistry, cacheKey?: string) {
+1 -1
View File
@@ -29,7 +29,7 @@ export function validateJsonSchemaValue(params: {
}): { ok: true } | { ok: false; errors: string[] } {
let cached = schemaCache.get(params.cacheKey);
if (!cached || cached.schema !== params.schema) {
const validate = ajv.compile(params.schema) as ValidateFunction;
const validate = ajv.compile(params.schema);
cached = { validate, schema: params.schema };
schemaCache.set(params.cacheKey, cached);
}
+1 -1
View File
@@ -57,7 +57,7 @@ export async function startPluginServices(params: {
return {
stop: async () => {
for (const entry of running.reverse()) {
for (const entry of running.toReversed()) {
if (!entry.stop) continue;
try {
await entry.stop();
+3 -1
View File
@@ -76,7 +76,9 @@ export function applyExclusiveSlotSelection(params: {
}
if (disabledIds.length > 0) {
warnings.push(`Disabled other "${slotKey}" slot plugins: ${disabledIds.sort().join(", ")}.`);
warnings.push(
`Disabled other "${slotKey}" slot plugins: ${disabledIds.toSorted().join(", ")}.`,
);
}
const changed = prevSlot !== params.selectedId || disabledIds.length > 0;