useForOf
Este conteúdo não está disponível em sua língua ainda.
Diagnostic Category: lint/style/useForOf
Since: v1.5.0
Sources:
- Same as:
@typescript-eslint/prefer-for-of
- Same as:
unicorn/no-for-loop
This rule recommends a for-of
loop when in a for
loop, the index used to extract an item from the iterated array.
Examples
Section titled ExamplesInvalid
Section titled Invalidcode-block.js:1:1 lint/style/useForOf ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ Use for-of loop instead of a for loop.
> 1 │ for (let i = 0; i < array.length; i++) {
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 2 │ console.log(array[i]);
> 3 │ }
│ ^
4 │