chore(lint): enable additional cleanup rules

This commit is contained in:
Peter Steinberger 2026-04-18 20:00:26 +01:00
parent 4fa961d4f1
commit 155162a8cd
No known key found for this signature in database
22 changed files with 39 additions and 42 deletions

View file

@ -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"
},

View file

@ -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 });
}
});

View file

@ -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 })),
);
});

View file

@ -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" });

View file

@ -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,
};

View file

@ -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 })),
);
});

View file

@ -18,9 +18,7 @@ const tempDirs: string[] = [];
export async function cleanupBundleMcpHarness(): Promise<void> {
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<string> {

View file

@ -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)", () => {

View file

@ -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 }),
),

View file

@ -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: {

View file

@ -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", () => {

View file

@ -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 });

View file

@ -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);
}

View file

@ -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);
}
};

View file

@ -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;

View file

@ -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;

View file

@ -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 })),
);
},
};

View file

@ -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 {

View file

@ -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 });
}
});

View file

@ -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 });
}
});

View file

@ -13,7 +13,7 @@ export function makeTempDir(tempDirs: string[] | Set<string>, prefix: string): s
}
export function cleanupTempDirs(tempDirs: string[] | Set<string>): 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 });
}

View file

@ -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 });
}
}