-
Notifications
You must be signed in to change notification settings - Fork 151
Labels
Description
Have you read the Troubleshooting section?
Yes
Plugin version
v7.6.0
ESLint version
8.57.0
Node.js version
20.11
Bug description
In rolling this plugin out across a huge number of repos I noticed it flag a pattern that should be valid. When assigning the return value of a wrapped async util to a variable, it is not considered "handled" by the plugin.
For example, for a given util waitForPlusSomeOtherStuff
that wraps waitFor
, these would be considered valid:
await waitForPlusSomeOtherStuff()
expect(await waitForPlusSomeOtherStuff()).toBe('foo');
whereas this is currently considered invalid:
const result = await waitForPlusSomeOtherStuff();
expect(result).toBe('foo'); // Promise returned from waitForPlusSomeOtherStuff wrapper over async util must be handled testing-library/await-async-utils
Steps to reproduce
- Apply this patch:
diff --git a/tests/lib/rules/await-async-utils.test.ts b/tests/lib/rules/await-async-utils.test.ts index 8f23bbf..dab26db 100644 --- a/tests/lib/rules/await-async-utils.test.ts +++ b/tests/lib/rules/await-async-utils.test.ts @@ -248,7 +248,8 @@ ruleTester.run(RULE_NAME, rule, { } test('handled promise from function wrapping ${asyncUtil} util is valid', async () => { - await waitForSomethingAsync() + const result = await waitForSomethingAsync() + expect(result).toBe('foo') }); `, })),
- Run tests
Error output/screenshots
No response
ESLint configuration
NA
Rule(s) affected
await-async-utils
(probably await-async-events
and await-async-queries
as well)
Anything else?
No response
Do you want to submit a pull request to fix this bug?
Yes