no-fallthrough
eslint
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"no-fallthrough": "error",
},
},
];switch(foo) {
case 1:
doSomething();
case 2:
doSomething();
}switch(foo) {
case 1:
doSomething();
break;
case 2:
doSomething();
}
function bar(foo) {
switch(foo) {
case 1:
doSomething();
return;
case 2:
doSomething();
}
}
switch(foo) {
case 1:
doSomething();
throw new Error("Boo!");
case 2:
doSomething();
}
switch(foo) {
case 1:
case 2:
// …Examples from the ESLint documentation.
no-fallthrough
eslint
export default [
{
rules: {
"no-fallthrough": "error",
},
},
];no-fallthrough
eslint plugin · pedantic
{
"rules": {
"no-fallthrough": "error"
}
}suspicious/noFallthroughSwitchClause
suspicious · since 1.0.0
{
"linter": {
"rules": {
"suspicious": {
"noFallthroughSwitchClause": "error"
}
}
}
}Switch cases should end with an unconditional "break" statement
Disallow let or var variables that are read but never assigned
Disallow multiple spaces in regular expressions
Disallow empty static blocks
Disallow expressions where the operation doesn't affect the value