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 new operators with global non-constructor functions
Disallow multiple spaces in regular expressions
Disallow duplicate arguments in function definitions
Disallow let or var variables that are read but never assigned