no-fallthrough doesn't seem to work
See original GitHub issueMaybe I am missing something, but the following code snippet lints successfully when I enter it into http://eslint.org/demo/. I expected it to fail with no-fallthrough
.
switch ("foo") {
case "foo":
case "bar":
break;
default:
throw new Error();
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:19 (17 by maintainers)
Top Results From Across the Web
Switch Fall Through Not Working as Expected - Stack Overflow
Your error is in believeing cases MSI and BI to be two different switch sections separated by an empty switch case body. There...
Read more >no-fallthrough - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Fallthrough in Switch Statements doesn't work for Patterns
Attempting to do fallthrough within switch statement with patterns does not work. See attached file for example of working pattern, non-stacked, ...
Read more >switch - JavaScript - MDN Web Docs - Mozilla
Breaking and fall-through. You can use the break statement within a switch statement's body to break out early, often when all statements ...
Read more >An end to implicit fall-throughs in the kernel - LWN.net
since the following is not valid C and a "raw" [[fallthrough]] is difficult ... doesn't work one though - the preprocessor will remove...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We originally had this as an exception because it’s a pretty common way to say you want fall through (even JSLint allows it):
My opinion is that this should still not warn. However, this definitely should warn:
So, if I’ve read this issue correct, it’s really the latter case that is problematic and I’d say it’s a bug that it’s not being flagged right now. @Grandrath is that correct?
Yup. If the two cases aren’t directly adjacent, then it should warn.