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
Fix: allow fallthrough comment inside block (fixes #14701) #14702
Fix: allow fallthrough comment inside block (fixes #14701) #14702
Conversation
@bakkot thanks for the PR!
I agree, I think it's fine to allow any comments after |
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.
All changes look good, I only have some small requests about the documentation and a few additional tests.
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.
LGTM, thanks!
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.
LGTM
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.
Thanks, and congrats on your first ESLint pull request, @bakkot! This will be released today.
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[x] Bug fix
[x] Changes an existing rule
What rule do you want to change?
no-fallthrough
Does this change cause the rule to produce more or fewer warnings?
fewer
How will the change be implemented? (New option, new default behavior, etc.)?
new default
Please provide some example code that this change will affect:
What does the rule currently do for this code?
warn
What will the rule do after it's changed?
not warn
What changes did you make? (Give an overview)
Now when the case consists of a single BlockStatement the code will look for the fallthrough comment to be the final comment in the case, as well where it looked previously.
Is there anything you'd like reviewers to focus on?
In the situation in question - i.e., when the case consists of exactly one statement, which is a BlockStatement - I've chosen to check for the fallthrough comment in both places. This means that it becomes possible to have a comment after the fallthrough comment, as long as it's after the block, as in
I think that's correct, personally. However, I'm happy to be more restrictive and say that the fallthrough comment must also be the final comment: that is, to only look in the new place when there are no comments after the block.