diff --git a/.oxlintrc.json b/.oxlintrc.json index c99082b2a73..82105eaf03f 100644 --- a/.oxlintrc.json +++ b/.oxlintrc.json @@ -9,9 +9,16 @@ "rules": { "curly": "error", "eslint-plugin-unicorn/prefer-array-find": "error", + "eslint/no-array-constructor": "error", "eslint/no-await-in-loop": "off", "eslint/no-new": "error", + "eslint/no-object-constructor": "error", + "eslint/no-return-assign": "error", "eslint/no-shadow": "off", + "eslint/no-useless-call": "error", + "eslint/no-useless-computed-key": "error", + "eslint/no-useless-concat": "error", + "eslint/no-useless-constructor": "error", "eslint/no-warning-comments": "error", "eslint/no-unmodified-loop-condition": "error", "eslint-plugin-unicorn/prefer-set-size": "error", @@ -23,11 +30,19 @@ "typescript/no-extraneous-class": "error", "typescript/no-meaningless-void-operator": "error", "typescript/no-unnecessary-type-assertion": "error", + "typescript/no-unnecessary-type-arguments": "error", + "typescript/no-unnecessary-type-constraint": "error", "typescript/no-unnecessary-type-conversion": "error", "typescript/no-unnecessary-type-parameters": "error", "typescript/no-unsafe-type-assertion": "off", "typescript/no-useless-default-assignment": "error", + "typescript/prefer-ts-expect-error": "error", "unicorn/consistent-function-scoping": "off", + "unicorn/no-unnecessary-array-flat-depth": "error", + "unicorn/no-unnecessary-array-splice-count": "error", + "unicorn/no-unnecessary-slice-end": "error", + "unicorn/no-useless-promise-resolve-reject": "error", + "unicorn/prefer-date-now": "error", "unicorn/prefer-set-size": "error", "unicorn/require-post-message-target-origin": "error" }, diff --git a/extensions/matrix/src/plugin-entry.runtime.test.ts b/extensions/matrix/src/plugin-entry.runtime.test.ts index 6bdce5bca07..02d0b35e3e1 100644 --- a/extensions/matrix/src/plugin-entry.runtime.test.ts +++ b/extensions/matrix/src/plugin-entry.runtime.test.ts @@ -144,7 +144,7 @@ function writeTrustedOpenClawBinFixture( } afterEach(() => { - for (const dir of tempDirs.splice(0, tempDirs.length)) { + for (const dir of tempDirs.splice(0)) { fs.rmSync(dir, { recursive: true, force: true }); } }); diff --git a/extensions/telegram/src/bot-native-commands.skills-allowlist.test.ts b/extensions/telegram/src/bot-native-commands.skills-allowlist.test.ts index d4e932002bd..17e994d428c 100644 --- a/extensions/telegram/src/bot-native-commands.skills-allowlist.test.ts +++ b/extensions/telegram/src/bot-native-commands.skills-allowlist.test.ts @@ -26,9 +26,7 @@ describe("registerTelegramNativeCommands skill allowlist integration", () => { resetNativeCommandMenuMocks(); resetPluginCommandMocks(); await Promise.all( - tempDirs - .splice(0, tempDirs.length) - .map((dir) => fs.rm(dir, { recursive: true, force: true })), + tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })), ); }); diff --git a/extensions/telegram/src/bot.create-telegram-bot.channel-post-media.test.ts b/extensions/telegram/src/bot.create-telegram-bot.channel-post-media.test.ts index 6234ed811ef..39c9fdb84b2 100644 --- a/extensions/telegram/src/bot.create-telegram-bot.channel-post-media.test.ts +++ b/extensions/telegram/src/bot.create-telegram-bot.channel-post-media.test.ts @@ -256,11 +256,9 @@ describe("createTelegramBot channel_post media", () => { }); sendMessageSpy.mockClear(); replySpy.mockClear(); - const fetchSpy = vi - .spyOn(globalThis, "fetch") - .mockImplementation(async () => - Promise.reject(new Error("MediaFetchError: Failed to fetch media")), - ); + const fetchSpy = vi.spyOn(globalThis, "fetch").mockImplementation(async () => { + throw new Error("MediaFetchError: Failed to fetch media"); + }); try { createTelegramBot({ token: "tok" }); diff --git a/scripts/label-open-issues.ts b/scripts/label-open-issues.ts index e4f6ea36cd4..eca02ba678f 100644 --- a/scripts/label-open-issues.ts +++ b/scripts/label-open-issues.ts @@ -459,7 +459,7 @@ function* fetchOpenLabelItemBatches(params: { if (results.length >= WORK_BATCH_SIZE) { yield { batchIndex, - items: results.splice(0, results.length), + items: results.splice(0), totalCount, fetchedCount, }; diff --git a/src/agents/identity-avatar.test.ts b/src/agents/identity-avatar.test.ts index a36e6b76c11..659a5485692 100644 --- a/src/agents/identity-avatar.test.ts +++ b/src/agents/identity-avatar.test.ts @@ -36,9 +36,7 @@ async function createTempAvatarRoot() { afterEach(async () => { await Promise.all( - tempRoots - .splice(0, tempRoots.length) - .map((root) => fs.rm(root, { recursive: true, force: true })), + tempRoots.splice(0).map((root) => fs.rm(root, { recursive: true, force: true })), ); }); diff --git a/src/agents/pi-bundle-mcp-test-harness.ts b/src/agents/pi-bundle-mcp-test-harness.ts index d3d3bc2b636..77abc0e1a7c 100644 --- a/src/agents/pi-bundle-mcp-test-harness.ts +++ b/src/agents/pi-bundle-mcp-test-harness.ts @@ -18,9 +18,7 @@ const tempDirs: string[] = []; export async function cleanupBundleMcpHarness(): Promise { await __testing.resetSessionMcpRuntimeManager(); - await Promise.all( - tempDirs.splice(0, tempDirs.length).map((dir) => fs.rm(dir, { recursive: true, force: true })), - ); + await Promise.all(tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true }))); } export async function makeTempDir(prefix: string): Promise { diff --git a/src/agents/pi-embedded-runner/skills-runtime.integration.test.ts b/src/agents/pi-embedded-runner/skills-runtime.integration.test.ts index e35d4fed270..a8924adeae7 100644 --- a/src/agents/pi-embedded-runner/skills-runtime.integration.test.ts +++ b/src/agents/pi-embedded-runner/skills-runtime.integration.test.ts @@ -50,9 +50,7 @@ async function resolveBundledDiffsSkillEntries(config?: OpenClawConfig) { afterEach(async () => { restoreBundledPluginsDir(); clearPluginManifestRegistryCache(); - await Promise.all( - tempDirs.splice(0, tempDirs.length).map((dir) => fs.rm(dir, { recursive: true, force: true })), - ); + await Promise.all(tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true }))); }); describe("resolveEmbeddedRunSkillEntries (integration)", () => { diff --git a/src/agents/skills.agents-skills-directory.test.ts b/src/agents/skills.agents-skills-directory.test.ts index febbad8045a..97da7fdc4d2 100644 --- a/src/agents/skills.agents-skills-directory.test.ts +++ b/src/agents/skills.agents-skills-directory.test.ts @@ -51,7 +51,7 @@ describe("buildWorkspaceSkillsPrompt — .agents/skills/ directories", () => { await restoreMockSkillsHomeEnv(envSnapshot, async () => { await Promise.all( tempDirs - .splice(0, tempDirs.length) + .splice(0) .map((dir) => fs.rm(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 20 }), ), diff --git a/src/agents/skills.buildworkspaceskillstatus.test.ts b/src/agents/skills.buildworkspaceskillstatus.test.ts index e2f22fbd77b..5fc642d138d 100644 --- a/src/agents/skills.buildworkspaceskillstatus.test.ts +++ b/src/agents/skills.buildworkspaceskillstatus.test.ts @@ -11,9 +11,7 @@ import type { SkillEntry } from "./skills/types.js"; const tempDirs: string[] = []; afterEach(async () => { - await Promise.all( - tempDirs.splice(0, tempDirs.length).map((dir) => fs.rm(dir, { recursive: true, force: true })), - ); + await Promise.all(tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true }))); }); function makeEntry(params: { diff --git a/src/agents/skills.e2e-test-helpers.test.ts b/src/agents/skills.e2e-test-helpers.test.ts index ffa6922cb2e..849878597e6 100644 --- a/src/agents/skills.e2e-test-helpers.test.ts +++ b/src/agents/skills.e2e-test-helpers.test.ts @@ -17,9 +17,7 @@ async function withTempSkillDir( } afterEach(async () => { - await Promise.all( - tempDirs.splice(0, tempDirs.length).map((dir) => fs.rm(dir, { recursive: true, force: true })), - ); + await Promise.all(tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true }))); }); describe("writeSkill", () => { diff --git a/src/agents/skills.loadworkspaceskillentries.test.ts b/src/agents/skills.loadworkspaceskillentries.test.ts index f44c83e4b9e..cb90b540c0d 100644 --- a/src/agents/skills.loadworkspaceskillentries.test.ts +++ b/src/agents/skills.loadworkspaceskillentries.test.ts @@ -41,9 +41,7 @@ afterEach(async () => { }); afterAll(async () => { - await Promise.all( - tempDirs.splice(0, tempDirs.length).map((dir) => fs.rm(dir, { recursive: true, force: true })), - ); + await Promise.all(tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true }))); await restoreMockSkillsHomeEnv(envSnapshot, async () => { if (fakeHome) { await fs.rm(fakeHome, { recursive: true, force: true }); diff --git a/src/agents/subagent-announce-queue.ts b/src/agents/subagent-announce-queue.ts index e4e9eccf0ec..0af29d458f4 100644 --- a/src/agents/subagent-announce-queue.ts +++ b/src/agents/subagent-announce-queue.ts @@ -162,7 +162,7 @@ function scheduleAnnounceDrain(key: string) { prompt, internalEvents: internalEvents.length > 0 ? internalEvents : last.internalEvents, }); - queue.items.splice(0, items.length); + queue.items.splice(0); if (summary) { clearQueueSummaryState(queue); } diff --git a/src/auto-reply/reply/acp-projector.ts b/src/auto-reply/reply/acp-projector.ts index 4fe91184bdf..3105afbcc21 100644 --- a/src/auto-reply/reply/acp-projector.ts +++ b/src/auto-reply/reply/acp-projector.ts @@ -279,7 +279,7 @@ export function createAcpReplyProjector(params: { if (!(settings.deliveryMode === "final_only" && force)) { return; } - for (const entry of pendingToolDeliveries.splice(0, pendingToolDeliveries.length)) { + for (const entry of pendingToolDeliveries.splice(0)) { await params.deliver("tool", entry.payload, entry.meta); } }; diff --git a/src/auto-reply/reply/queue/drain.ts b/src/auto-reply/reply/queue/drain.ts index 30584259040..0369a40157a 100644 --- a/src/auto-reply/reply/queue/drain.ts +++ b/src/auto-reply/reply/queue/drain.ts @@ -219,7 +219,7 @@ export function scheduleFollowupDrain( enqueuedAt: Date.now(), ...routing, }); - queue.items.splice(0, groupItems.length); + queue.items.splice(0); if (pendingSummary) { clearQueueSummaryState(queue); pendingSummary = undefined; diff --git a/src/infra/system-events.ts b/src/infra/system-events.ts index 2496481c4f1..6600b4110d0 100644 --- a/src/infra/system-events.ts +++ b/src/infra/system-events.ts @@ -167,7 +167,7 @@ export function consumeSystemEventEntries( ) { return []; } - const removed = entry.queue.splice(0, consumedEntries.length).map(cloneSystemEvent); + const removed = entry.queue.splice(0).map(cloneSystemEvent); if (entry.queue.length === 0) { entry.lastText = null; entry.lastContextKey = null; diff --git a/src/plugins/bundle-mcp.test-support.ts b/src/plugins/bundle-mcp.test-support.ts index c9782fcce74..d1f3f376c92 100644 --- a/src/plugins/bundle-mcp.test-support.ts +++ b/src/plugins/bundle-mcp.test-support.ts @@ -18,9 +18,7 @@ export function createBundleMcpTempHarness() { clearPluginDiscoveryCache(); clearPluginManifestRegistryCache(); await Promise.all( - tempDirs - .splice(0, tempDirs.length) - .map((dir) => fs.rm(dir, { recursive: true, force: true })), + tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })), ); }, }; diff --git a/src/plugins/bundled-capability-runtime.ts b/src/plugins/bundled-capability-runtime.ts index cf37c425d2c..3e1f8d5b51b 100644 --- a/src/plugins/bundled-capability-runtime.ts +++ b/src/plugins/bundled-capability-runtime.ts @@ -69,8 +69,8 @@ function applyVitestCapabilityAliasOverrides(params: { } const { - ["openclaw/plugin-sdk"]: _ignoredLegacyRootAlias, - ["@openclaw/plugin-sdk"]: _ignoredScopedRootAlias, + "openclaw/plugin-sdk": _ignoredLegacyRootAlias, + "@openclaw/plugin-sdk": _ignoredScopedRootAlias, ...scopedAliasMap } = params.aliasMap; return { diff --git a/src/plugins/contracts/runtime-seams.contract.test.ts b/src/plugins/contracts/runtime-seams.contract.test.ts index 28dce380bb8..41065dd9df8 100644 --- a/src/plugins/contracts/runtime-seams.contract.test.ts +++ b/src/plugins/contracts/runtime-seams.contract.test.ts @@ -89,7 +89,7 @@ afterEach(() => { } else { Reflect.deleteProperty(globalThis as object, "fetch"); } - for (const dir of tempDirs.splice(0, tempDirs.length)) { + for (const dir of tempDirs.splice(0)) { fs.rmSync(dir, { recursive: true, force: true }); } }); diff --git a/src/plugins/generated-plugin-test-helpers.ts b/src/plugins/generated-plugin-test-helpers.ts index 86c2ed18e5b..8bac2c70b5b 100644 --- a/src/plugins/generated-plugin-test-helpers.ts +++ b/src/plugins/generated-plugin-test-helpers.ts @@ -20,7 +20,7 @@ export function createGeneratedPluginTempRoot(prefix: string): string { export function installGeneratedPluginTempRootCleanup() { afterEach(() => { - for (const dir of tempDirs.splice(0, tempDirs.length)) { + for (const dir of tempDirs.splice(0)) { fs.rmSync(dir, { recursive: true, force: true }); } }); diff --git a/test/helpers/temp-dir.ts b/test/helpers/temp-dir.ts index 578321c2219..6ba58e73c3b 100644 --- a/test/helpers/temp-dir.ts +++ b/test/helpers/temp-dir.ts @@ -13,7 +13,7 @@ export function makeTempDir(tempDirs: string[] | Set, prefix: string): s } export function cleanupTempDirs(tempDirs: string[] | Set): void { - const dirs = Array.isArray(tempDirs) ? tempDirs.splice(0, tempDirs.length) : [...tempDirs]; + const dirs = Array.isArray(tempDirs) ? tempDirs.splice(0) : [...tempDirs]; for (const dir of dirs) { fs.rmSync(dir, { recursive: true, force: true }); } diff --git a/test/helpers/temp-repo.ts b/test/helpers/temp-repo.ts index f5633588adc..9a2a8ca33cf 100644 --- a/test/helpers/temp-repo.ts +++ b/test/helpers/temp-repo.ts @@ -14,7 +14,7 @@ export function writeJsonFile(filePath: string, value: unknown): void { } export function cleanupTempDirs(tempDirs: string[]): void { - for (const dir of tempDirs.splice(0, tempDirs.length)) { + for (const dir of tempDirs.splice(0)) { fs.rmSync(dir, { recursive: true, force: true }); } }