oxc/const-comparisons
oxc plugin · correctness
{
"rules": {
"oxc/const-comparisons": "error"
}
}Checks for redundant or logically impossible comparisons. This includes: - Ineffective double comparisons against constants. - Impossible comparisons involving constants. - Redundant comparisons where both operands are the same (e.g., a < a).
status_code <= 400 && status_code > 500;
status_code < 200 && status_code <= 299;
status_code > 500 && status_code >= 500;
a < a; // Always false
a >= a; // Always truestatus_code >= 400 && status_code < 500;
500 <= status_code && 600 > status_code;
500 <= status_code && status_code <= 600;
a < b;
a <= b;Examples from the Oxlint documentation.
ESLint does not have this rule.
oxc/const-comparisons
oxc plugin · correctness
{
"rules": {
"oxc/const-comparisons": "error"
}
}nursery/noConstantComparisons
nursery · since 2.6.6
{
"linter": {
"rules": {
"nursery": {
"noConstantComparisons": "error"
}
}
}
}This rule warns when the replaceAll method is called with a regular expression that does not have the global flag (g).
Checks for comparisons between object and array literals.
Checks whether the throw keyword is missing in front of a new expression.
Checks whether the clamp function Math.min(Math.max(x, y), z) always evaluates to a constant result because the arguments are in the wrong order.
Checks whether the radix or precision arguments of number-related functions exceed the limit.