unicorn/no-double-comparison
eslint-plugin-unicorn
Suggestion
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-double-comparison": "error",
},
},
];Disallow two comparisons of the same operands that can be combined into one.
x === y || x < y;x === y || x > y;x <= y && x >= y;x <= y;x >= y;x === y;Examples from the ESLint documentation.
unicorn/no-double-comparison
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-double-comparison": "error",
},
},
];Oxlint does not have this rule.
nursery/noDoubleComparison
nursery · since 2.6.0
{
"linter": {
"rules": {
"nursery": {
"noDoubleComparison": "error"
}
}
}
}Disallow boolean-returning sort comparators.
Disallow sorting arrays to get the minimum or maximum value.
Disallow negated array predicate calls.
Disallow bitwise operators where a logical operator was likely intended.
Prefer comparing values directly over subtracting and comparing to 0.