Saltearse al contenido

useWhile

Esta página aún no está disponible en tu idioma.

Enforce the use of while loops instead of for loops when the initializer and update expressions are not needed.

for (; x.running;) {
x.step();
}
code-block.js:1:1 lint/complexity/useWhile  FIXABLE  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Use a while loop instead of a for loop.

> 1 │ for (; x.running;) {
^^^^^^^^^^^^^^^^^^
2 │ x.step();
3 │ }

Prefer a while loop over a for loop without initialization and update.

Safe fix: Use a while loop.

1 - for·(;·x.running;)·{
1+ while·(x.running)·{
2 2 x.step();
3 3 }

for (let x = 0; x < 10; i++) {}
let x = 0
for (; x < 10; i++) {}
for (let x = 0; x < 10;) {
i++
}
biome.json
{
"linter": {
"rules": {
"complexity": {
"useWhile": "error"
}
}
}
}