A default clause is followed by a case clause
What it finds
A default clause in the middle of a switch still only runs when no case matches, but readers expect it at the end and may miss the cases after it, or take a fall through into the next case for a mistake.
An empty default clause right before a case, as in default: case Mode.Medium:, shares the body of that case on purpose and is left alone.
From the rule's source, default_before_case.rs.
function name(n: number) { switch (n) { default:tx0 reports: default comes before other cases return "other"; case 1: return "one"; }}function last(n: number) { switch (n) { case 1: return "one"; default: return "other"; }} 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:default-before-case" = "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:default-before-case] reason="..."tx0 explain tx0/ts:default-before-case shows the same in the terminal. Found a false positive? Report it.