chore: enable no-unreachable-loop#9540
chore: enable no-unreachable-loop#9540JoshuaKGoldberg merged 5 commits intotypescript-eslint:mainfrom
Conversation
|
Thanks for the PR, @abrahamguo! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9540 +/- ##
==========================================
- Coverage 88.45% 88.45% -0.01%
==========================================
Files 422 422
Lines 14694 14693 -1
Branches 4299 4299
==========================================
- Hits 12997 12996 -1
Misses 1372 1372
Partials 325 325
Flags with carried forward coverage won't be shown. Click here to find out more.
|
| return [] as any[]; | ||
| } | ||
| `, | ||
| 'const foo: (() => void) | undefined = () => 1;', |
There was a problem hiding this comment.
functionType.getCallSignatures() can return an empty array, but that code path was not being tested. This ensures that the code path is now covered.
There was a problem hiding this comment.
This was brought to light because when I initially refactored the rule to assume that getCallSignatures()[0] was always defined, the tests passed, but the rule crashed when linting this repo, therefore showing that a test was missing.
| : AllowedType.Number; | ||
| } | ||
| } | ||
| const [{ initializer }] = (declarations[0] as ts.EnumDeclaration) |
There was a problem hiding this comment.
Love this because this exposes a bug (not sure if it's intentional)! Checking declarations[0] is almost always a bug.
There was a problem hiding this comment.
Is this truly a bug? Is it possible for a symbol to have multiple declarations, that would be different from each other?
There was a problem hiding this comment.
No; if a symbol returns multiple declarations, that means these sites are merged together and should be treated as one. That's my understanding; I haven't verified it.
There was a problem hiding this comment.
Appreciate you being proactive about adding that test 🙂
…o-unreachable-loop
…o-unreachable-loop
There was a problem hiding this comment.
A chore so good, it got promoted to a fix(eslint-plugin). Nice! 💪
|
@JoshuaKGoldberg I don't think there are behavior differences with this PR? The logic of no-unsafe-return wasn't buggy, I think (well it could be, since only caring about the first signature still seems fishy). |
|
Oh, gotcha - I misinterpreted. Never mind then. 🙂 |
8bf8fd3

PR Checklist
Overview
Enable
no-unreachable-loop(docs)