A conditional expression picks the smaller or larger of two values by hand
What it finds
a < b ? a : b picks the smaller of two values, which Math.min(a, b) names. Written out, the reader has to check that the operands are repeated in the right order to tell a minimum from a maximum.
Reported are conditional expressions whose condition compares two operands with <, <=, > or >= and whose outcomes are those same operands, without effects. There is no fix, since Math.min and Math.max differ from the comparison for NaN and mixed types.
From the rule's source, min_max_ternary.rs.
export function bounds(a: number, b: number) { const low = a < b ? a : b;tx0 reports: picks the smaller of two values const high = a < b ? b : a;tx0 reports: picks the larger of two values const other = a < b ? 1 : 2; return [low, high, other];} 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:min-max-ternary" = "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:min-max-ternary] reason="..."tx0 explain tx0/ts:min-max-ternary shows the same in the terminal. Found a false positive? Report it.