Skip to content

Allow for...of loops#7

Open
stevehanson wants to merge 2 commits intomainfrom
for-of-remove
Open

Allow for...of loops#7
stevehanson wants to merge 2 commits intomainfrom
for-of-remove

Conversation

@stevehanson
Copy link
Contributor

@stevehanson stevehanson commented Nov 10, 2023

This rule originally comes from the Airbnb ruleset. These were restricted by Airbnb because browser support was lacking in 2018. Browser support for for...of is now at 97%. Additionally, not all of our users are writing for the browser. Finally, for...of loops are the simplest way to loop through arrays asynchronously in sequence:

// this works, but .forEach and for...in do not
for await (const item of items) {
  await doSomething(item);
}

Similarly, this PR allows the use of continue statements. We often encourage early returns in methods, and to me continue is a similar concept, but in the context of a loop. I don't see a need to be opinionated about its usage.

https://caniuse.com/?search=for...of

Stephen Hanson added 2 commits November 9, 2023 22:51
These were restricted because browser support was lacking in 2018. Browser support is now at 97%. Additionally, not all of our users are writing for the browser. Finally, for...of loops are the simplest way to loop through arrays asynchronously in sequence.

https://caniuse.com/?search=for...of
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant