useWhile (since v0.7.0)
This rule is recommended by Rome.
Enforce the use of while
loops instead of for
loops when the initializer and update expressions are not needed
Examples
Invalid
for (; x.running;) {
x.step();
}
style/useWhile.js:1:1 lint/style/useWhile FIXABLE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Use while loops instead of for loops.
> 1 │ for (; x.running;) {
│ ^^^^^^^^^^^^^^^^^^
2 │ x.step();
3 │ }
ℹ Suggested fix: Use a while loop
1 │ - for·(;·x.running;)·{
1 │ + while·(x.running)·{
2 2 │ x.step();
3 3 │ }