From 0fa62d8177f2216b95739e3d36f87fc1a95886c5 Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Tue, 28 Jul 2026 19:10:30 +0530 Subject: chore: fail the build on unguarded type assertions A clean tsc does not prove the absence of casts. This scans src/ for as any, ts-ignore, non-null assertions, inline object casts, and double casts, wired into a new npm run check that CI runs as a single step. The escape hatch is an external allowlist module rather than an inline comment marker: comments are not used in this codebase, and an entry carries a count, so adding a new cast to an already-exempted file still fails until someone raises a number that shows up in the diff. Exactly one exemption is needed today, for the dynamic sharp import. scripts/ was gitignored wholesale, so the two new files are un-ignored individually and everything else dropped there stays ignored. Co-Authored-By: Claude Opus 5 (1M context) --- scripts/boundary-allowlist.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 scripts/boundary-allowlist.ts (limited to 'scripts/boundary-allowlist.ts') diff --git a/scripts/boundary-allowlist.ts b/scripts/boundary-allowlist.ts new file mode 100644 index 0000000..be6816f --- /dev/null +++ b/scripts/boundary-allowlist.ts @@ -0,0 +1,16 @@ +export type Exemption = { + readonly path: string; + readonly rule: string; + readonly count: number; + readonly reason: string; +}; + +export const ALLOWLIST: ReadonlyArray = [ + { + path: "src/util/sharp-shim.ts", + rule: "inline-object-cast", + count: 1, + reason: + "sharp is an optional dependency resolved by a dynamic import, so its shape is unknown at compile time; the cast only claims an optional .default and every value read off it is re-checked with typeof before use", + }, +]; -- cgit v1.2.3