eslint: no-fallthrough doesn't seem to work
Maybe 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();
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 19 (17 by maintainers)
Commits related to this issue
- Fix: `no-fallthrough` empty case with comment (fixes #5799) — committed to eslint/eslint by alberto 8 years ago
- Fix: `no-fallthrough` empty case with comment (fixes #5799) — committed to eslint/eslint by alberto 8 years ago
- Fix: `no-fallthrough` empty case with comment (fixes #5799) — committed to eslint/eslint by alberto 8 years ago
- Fix: `no-fallthrough` empty case with comment (fixes #5799) — committed to eslint/eslint by alberto 8 years ago
- Merge pull request #5813 from eslint/issue4799 Fix: `no-fallthrough` empty case with comment (fixes #5799) — committed to eslint/eslint by nzakas 8 years ago
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.