Enable strict unused-symbol checks and remove dead code

Turn on noUnusedLocals/noUnusedParameters so the compiler keeps flagging
dead symbols, then clear the 737 findings it reports: unused imports across
src/, unused parameters, unreachable locals, and the copy-pasted 135-line
import prologues in the seal tool modules (each tool file now imports only
what it uses). Also applies the equivalent-safe lint rewrites (Array.from
instead of new Array(n).fill, non-null assertions in tests after toBeDefined,
simplified spreads, unused catch params) that oxlint will gate in a later
commit.
This commit is contained in:
gitea committed 2026-09-29 22:04:01 +08:00
1 parent 661babd4f4
commit 5f4906758e
43 files changed
+55 -1150

No files matched your search

-2
View File
@@ -1,6 +1,5 @@
import { describe, expect, test } from "bun:test";
import {
existsSync,
lstatSync,
mkdirSync,
mkdtempSync,
@@ -14,7 +13,6 @@ import { tmpdir } from "node:os";
import { join } from "node:path";
import {
getAllAgentHostsStatus,
getAllLinkableHostsStatus,
getAntigravitySkillsStatus,
getHostSkillsStatus,
KNOWN_LINKABLE_HOSTS,
-1
View File
@@ -8,7 +8,6 @@ import {
assertHoseAssistTenantMatches,
defaultSealUrl,
exchangeHoseAssistLink,
fetchHoseOpenApiKeysFromLink,
fetchHoseStaffDetails,
getHoseEnterpriseUrl,
getHoseProvisionalAuthLink,
+1
View File
@@ -79,6 +79,7 @@ export const SealHeaderMapSchema = z.record(
export const SealCookieMapSchema = z.record(
z.string().regex(HTTP_TOKEN_PATTERN, "Invalid cookie name"),
// oxlint-disable-next-line no-control-regex -- rejecting control chars IS the check.
z.string().refine((value) => !/[\u0000-\u001f\u007f;]/.test(value), {
message: "Cookie value cannot contain control characters or semicolons"
})
+1 -1
View File
@@ -13,7 +13,7 @@ export function formatCookieHeader(cookies: Record<string, string> | undefined):
// same-named entry, while Authorization is always left to the caller so the
// session bearer token can never be silently replaced by config.
export function resolveSealCustomHeaders(seal: SealCustomHeaderSource | undefined): Record<string, string> {
const headers: Record<string, string> = { ...(seal?.headers ?? {}) };
const headers: Record<string, string> = { ...seal?.headers };
const cookieHeader = formatCookieHeader(seal?.cookies);
if (cookieHeader) headers.Cookie = cookieHeader;
return headers;
+1 -1
View File
@@ -1,4 +1,4 @@
import { existsSync, symlinkSync, rmSync } from "node:fs";
import { existsSync, symlinkSync } from "node:fs";
import { homedir } from "node:os";
import { basename, dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
-1
View File
@@ -4,7 +4,6 @@ import {
filterCorpsFuzzy,
fuzzyMatchString,
levenshteinDistance,
matchCorp,
minSubstringLevenshtein,
normalizeFuzzyPinyin
} from "./fuzzy.js";
+1 -1
View File
@@ -46,7 +46,7 @@ export function levenshteinDistance(a: string, b: string): number {
if (n === 0) return m;
let prevRow = Array.from({ length: n + 1 }, (_, j) => j);
let currRow = new Array<number>(n + 1).fill(0);
let currRow: number[] = Array.from({ length: n + 1 }, () => 0);
for (let i = 1; i <= m; i += 1) {
currRow[0] = i;
+1 -2
View File
@@ -1,12 +1,11 @@
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { mkdirSync, rmSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import { tmpdir } from "node:os";
import {
computeWindowCutoff,
getRecentCorpUsageScores,
loadUsageStats,
pruneExpiredStats,
recordCorpUsage,
resolveUsageFilePath,
sortCorpsByUsageAndRecency,
+1 -1
View File
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import {
+1 -1
View File
@@ -1,4 +1,4 @@
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
import { homedir } from "node:os";
import { dirname, join } from "node:path";
import { spawn } from "node:child_process";