unicorn/no-chained-comparison
eslint-plugin-unicorn
Suggestion
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-chained-comparison": "error",
},
},
];if (a < b < c) {}if (a === b === c) {}if (a < b && b < c) {}if (a === b && b === c) {}// Intentionally comparing two boolean results.
if ((a > 0) === (b > 0)) {}Examples from the ESLint documentation.
unicorn/no-chained-comparison
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-chained-comparison": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Disallow conflicting CSS query and HTML form constraints.
Disallow asynchronous callbacks in synchronous iterator helpers.
Disallow declarations before conditional early exits when they are only used after the exit.
Disallow .fill() after Array.from({length: …}).
Disallow adjacent duplicate operands in logical expressions.