no-cond-assign
NOTE: this rule is part of the
recommended rule set.Enable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["recommended"]
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["no-cond-assign"],
"exclude": ["no-cond-assign"]
}
}
}Disallows the use of the assignment operator, =, in conditional statements.
Use of the assignment operator within a conditional statement is often the
result of mistyping the equality operator, ==. If an assignment within a
conditional statement is required then this rule allows it by wrapping the
assignment in parentheses.
Invalid:
let x;
if (x = 0) {
let b = 1;
}
function setHeight(someNode) {
do {
someNode.height = "100px";
} while (someNode = someNode.parentNode);
}
Valid:
let x;
if (x === 0) {
let b = 1;
}
function setHeight(someNode) {
do {
someNode.height = "100px";
} while ((someNode = someNode.parentNode));
}