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 x = 1; x < 10; x++) {
    console.log(x);
}

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

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

for(;true===true;) {
    console.log(x);
}