Assignments within sub-expressions are hard to spot and therefore make the code less readable. Ideally, sub-expressions should not have side-effects.
Moreover, using chained assignment in declarations is also dangerous because one may accidentally create global variables, e.g. in let x = y
= 1;, if y is not declared, it will be hoisted as global.
if (val = value() && check()) { // Noncompliant
// ...
}
val = value();
if (val && check()) {
// ...
}
The rule does not raise issues for the following patterns:
a = b = c = 0; (a = 0) != b a = 0, b = 1, c = 2 () => a = 0 a || (a = 0) while (a = 0);