Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[require-await] require-await false positive #1188

Closed
mdouglass opened this issue Nov 10, 2019 · 1 comment · Fixed by #1193
Closed

[require-await] require-await false positive #1188

mdouglass opened this issue Nov 10, 2019 · 1 comment · Fixed by #1193
Labels
bug Something isn't working has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@mdouglass
Copy link

mdouglass commented Nov 10, 2019

Repro

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": { "project": "./tsconfig.json" },
  "plugins": ["@typescript-eslint"],
  "rules": {
    "@typescript-eslint/require-await": "error"
  }
}
async function testFunction(): Promise<void> {
  await Promise.all([1, 2, 3].map(async value => Promise.resolve(value)))
}

Expected Result
No warnings/errors

Actual Result
1:1 error Async function 'testFunction' has no 'await' expression @typescript-eslint/require-await

Additional Info
Changing the function passed to map to value => value causes the false positive to not trigger.

Versions

package version
@typescript-eslint/eslint-plugin 2.6.1
@typescript-eslint/parser 2.6.1
TypeScript 3.7.2
ESLint 6.6.0
node 13.1.0
npm 6.12.1
@mdouglass mdouglass added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Nov 10, 2019
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for maintainers to take a look labels Nov 11, 2019
@bradzacher
Copy link
Member

It's a bug in the rule implementation.
The extension knows the inner callback doesn't need have an error, so it doesn't call the base rule's handler.
But in doing so, it means the base rule doesn't properly update its internal state, so it ends up looking at the state for the cb whilst exiting testFunction.

@bradzacher bradzacher added the has pr there is a PR raised to close this label Nov 11, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants