chore: Enable some "perf" lint rules.

This commit is contained in:
cpojer
2026-01-31 15:58:24 +09:00
parent f99e3ddd6d
commit 7a9ddcd590
8 changed files with 20 additions and 13 deletions

View File

@@ -6,7 +6,14 @@
"oxc"
],
"categories": {
"correctness": "error"
"correctness": "error",
"perf": "error"
},
"rules": {
"eslint-plugin-unicorn/prefer-array-find": "off",
"eslint/no-await-in-loop": "off",
"oxc/no-accumulating-spread": "off",
"oxc/no-map-spread": "off"
},
"ignorePatterns": ["src/canvas-host/a2ui/a2ui.bundle.js"]
}

View File

@@ -226,10 +226,10 @@ export function buildAuthHealthSummary(params: {
provider.remainingMs = provider.expiresAt - now;
}
const statuses = expirable.map((p) => p.status);
if (statuses.includes("expired") || statuses.includes("missing")) {
const statuses = new Set(expirable.map((p) => p.status));
if (statuses.has("expired") || statuses.has("missing")) {
provider.status = "expired";
} else if (statuses.includes("expiring")) {
} else if (statuses.has("expiring")) {
provider.status = "expiring";
} else {
provider.status = "ok";

View File

@@ -434,7 +434,7 @@ export function resolveModelDirectiveSelection(params: {
defaultProvider,
defaultModel,
});
return { candidate, ...details };
return Object.assign({ candidate }, details);
})
.sort((a, b) => {
if (b.score !== a.score) return b.score - a.score;

View File

@@ -225,11 +225,11 @@ function auditGatewayServicePath(
.split(getPathModule(platform).delimiter)
.map((entry) => entry.trim())
.filter(Boolean);
const normalizedParts = parts.map((entry) => normalizePathEntry(entry, platform));
const normalizedParts = new Set(parts.map((entry) => normalizePathEntry(entry, platform)));
const normalizedExpected = new Set(expected.map((entry) => normalizePathEntry(entry, platform)));
const missing = expected.filter((entry) => {
const normalized = normalizePathEntry(entry, platform);
return !normalizedParts.includes(normalized);
return !normalizedParts.has(normalized);
});
if (missing.length > 0) {
issues.push({

View File

@@ -331,13 +331,13 @@ export function resolveGroupDmAllow(params: {
}) {
const { channels, channelId, channelName, channelSlug } = params;
if (!channels || channels.length === 0) return true;
const allowList = channels.map((entry) => normalizeDiscordSlug(String(entry)));
const allowList = new Set(channels.map((entry) => normalizeDiscordSlug(String(entry))));
const candidates = [
normalizeDiscordSlug(channelId),
channelSlug,
channelName ? normalizeDiscordSlug(channelName) : "",
].filter(Boolean);
return allowList.includes("*") || candidates.some((candidate) => allowList.includes(candidate));
return allowList.has("*") || candidates.some((candidate) => allowList.has(candidate));
}
export function shouldEmitDiscordReactionNotification(params: {

View File

@@ -218,7 +218,7 @@ export async function loadCostUsageSummary(params?: {
}
const daily = Array.from(dailyMap.entries())
.map(([date, bucket]) => ({ date, ...bucket }))
.map(([date, bucket]) => Object.assign({ date }, bucket))
.sort((a, b) => a.date.localeCompare(b.date));
return {

View File

@@ -527,7 +527,7 @@ export class MemoryIndexManager {
entry.chunks = row.c ?? 0;
bySource.set(row.source, entry);
}
return sources.map((source) => ({ source, ...bySource.get(source)! }));
return sources.map((source) => Object.assign({ source }, bySource.get(source)!));
})();
return {
files: files?.c ?? 0,

View File

@@ -310,8 +310,8 @@ describe("createTelegramBot", () => {
{ command: "custom_backup", description: "Git backup" },
{ command: "custom_generate", description: "Create an image" },
]);
const reserved = listNativeCommandSpecs().map((command) => command.name);
expect(registered.some((command) => reserved.includes(command.command))).toBe(false);
const reserved = new Set(listNativeCommandSpecs().map((command) => command.name));
expect(registered.some((command) => reserved.has(command.command))).toBe(false);
});
it("uses wrapped fetch when global fetch is available", () => {