A case of a switch runs on into the next without a comment saying so
What it finds
A case with statements that runs on into the next one, because it does not end with break, return, throw or continue, is often missing its break.
A comment before the next case that says so, such as // falls through or // fallthrough, marks it as meant. Empty cases that share the statements of the next, as in case 1: case 2:, are not reported. Calls are assumed to return unless the function is named for not returning, such as throwError, assertNever or process.exit; a case that ends with a call to another function that always throws is reported too, which is why this rule is recommended rather than on by default.
From the rule's source, fallthrough.rs.
function run(kind: number, log: (s: string) => void) { switch (kind) { case 1: log("one"); case 2:tx0 reports: the case before case 2: runs on into it log("two"); break; case 3: case 4: log("three or four"); // falls through case 5: if (kind) { return; } log("five"); default:tx0 reports: the case before default: runs on into it log("other"); } switch (kind) { case 1: { log("one"); // fallthrough } case 2: throwError("two"); case 3: if (kind) { break; } else { return; } case 4: log("four"); }} declare function throwError(message: string): never; Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:fallthrough" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:fallthrough] reason="..."tx0 explain tx0/ts:fallthrough shows the same in the terminal. Found a false positive? Report it.