oxc/bad-min-max-func Correctness
What it does
Checks whether the clamp function Math.min(Math.max(x, y), z)
always evaluate to a constant result because the arguments are in the wrong order.
Why is this bad?
The Math.min(Math.max(x, y), z)
function is used to clamp a value between two other values. If the arguments are in the wrong order, the function will always evaluate to a constant result.
Example
Examples of incorrect code for this rule:
javascript
Math.min(Math.max(100, x), 0);
Math.max(1000, Math.min(0, z));
Examples of correct code for this rule:
javascript
Math.max(0, Math.min(100, x));
Math.min(0, Math.max(1000, z));