Why is this an issue?

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.

Noncompliant code example

if (val = value() && check()) { // Noncompliant
  // ...
}

Compliant solution

val = value();
if (val && check()) {
  // ...
}

Exceptions

The rule does not raise issues for the following patterns:

Resources