Skip to content

Conversation

@Hweinstock
Copy link
Contributor

Problem

Many bugs, and confusing behavior stem from developers using an async function within a forEach. This is almost always not desired. Additionally, forEach can lead to bloated implementations when other methods like some, find, reduce, or flatMap are more applicable.

According to https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-for-each.md It is also faster with for ... of.

Solution


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@Hweinstock
Copy link
Contributor Author

/runIntegrationTests

@Hweinstock Hweinstock marked this pull request as ready for review December 20, 2024 19:26
@Hweinstock Hweinstock requested review from a team as code owners December 20, 2024 19:26
Copy link
Contributor

@justinmk3 justinmk3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@justinmk3 justinmk3 merged commit 5ef59ca into aws:master Dec 23, 2024
22 of 23 checks passed
karanA-aws pushed a commit to karanA-aws/aws-toolkit-vscode that referenced this pull request Jan 17, 2025
## Problem
Many bugs, and confusing behavior stem from developers using an async
function within a forEach. This is almost always not desired.
Additionally, `forEach` can lead to bloated implementations when other
methods like `some`, `find`, `reduce`, or `flatMap` are more applicable.

According to
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-for-each.md
It is also faster with `for ... of`.

## Solution
- Add lint rule: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-for-each.md
- Migrate existing cases with `eslint CLI --fix` (75% of cases).
- For remaining cases, mark as exception.
s7ab059789 pushed a commit to s7ab059789/aws-toolkit-vscode that referenced this pull request Feb 19, 2025
Many bugs, and confusing behavior stem from developers using an async
function within a forEach. This is almost always not desired.
Additionally, `forEach` can lead to bloated implementations when other
methods like `some`, `find`, `reduce`, or `flatMap` are more applicable.

According to
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-for-each.md
It is also faster with `for ... of`.

- Add lint rule: https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/no-array-for-each.md
- Migrate existing cases with `eslint CLI --fix` (75% of cases).
- For remaining cases, mark as exception.
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.

2 participants