mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-28 06:31:11 +00:00
chore(lint): enable additional cleanup rules
This commit is contained in:
parent
4fa961d4f1
commit
155162a8cd
22 changed files with 39 additions and 42 deletions
|
|
@ -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"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 })),
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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" });
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 })),
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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> {
|
||||
|
|
|
|||
|
|
@ -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)", () => {
|
||||
|
|
|
|||
|
|
@ -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 }),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -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: {
|
||||
|
|
|
|||
|
|
@ -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", () => {
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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 })),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue