An assertion checks the boolean of a comparison where a matcher would report both values
What it finds
expect(a === b).toBe(true) fails with "expected true, received false", which hides the values compared. expect(a).toBe(b) reports both. Likewise toHaveLength, toBeNull and toBeUndefined give better messages than comparing length, null or undefined by hand.
Reported are expect of a comparison followed by toBe(true), toBe(false), toBeTruthy() or toBeFalsy(), and expect(...) followed by toBe(null) or toBe(undefined).
From the rule's source, comparison_wrapped_in_matcher.rs.
it("compares", () => { expect(total() === 3).toBe(true);tx0 reports: this asserts the boolean of a comparison expect(total()).toBe(3);});declare function total(): number; 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:comparison-wrapped-in-matcher" = "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:comparison-wrapped-in-matcher] reason="..."tx0 explain tx0/ts:comparison-wrapped-in-matcher shows the same in the terminal. Found a false positive? Report it.