Skip to content

caseFallthroughs

Reports switch case clauses that fall through unexpectedly.

✅ This rule is included in the ts logical presets.

The switch statement in JavaScript allows “fallthrough” from one case to the next, which is often unintentional and can lead to bugs. This rule reports cases that fall through to the next case without a break, return, throw, or continue statement.

Empty case clauses are allowed to fall through, as this is a common pattern for grouping multiple cases. Intentional fallthrough can be indicated with a comment containing “falls through” (case-insensitive).

switch (value) {
case 1:
doSomething();
case 2:
doSomethingElse();
break;
}
switch (value) {
case 1:
if (condition) {
break;
}
case 2:
break;
}

This rule is not configurable.

If you rely heavily on intentional fallthrough in switch statements and prefer not to add comments, you may disable this rule. Some legacy codebases may use fallthrough patterns that would require extensive refactoring.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.