An equality comparison puts the literal before the value it tests
What it finds
if ("admin" === role) puts the constant first, which reads backwards: one asks whether the role is admin, not whether admin is the role. The order guarded against = typos in languages without a linter; in JavaScript if (role = "admin") is reported anyway.
Reported are equality comparisons whose left operand is a literal and whose right one is not. The fix, which is safe since equality is symmetric, swaps the operands.
From the rule's source, reversed_equality_operands.rs.
export function isAdmin(role: string) { return "admin" === role || role === "root";tx0 reports: the literal comes first} Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:reversed-equality-operands" = "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:reversed-equality-operands] reason="..."tx0 explain tx0/ts:reversed-equality-operands shows the same in the terminal. Found a false positive? Report it.