Rule: prefer-while

Prefer while loops instead of for loops without an initializer and incrementor.

Rationale

Simplifies the readability of the loop statement, while maintaining the same functionality.

Notes:
Has Fixer

Config

Not configurable.

Config examples
"prefer-while": true
Schema
null

Code examples:

Prefer `while` loops instead of `for` loops without an initializer and incrementor.
"rules": { "prefer-while": true }
Passes
for(let i = 1; i < 10; i++) {
    console.log(i);
}

for (let i = 0; i < 10; i+=1) {
    console.log(i);
}

for (let i = 0; i < 10;) {
    i += 1;
}
Fails
for(;;) {
    console.log('Hello World');
}

for(;true===true;) {
    console.log('Hello World');
}