Skip to main content

useWhile

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();
}
warning[useWhile]: Use while loops instead of for loops.
   useWhile.js:1:1
  
1  for (; x.running;) {
   ------------------

Suggested fix: Use a while loop
    | @@ -1,3 +1,3 @@
0   | - for (; x.running;) {
  0 | + while (x.running) {
1 1 |       x.step();
2 2 |   }