Open
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/prefer-for-of/
Description
https://typescript-eslint.io/rules/prefer-for-of/ and https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-for-loop.md seem to mostly overlap, but with some slight differences as noticed in #9628
I think I would prefer typescript-eslint/prefer-for-of
's seemingly less aggressive approach, but unicorn/no-for-loop
brings a lot of value by simply having it be autofixable.
Fail
// Caught by both
const values = [1, 2, 3]
let output = 0
for (let index = 0; index < values.length; index++) {
output += values[index]
}
Pass
// unicorn/no-for-loop autofixes to this
const values = [1, 2, 3]
let output = 0
for (const value of values) {
output += value
}
Additional Info
No response