A case label combines values with ||, && or ,, so it matches only one of them
What it finds
case "a" || "b":: a case compares the switch value with the result of its expression, and "a" || "b" is just "a", so the "b" case is never matched. Two case labels in a row, case "a": case "b":, match both.
Reported are case expressions that are ||, && or , of constants. Expressions with names, this, member accesses or calls, as case isAdmin && role: in a switch (true), are left alone.
From the rule's source, case_with_logical_operator.rs.
export function kind(value: string, isAdmin: boolean, role: string) { switch (value) { case "a" || "b":tx0 reports: this case matches only one value return 1; case "c": return 2; } switch (true) { case isAdmin && role === "x": return 3; } return 0;} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/ts:case-with-logical-operator" = "off"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:case-with-logical-operator] reason="..."tx0 explain tx0/ts:case-with-logical-operator shows the same in the terminal. Found a false positive? Report it.