no-fallthrough
What it does
Section titled “What it does”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.
Why it matters
Section titled “Why it matters”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.
Example
Section titled “Example”... switch (x) { case 1: m(); case 2: n(); break; case 3:...Configuration
Section titled “Configuration”java: lint: rules: no-fallthrough: warn # off, warn (default), errorjs: lint: rules: no-fallthrough: warn # off, warn (default), errorphp: lint: rules: no-fallthrough: warn # off, warn (default), errorEnabled 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.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint | no-fallthrough |
full |