2 title: no-unmodified-loop-condition
8 Variables in a loop condition often are modified in the loop.
9 If not, it's possibly a mistake.
26 This rule finds references which are inside of loop conditions, then checks the
27 variables of those references are modified in the loop.
29 If a reference is inside of a binary expression or a ternary expression, this rule checks the result of
30 the expression instead.
31 If a reference is inside of a dynamic expression (e.g. `CallExpression`,
32 `YieldExpression`, ...), this rule ignores it.
34 Examples of **incorrect** code for this rule:
39 /*eslint no-unmodified-loop-condition: "error"*/
48 for (var j = 0; j < items.length; ++i) {
49 doSomething(items[j]);
52 while (node !== root) {
59 Examples of **correct** code for this rule:
64 /*eslint no-unmodified-loop-condition: "error"*/
71 for (var j = 0; j < items.length; ++j) {
72 doSomething(items[j]);
75 // OK, the result of this binary expression is changed in this loop.
76 while (node !== root) {
81 // OK, the result of this ternary expression is changed in this loop.
82 while (node ? A : B) {
87 // A property might be a getter which has side effect...
88 // Or "doSomething" can modify "obj.foo".
93 // A function call can return various values.
101 ## When Not To Use It
103 If you don't want to notified about references inside of loop conditions, then it's safe to disable this rule.