no-unmodified-loop-condition
Loop conditions that are never modified in the loop body usually indicate a mistake.Rule Type: Problem
Fixable: No
Fixable: No
Why This Rule Exists
If a variable appears in a loop condition but is never modified inside the loop, the loop will either never execute or become infinite. This is almost always a bug.Rule Details
This rule finds references in loop conditions and checks whether the variables are modified in the loop body. What it checks:- Variables in loop conditions
- Binary expressions in conditions
- Ternary expressions in conditions
- Dynamic expressions (function calls, yield, etc.)
- Object properties (they might have getters)
Examples
Incorrect Code
Correct Code
Common Patterns
Linked List Traversal
Array Iteration
Breaking Out of Loop
Why Properties and Functions Are Ignored
Properties Might Be Getters
Functions Can Examine State
Fixing Infinite Loops
Update the Condition Variable
Use a Different Loop Type
Add Proper Exit Condition
When Not to Use It
You might want to disable this rule if:- Your code intentionally uses infinite loops with explicit breaks
- You have complex loop conditions that the rule can’t analyze correctly