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
Rule Change: no-fallthrough should not permit "falls through" comment when code will not fall through. #18182
Comments
Hi @kirkwaiblinger, thanks for the issue, i think reporting comments shouldn't be the default behavior of |
Makes sense to me 👍 I agree with @Tanujkanti4441 that this behavior should be behind an option. @eslint/eslint-team thoughts about this? |
👍 agreed this is a good idea for an opt-in. |
It looks like there is consensus to add the ability to flag useless |
…ule (#18188) * feat: (no-fallthrough) Report unused fallthrough comments fixes #18182 * add space * add a few test cases to ensure state doesn't leak across multiple switches * add correct case in docs * fix leaked state * Fix docs typo Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com> * add some test coverage --------- Co-authored-by: Milos Djermanovic <milos.djermanovic@gmail.com>
What rule do you want to change?
no-fallthrough
What change do you want to make?
Generate more warnings
How do you think the change should be implemented?
A new default behavior
Example code
What does the rule currently do for this code?
No warnings
What will the rule do after it's changed?
the
// fallthrough
comment should be flagged, because it incorrectly implies to a reader that a fallthrough can/will occur.Participation
Additional comments
This very similar in concept to
--report-unused-disable-directives
, so I'm not terribly sure whether it ought to flag as part of the rule per se, or when running--report-unused-disable-directives
. But I think that having this would be especially valuable for cases with a multiple branches, where it doesn't literally terminate in abreak
/return
. For example, something likeNote that if I put code where the
fallthrough
comment is, it would get flagged for being unreachablePS I discovered this organically, making this very mistake during refactoring
The text was updated successfully, but these errors were encountered: