Skip to content

fix: align switch-exhaustiveness-check with upstream - #1743

Draft
fansenze wants to merge 1 commit into
mainfrom
fix/switch-exhaustiveness-check-alignment-20260814
Draft

fix: align switch-exhaustiveness-check with upstream#1743
fansenze wants to merge 1 commit into
mainfrom
fix/switch-exhaustiveness-check-alignment-20260814

Conversation

@fansenze

@fansenze fansenze commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Align @typescript-eslint/switch-exhaustiveness-check diagnostics and missing-case order with TypeScript/typescript-eslint behavior.
  • Generate enum and unique-symbol suggestions only from checker-proven runtime paths, preserving aliases, namespace qualification, renamed exports, type-only boundaries, and compiler-target-aware property access.
  • Match defaultCaseCommentPattern with ECMAScript Unicode (u) semantics and ECMAScript whitespace trimming, with bounded compilation, matching, caching, and file-local resource fuses.
  • Fully escape generated JavaScript string literals and document intentional process-safety and suggestion-safety differences.
  • Keep default-comment lookup and edit construction demand-aware so ordinary diagnostics avoid optional work.

Go benchmark

Median of 8 runs:

GOWORK=off go test ./internal/plugins/typescript/rules/switch_exhaustiveness_check \
  -run '^$' \
  -bench '^BenchmarkSwitchExhaustivenessCheck$' \
  -benchmem \
  -benchtime=100ms \
  -count=8
Case ns/op before → after B/op before → after allocs/op before → after
Exhaustive matched 2507.5 → 2132.5 4854 → 3197.5 65 → 44
Missing diagnostics only 6314 → 5819.5 16919.5 → 15234.5 180 → 159
Missing suggestion 15905 → 6603 77342.5 → 17792.5 357 → 175
Non-union default diagnostics 1793 → 1433 5268 → 3675 57 → 44
Non-union default suggestion 1944 → 1635 5637 → 4044 63 → 50
Custom pattern matched 3159 → 5938 9616 → 13783 100 → 291
Custom pattern no-match 3827 → 6757.5 10765 → 16213 112 → 319
Unnecessary default 1578.5 → 1587.5 3340 → 3340 42 → 42
No-switch control 1107 → 1087.5 3131 → 3131 36 → 36

The custom-pattern cases reflect the deliberate cost of replacing regexp2's approximation with an ECMAScript-compatible engine; default and ordinary diagnostic/suggestion paths improve or remain allocation-neutral.

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@fansenze
fansenze marked this pull request as draft August 15, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant