src/content/docs/linter/rules/no-fallthrough-switch-clause.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.0.0` - Diagnostic Category: [`lint/suspicious/noFallthroughSwitchClause`](/reference/diagnostics#diagnostic-category) - This rule is **recommended**, meaning it is enabled by default. - This rule doesn't have a fix. - The default severity of this rule is [**error**](/reference/diagnostics#error). - Sources: - Same as [`no-fallthrough`](https://eslint.org/docs/latest/rules/no-fallthrough){
"linter": {
"rules": {
"suspicious": {
"noFallthroughSwitchClause": "error"
}
}
}
}
Disallow fallthrough of switch clauses.
Switch clauses in switch statements fall through by default.
This can lead to unexpected behavior when forgotten.
The rule doesn't take
process.exit()in consideration.
switch (bar) {
case 0:
a();
case 1:
b();
}
switch (foo) {
case 1:
case 2:
doSomething();
break;
case 3: {
if (cond) {
break;
} else {
break;
}
}
case 4:
doSomething();
}