Commit cb4fbb9
feat(linter/eslint): implement no-unreachable-loop rule (#23975)
## Summary
- add native `eslint/no-unreachable-loop` support
- support the ESLint `ignore` option for loop statement types
- reuse `no-unreachable`'s effective CFG reachability helper
(`effective_unreachable_blocks`)
- generate oxlint config schema/types and rule metadata
## Why
`no-unreachable-loop` is currently missing from Oxlint's ESLint rule
coverage. The rule catches loops whose body cannot reach a second
iteration, while preserving ESLint-compatible behavior for unreachable
loops and configured ignored loop types.
## Performance
The effective-reachability helper is a whole-CFG traversal. It is only
needed to recognize a loop that is dead code *after* an infinite loop;
the next-iteration search prunes infinite loops on its own. So the
analysis runs on the CFG's base reachability first and builds the
corrected map only when a loop would otherwise be reported *and* is a
static infinite loop — a rare path the common case never hits. This
keeps the rule self-contained and brings the `linter[binder.ts]` and
`linter[kitchen-sink.tsx]` benches from a ~4-5% regression down to
noise.
## AI Assistance
This PR was implemented with AI assistance.
---------
Co-authored-by: Cameron <cameron.clark@hey.com>1 parent cd8fdfe commit cb4fbb9
9 files changed
Lines changed: 7059 additions & 131 deletions
File tree
- apps/oxlint/src-js/package
- crates/oxc_linter/src
- generated
- rules/eslint
- snapshots
- utils
- npm/oxlint
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| 159 | + | |
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| |||
1208 | 1209 | | |
1209 | 1210 | | |
1210 | 1211 | | |
| 1212 | + | |
1211 | 1213 | | |
1212 | 1214 | | |
1213 | 1215 | | |
| |||
3592 | 3594 | | |
3593 | 3595 | | |
3594 | 3596 | | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
3595 | 3600 | | |
3596 | 3601 | | |
3597 | 3602 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
| 178 | + | |
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| |||
0 commit comments