useWhile
Ce contenu n’est pas encore disponible dans votre langue.
Diagnostic Category: lint/style/useWhile
Since: v1.0.0
Sources:
- Same as:
sonarjs/prefer-while
Enforce the use of while
loops instead of for
loops when the initializer and update expressions are not needed.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:1 lint/style/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 │ }