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
no-fallthrough should allow the comment inside of a block when the case is a single block #14701
Comments
as a workaround, you can write the comment out the block: switch (foo) {
case 1: {
let x = value;
console.log(value);
}
// falls through
case 2: {
doSomething();
}
} IMHO, it seems a bug, no new option needed. but let's see what others thoughts. :) |
Agreed. If |
I'll prepare a PR for this unless someone is already working on it. |
@bakkot please feel free to open a PR, thanks! |
Done: #14702. |
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 behavior
Please provide some example code that this change will affect:
What does the rule currently do for this code?
Error
What will the rule do after it's changed?
Not error
Are you willing to submit a pull request to implement this change?
Yes
This has been brought up before, in #9559 and #9080, and with a PR in #11016. On each of those occasions it's been closed automatically without any interest. But those just asked for the new behavior without really explaining why.
I want to make a case the proposed change is the right behavior. The
fallthrough
comment is intended to replace abreak
, which means that a reader of the code will be looking for it where they would expect to find thebreak
. And the convention when using a bracedcase
is that thebreak
occurs within the braces, not outside of it. So that is where a reader should expect to find the comment, not (as eslint currently requires) after the braces. The placement required by the current rule actually makes the comment easier to miss.The text was updated successfully, but these errors were encountered: