Commit 15b246b
committed
chore(lint): warn on type-erasing assertions via a Biome GritQL plugin
Adds `biome-plugins/no-type-erasing-assertions.grit`, wired into biome.json,
that warns on `as any` / `as never` / `as unknown` in source — assertions that
punch through the type system instead of narrowing (a real mismatch can hide
behind them). `as const`, plain `as SpecificType`, and `never` as a type
annotation are NOT flagged. `as unknown` also catches the inner half of an
`as unknown as T` double-cast.
- severity `warn`: Biome is not a CI gate here (only local `code:fix`), and
there's a small existing backlog (~17 in src) — this is a ratchet to keep NEW
erasures visible, not a hard block. Warnings don't change `biome check`'s exit
code (verified).
- test/integration/*.test-d.ts files are exempt via an `overrides` entry — test
doubles legitimately force-cast; suppress a deliberate src case with
`// biome-ignore lint/plugin: <reason>`.
- Known limitation (documented in the plugin): matches only the bare forms, not
compound casts like `as never[]`.
Claude-Session: https://claude.ai/code/session_01MxTTPaPP16m6br7Hoab94w1 parent e9e81e6 commit 15b246b
3 files changed
Lines changed: 47 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
180 | 186 | | |
181 | 187 | | |
182 | 188 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
34 | 48 | | |
0 commit comments