unthrown icon indicating copy to clipboard operation
unthrown copied to clipboard

oxlint no-catch-all-pattern: allow P._ when E is a single non-union type

Open btravers opened this issue 3 months ago • 0 comments

Found while auditing btravstack/start (2026-08-13).

@unthrown/oxlint's no-catch-all-pattern documentation already names the legitimate P._ cases: a helper generic in E, or an E that is a single non-union type with nothing to enumerate. But the rule flags those cases anyway, so idiomatic code carries a disable comment.

Concrete cost, measured in btravstack/start: the env-validation fold

// oxlint-disable-next-line unthrown/no-catch-all-pattern -- `E` is the issues array: one type with no discriminant, so there is nothing to enumerate and the single arm IS the enumeration
errCases: (matcher) => matcher.with(P._, (issues) => abort(describeEnvIssues(issues))),

is copy-pasted verbatim into four entry points (E = a standard-schema issues array — one non-union type). When the idiomatic path requires a suppression, the suppression stops carrying information.

Acceptance

  • The rule does not flag P._ when the matched E is provably a single non-union type (and, if feasible, the unresolved-generic-E case).
  • Sites that currently carry the disable for exactly that reason can drop it (an unused disable is already a warning, so the cleanup is self-indicating).

btravers avatar Aug 13 '26 18:08 btravers