prefer-for-of
Configuration
rslint.config.ts
Rule Details
Enforce the use of for-of loop over the standard for loop where possible.
Many developers default to writing for (let i = 0; i < ...; i++) loops to iterate over arrays. However, in many cases the loop iterator variable is only used to access the respective element of the array. In such cases, a for-of loop is simpler and more readable.
This rule will report when a for loop can be replaced with a for-of loop.
Examples of incorrect code for this rule:
Examples of correct code for this rule: