Rules
Every rule from ESLint, Oxlint and Biome. Pick a rule to see its example. Reach is the weekly npm downloads of the presets that enable a rule; trend is its change over the last quarter.
Every rule from ESLint, Oxlint and Biome. Pick a rule to see its example. Reach is the weekly npm downloads of the presets that enable a rule; trend is its change over the last quarter.
// Unintentional assignment
let x;
if (x = 0) {
const b = 1;
}
// Practical example that is similar to an error
const setHeight = function (someNode) {
do {
someNode.height = "100px";
} while (someNode = someNode.parentNode);
}// Assignment replaced by comparison
let x;
if (x === 0) {
const b = 1;
}
// Practical example that wraps the assignment in parentheses
const setHeight = function (someNode) {
do {
someNode.height = "100px";
} while ((someNode = someNode.parentNode));
}
// Practical example that wraps the assignment and tests for 'null'
const set_height = function (someNode) {
do {
someNode.height = "100px";
} while ((someNode = someNode.parentNode) !== null);
}Popular · 1 of 41
Disallow assignment operators in conditional expressions
// Unintentional assignment
let x;
if (x = 0) {
const b = 1;
}
// Practical example that is similar to an error
const setHeight = function (someNode) {
do {
someNode.height = "100px";
} while (someNode = someNode.parentNode);
}// Assignment replaced by comparison
let x;
if (x === 0) {
const b = 1;
}
// Practical example that wraps the assignment in parentheses
const setHeight = function (someNode) {
do {
someNode.height = "100px";
} while ((someNode = someNode.parentNode));
}
// Practical example that wraps the assignment and tests for 'null'
const set_height = function (someNode) {
do {
someNode.height = "100px";
} while ((someNode = someNode.parentNode) !== null);
}