testing-library / eslint-plugin-testing-library

ESLint plugin to follow best practices and anticipate common mistakes when writing tests with Testing Library
https://npm.im/eslint-plugin-testing-library
MIT License
982 stars 137 forks source link

await-async-event adds async and await in forEach loop #843

Open fa93hws opened 10 months ago

fa93hws commented 10 months ago

Have you read the Troubleshooting section?

Yes

Plugin version

v6.1.2

ESLint version

v8.45.0

Node.js version

20.8.1

package manager and version

yarn 1.22.19

Operating system

macos 13.6.1

Bug description

async and await doesn't work for forEach loop. I think we should give up autofixing this issue.

Steps to reproduce

foo.forEach(() => {
  userEvent.click();
});

After autofix, it becomes

foo.forEach(async () => {
  await userEvent.click();
});

Error output/screenshots

No response

ESLint configuration

{ ... "testing-library/await-async-event": "error", }

Rule(s) affected

await-async-event

Anything else?

No response

Do you want to submit a pull request to fix this bug?

Yes