Skip to content

no-fallthrough

Reports a case whose statements can reach the next case or default, and an empty one that is followed by a blank line, without a comment that says falls through before the next one (or at the end of its block). Cases that stack with no statement between them (case 1: case 2: b();) are not reported.

Execution that runs on from one case into the next is easily a forgotten break: the reader cannot tell it from an error, and the code of the second case then runs for the first value too.

To fix, end the case with break or return; if the fall-through is meant, write a // falls through comment.

Reported
...
switch (x) {
case 1:
m();
case 2:
n();
break;
case 3:
...
java:
lint:
rules:
no-fallthrough: warn # off, warn (default), error
js:
lint:
rules:
no-fallthrough: warn # off, warn (default), error
php:
lint:
rules:
no-fallthrough: warn # off, warn (default), error

Enabled by the presets: js/eslint-recommended, js/biome-recommended.

Suppress one line with sudsy-disable-next-line no-fallthrough in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
eslint no-fallthrough full