From d3fd85c37de34cc83b2b0fa6c110525b12934fdb Mon Sep 17 00:00:00 2001 From: "jared-outpost[bot]" Date: Wed, 26 Aug 2026 12:51:21 +0000 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20extend=20no-silent-catch.grit=20to?= =?UTF-8?q?=20also=20match=20catch=E2=80=A6finally=20forms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per BYK review feedback on #1487, add the six patterns (and the matching variants) so a silent catch followed by a is still caught. The current tree still has zero silent sites, so the 197 grandfathered suppressions remain valid and lint stays clean. --- packages/cli/lint-rules/no-silent-catch.grit | 42 ++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 packages/cli/lint-rules/no-silent-catch.grit diff --git a/packages/cli/lint-rules/no-silent-catch.grit b/packages/cli/lint-rules/no-silent-catch.grit new file mode 100644 index 000000000..a612a6a9e --- /dev/null +++ b/packages/cli/lint-rules/no-silent-catch.grit @@ -0,0 +1,42 @@ +language js + +// Flags "silent" catch blocks: a `catch` clause (or a `.catch()` handler) whose +// body is empty, a bare `return;`, or `return ;` that does not reference +// the caught error. Errors must be surfaced via log.debug()/log.warn() or +// re-thrown (see AGENTS.md). Biome's built-in noEmptyBlockStatements only +// covers syntactically empty `catch {}`; this also covers comment-only and +// return-only bodies. +// +// This replaces the hand-rolled detector in script/check-error-patterns.ts. +// The pre-existing backlog is grandfathered with inline +// `// biome-ignore lint/plugin: ` comments. Removing a grandfathered +// catch orphans its suppression, which Biome reports as `suppressions/unused`; +// the lint step runs with `--error-on-warnings`, so the backlog can only shrink +// (the same ratchet the old baseline JSON provided). +// +// Registered via an override scoped to `src/**` in biome.jsonc (the old script +// only scanned `src/**/*.ts`). +or { + `try { $t } catch { }`, + `try { $t } catch { return; }`, + `try { $t } catch { return $r; }`, + `try { $t } catch ($e) { }`, + `try { $t } catch ($e) { return; }`, + `try { $t } catch ($e) { return $r; }` where { $r <: not contains $e }, + `try { $t } catch { } finally { $f }`, + `try { $t } catch { return; } finally { $f }`, + `try { $t } catch { return $r; } finally { $f }`, + `try { $t } catch ($e) { } finally { $f }`, + `try { $t } catch ($e) { return; } finally { $f }`, + `try { $t } catch ($e) { return $r; } finally { $f }` where { + $r <: not contains $e + }, + `$p.catch(() => { })`, + `$p.catch(() => { return; })`, + `$p.catch(() => { return $r; })`, + `$p.catch(($e) => { })`, + `$p.catch(($e) => { return; })`, + `$p.catch(($e) => { return $r; })` where { $r <: not contains $e } +} as $m where { + register_diagnostic(span=$m, message="Silent catch block. Add log.debug()/log.warn() or re-throw — errors must not vanish (AGENTS.md). If the suppression is intentional, grandfather it with `// biome-ignore lint/plugin: `.") +} From 827c5da402748273888d3898f4b0e5ee97835acd Mon Sep 17 00:00:00 2001 From: "jared-outpost[bot]" Date: Wed, 26 Aug 2026 13:55:09 +0000 Subject: [PATCH 2/2] feat: extend no-silent-catch.grit to typed catch bindings GritQL type-annotation metavariables don't bind, so the untyped `catch ($e)` patterns missed `catch (e: unknown)` / `catch (e: any)`. TypeScript only permits unknown or any as a catch binding type, so add literal variants for both across the empty / return / return-value forms, with and without finally. The error-forwarding guard is preserved. --- packages/cli/lint-rules/no-silent-catch.grit | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/cli/lint-rules/no-silent-catch.grit b/packages/cli/lint-rules/no-silent-catch.grit index a612a6a9e..7d8daa5a9 100644 --- a/packages/cli/lint-rules/no-silent-catch.grit +++ b/packages/cli/lint-rules/no-silent-catch.grit @@ -23,6 +23,18 @@ or { `try { $t } catch ($e) { }`, `try { $t } catch ($e) { return; }`, `try { $t } catch ($e) { return $r; }` where { $r <: not contains $e }, + // Typed catch bindings. GritQL type-annotation metavariables don't bind, so + // the untyped `catch ($e)` patterns above miss `catch (e: unknown)` / + // `catch (e: any)`. TypeScript only permits `unknown` or `any` as a catch + // binding type, so those two literals cover every typed form. + `try { $t } catch ($e: unknown) { }`, + `try { $t } catch ($e: unknown) { return; }`, + `try { $t } catch ($e: unknown) { return $r; }` where { + $r <: not contains $e + }, + `try { $t } catch ($e: any) { }`, + `try { $t } catch ($e: any) { return; }`, + `try { $t } catch ($e: any) { return $r; }` where { $r <: not contains $e }, `try { $t } catch { } finally { $f }`, `try { $t } catch { return; } finally { $f }`, `try { $t } catch { return $r; } finally { $f }`, @@ -31,6 +43,16 @@ or { `try { $t } catch ($e) { return $r; } finally { $f }` where { $r <: not contains $e }, + `try { $t } catch ($e: unknown) { } finally { $f }`, + `try { $t } catch ($e: unknown) { return; } finally { $f }`, + `try { $t } catch ($e: unknown) { return $r; } finally { $f }` where { + $r <: not contains $e + }, + `try { $t } catch ($e: any) { } finally { $f }`, + `try { $t } catch ($e: any) { return; } finally { $f }`, + `try { $t } catch ($e: any) { return $r; } finally { $f }` where { + $r <: not contains $e + }, `$p.catch(() => { })`, `$p.catch(() => { return; })`, `$p.catch(() => { return $r; })`,