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 accessing Map, Set, WeakMap, and WeakSet entries with bracket notation.
Disallow asynchronous callbacks in synchronous iterator helpers.
Disallow conflicting CSS query and HTML form constraints.
Disallow .fill() after Array.from({length: …}).
Disallow declarations before conditional early exits when they are only used after the exit.