Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
chore: enable no-unreachable-loop#9540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
chore: enable no-unreachable-loop#9540
Uh oh!
There was an error while loading.Please reload this page.
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 onhttps://opencollective.com/typescript-eslint. |
netlifybot commentedJul 11, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify site configuration. |
nx-cloudbot commentedJul 11, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
codecovbot commentedJul 11, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This was brought to light because when I initially refactored the rule to assume thatgetCallSignatures()[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]asts.EnumDeclaration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Love this because this exposes a bug (not sure if it's intentional)! Checkingdeclarations[0] is almost always a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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.
kirkwaiblinger left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Appreciate you being proactive about adding that test 🙂
JoshuaKGoldberg left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Achore so good, it got promoted to afix(eslint-plugin). Nice! 💪
Josh-Cena commentedJul 20, 2024
@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). |
JoshuaKGoldberg commentedJul 20, 2024
Oh, gotcha - I misinterpreted. Never mind then. 🙂 |
8bf8fd3
Uh oh!
There was an error while loading.Please reload this page.
PR Checklist
Overview
Enable
no-unreachable-loop(docs)