From 8eda5670bd56067db967e4e08aabfa00d448acc4 Mon Sep 17 00:00:00 2001 From: Laith Al-Saadoon <9553966+theagenticguy@users.noreply.github.com> Date: Wed, 22 Apr 2026 22:26:30 -0500 Subject: [PATCH] chore: clean Biome findings, align lint rules with tsconfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Brings the repo to zero Biome warnings / infos / errors. Three changes: 1. Disable `lint/complexity/useLiteralKeys` globally. It actively conflicts with the tsconfig's `noPropertyAccessFromIndexSignature: true` — Biome wants `record.key` while the TypeScript compiler requires `record["key"]` on Record-typed index signatures. tsconfig wins; Biome rule gets switched off. Drops 480 infos and lets us remove 10 per-site `biome-ignore` suppression comments that were papering over the conflict. 2. Override `noConsole: off` for `packages/cli/src/commands/**`. CLI commands print to stdout as a feature (verdict output, impact lists, etc.) — those aren't debug statements. Drops 52 warnings. 3. Hand-fix 4 `useTemplate` infos in onnx-embedder.ts and profile.test.ts (concatenation → template literals). Real small-win improvements. Also bumped biome.json `$schema` reference from 2.4.0 → 2.4.12 to match the installed Biome version. Verified: - `pnpm exec biome check .`: 0 errors, 0 warnings, 0 infos - `pnpm -r build`: clean - `pnpm -r exec tsc --noEmit`: clean - `pnpm -r test`: 952 pass / 0 fail - `bash scripts/check-banned-strings.sh`: clean --- biome.json | 17 +++++++++++++++-- packages/embedder/src/onnx-embedder.ts | 6 ++---- .../src/pipeline/phases/profile.test.ts | 9 ++++----- packages/mcp/src/next-step-hints.test.ts | 1 - packages/mcp/src/next-step-hints.ts | 1 - packages/mcp/src/resources/repo-context.ts | 1 - packages/sarif/src/enrich.ts | 1 - packages/storage/src/meta.ts | 6 ------ 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/biome.json b/biome.json index e79b8b47..a669ea16 100644 --- a/biome.json +++ b/biome.json @@ -1,5 +1,5 @@ { - "$schema": "https://biomejs.dev/schemas/2.4.0/schema.json", + "$schema": "https://biomejs.dev/schemas/2.4.12/schema.json", "root": true, "files": { "includes": ["packages/**/src/**", "packages/**/test/**", "scripts/**/*.{js,mjs,ts}"], @@ -36,6 +36,7 @@ "useImportType": "error" }, "complexity": { + "useLiteralKeys": "off", "useOptionalChain": "error" } } @@ -46,5 +47,17 @@ "organizeImports": "on" } } - } + }, + "overrides": [ + { + "includes": ["packages/cli/src/commands/**"], + "linter": { + "rules": { + "suspicious": { + "noConsole": "off" + } + } + } + } + ] } diff --git a/packages/embedder/src/onnx-embedder.ts b/packages/embedder/src/onnx-embedder.ts index b3d07954..801c8366 100644 --- a/packages/embedder/src/onnx-embedder.ts +++ b/packages/embedder/src/onnx-embedder.ts @@ -293,7 +293,7 @@ class OnnxEmbedder implements Embedder { const hidden = results["last_hidden_state"]; if (hidden === undefined || hidden.type !== "float32") { throw new Error( - `ONNX session did not return float32 last_hidden_state ` + `(got ${String(hidden?.type)})`, + `ONNX session did not return float32 last_hidden_state (got ${String(hidden?.type)})`, ); } // Shape is [B, seqLen, hiddenSize]. hiddenSize derived from data length @@ -302,9 +302,7 @@ class OnnxEmbedder implements Embedder { const data = hidden.data as Float32Array; const hiddenSize = data.length / (batchSize * batchMax); if (hiddenSize !== EMBED_DIM) { - throw new Error( - `Expected hidden size ${EMBED_DIM}, got ${hiddenSize}. ` + `Wrong model loaded?`, - ); + throw new Error(`Expected hidden size ${EMBED_DIM}, got ${hiddenSize}. Wrong model loaded?`); } const out: Float32Array[] = []; diff --git a/packages/ingestion/src/pipeline/phases/profile.test.ts b/packages/ingestion/src/pipeline/phases/profile.test.ts index e2175259..010d5be5 100644 --- a/packages/ingestion/src/pipeline/phases/profile.test.ts +++ b/packages/ingestion/src/pipeline/phases/profile.test.ts @@ -57,7 +57,7 @@ describe("profilePhase — polyglot TS + Python + Terraform + OpenAPI + Next.js ); await fs.writeFile( path.join(repo, "pyproject.toml"), - [ + `${[ "[project]", 'name = "polyglot-svc"', 'version = "0.0.1"', @@ -65,7 +65,7 @@ describe("profilePhase — polyglot TS + Python + Terraform + OpenAPI + Next.js ' "django>=4.0",', ' "fastapi>=0.100",', "]", - ].join("\n") + "\n", + ].join("\n")}\n`, ); // requirements.txt should be shadowed by pyproject in the cascade await fs.writeFile(path.join(repo, "requirements.txt"), "flask==2.2.0\n"); @@ -79,8 +79,7 @@ describe("profilePhase — polyglot TS + Python + Terraform + OpenAPI + Next.js await fs.mkdir(path.join(repo, "api"), { recursive: true }); await fs.writeFile( path.join(repo, "api", "openapi.yaml"), - ["openapi: 3.0.3", "info:", " title: Sample", " version: 1.0.0", "paths: {}"].join("\n") + - "\n", + `${["openapi: 3.0.3", "info:", " title: Sample", " version: 1.0.0", "paths: {}"].join("\n")}\n`, ); // Docker @@ -90,7 +89,7 @@ describe("profilePhase — polyglot TS + Python + Terraform + OpenAPI + Next.js await fs.mkdir(path.join(repo, "deploy"), { recursive: true }); await fs.writeFile( path.join(repo, "deploy", "pod.yaml"), - ["apiVersion: v1", "kind: Pod", "metadata:", " name: demo"].join("\n") + "\n", + `${["apiVersion: v1", "kind: Pod", "metadata:", " name: demo"].join("\n")}\n`, ); // Source code directories. Python side: diff --git a/packages/mcp/src/next-step-hints.test.ts b/packages/mcp/src/next-step-hints.test.ts index fc4b37ed..fb7a594a 100644 --- a/packages/mcp/src/next-step-hints.test.ts +++ b/packages/mcp/src/next-step-hints.test.ts @@ -40,6 +40,5 @@ test("withNextSteps attaches staleness under codehub/staleness namespace", () => test("withNextSteps omits _meta entirely when no staleness", () => { const result = withNextSteps("x", { a: 1 }, ["hi"]); const sc = result.structuredContent as Record; - // biome-ignore lint/complexity/useLiteralKeys: dot-access disallowed on Record index signatures assert.equal(sc["_meta"], undefined); }); diff --git a/packages/mcp/src/next-step-hints.ts b/packages/mcp/src/next-step-hints.ts index 32df4fd8..1a2bb785 100644 --- a/packages/mcp/src/next-step-hints.ts +++ b/packages/mcp/src/next-step-hints.ts @@ -42,7 +42,6 @@ export function withNextSteps>( next_steps: [...nextSteps], }; if (Object.keys(meta).length > 0) { - // biome-ignore lint/complexity/useLiteralKeys: dot-access disallowed on Record index signatures structuredContent["_meta"] = meta; } diff --git a/packages/mcp/src/resources/repo-context.ts b/packages/mcp/src/resources/repo-context.ts index 111c3b83..56b217e3 100644 --- a/packages/mcp/src/resources/repo-context.ts +++ b/packages/mcp/src/resources/repo-context.ts @@ -54,7 +54,6 @@ export function registerRepoContextResource(server: McpServer, ctx: ResourceCont mimeType: "text/yaml", }, async (uri, variables): Promise => { - // biome-ignore lint/complexity/useLiteralKeys: dot-access disallowed on Record index signatures const raw = variables["name"]; const nameVar = Array.isArray(raw) ? raw[0] : raw; const decoded = nameVar ? decodeURIComponent(String(nameVar)) : undefined; diff --git a/packages/sarif/src/enrich.ts b/packages/sarif/src/enrich.ts index 147e129b..492d164d 100644 --- a/packages/sarif/src/enrich.ts +++ b/packages/sarif/src/enrich.ts @@ -161,7 +161,6 @@ function primaryFingerprint(result: unknown): string | undefined { if (!isPlainObject(result)) { return undefined; } - // biome-ignore lint/complexity/useLiteralKeys: dot-access is disallowed on Record index signatures (tsconfig's noPropertyAccessFromIndexSignature) const pf = result["partialFingerprints"]; if (!isPlainObject(pf)) { return undefined; diff --git a/packages/storage/src/meta.ts b/packages/storage/src/meta.ts index 70a0dc56..915b3258 100644 --- a/packages/storage/src/meta.ts +++ b/packages/storage/src/meta.ts @@ -75,29 +75,23 @@ function validateStoreMeta(value: unknown, source: string): asserts value is Sto } const v = value as Record; // Bracket access required by tsconfig's `noPropertyAccessFromIndexSignature`. - // biome-ignore lint/complexity/useLiteralKeys: dot-access is disallowed on Record index signatures if (typeof v["schemaVersion"] !== "string") { throw new Error(`Invalid meta.json at ${source}: schemaVersion missing`); } - // biome-ignore lint/complexity/useLiteralKeys: dot-access is disallowed on Record index signatures if (typeof v["indexedAt"] !== "string") { throw new Error(`Invalid meta.json at ${source}: indexedAt missing`); } - // biome-ignore lint/complexity/useLiteralKeys: dot-access is disallowed on Record index signatures if (typeof v["nodeCount"] !== "number" || typeof v["edgeCount"] !== "number") { throw new Error(`Invalid meta.json at ${source}: counts missing`); } - // biome-ignore lint/complexity/useLiteralKeys: dot-access is disallowed on Record index signatures const cacheHitRatio = v["cacheHitRatio"]; if (cacheHitRatio !== undefined && typeof cacheHitRatio !== "number") { throw new Error(`Invalid meta.json at ${source}: cacheHitRatio must be a number`); } - // biome-ignore lint/complexity/useLiteralKeys: dot-access is disallowed on Record index signatures const cacheSizeBytes = v["cacheSizeBytes"]; if (cacheSizeBytes !== undefined && typeof cacheSizeBytes !== "number") { throw new Error(`Invalid meta.json at ${source}: cacheSizeBytes must be a number`); } - // biome-ignore lint/complexity/useLiteralKeys: dot-access is disallowed on Record index signatures const lastCompaction = v["lastCompaction"]; if (lastCompaction !== undefined && typeof lastCompaction !== "string") { throw new Error(`Invalid meta.json at ${source}: lastCompaction must be a string`);