An expression is tested against true or false with an equality operator
What it finds
if (done === true), visible == false: comparing with a boolean literal says the same as the value itself or its negation, in more words. With ==, it also converts: "1" == true holds.
Comparisons with === or !== are a way in TypeScript to tell true from other values of a union, as undefined, which is why the rule is strict.
From the rule's source, compare_to_true_false.rs.
function check(done: boolean, visible: boolean) { if (done === true) {tx0 reports: comparing with true restates the value return 1; } return visible == false || done;tx0 reports: comparing with false restates the value} 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:compare-to-true-false" = "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:compare-to-true-false] reason="..."tx0 explain tx0/ts:compare-to-true-false shows the same in the terminal. Found a false positive? Report it.