-
-
Notifications
You must be signed in to change notification settings - Fork 2.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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: enable no-unreachable-loop #9540
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.
|
@@ -127,6 +127,7 @@ function foo(): Set<number> { | |||
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 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.
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)! Checking declarations[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.
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 🙂
…o-unreachable-loop
…o-unreachable-loop
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.
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
6647f7e
into
typescript-eslint:main
PR Checklist
Overview
Enable
no-unreachable-loop
(docs)