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

[return-await] breaks with functions nested in try blocks #3600

Closed
3 tasks done
MichaelBelousov opened this issue Jul 2, 2021 · 0 comments · Fixed by #3601
Closed
3 tasks done

[return-await] breaks with functions nested in try blocks #3600

MichaelBelousov opened this issue Jul 2, 2021 · 0 comments · Fixed by #3601
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@MichaelBelousov
Copy link
Contributor

MichaelBelousov commented Jul 2, 2021

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have read the FAQ and my problem is not listed.

Repro

{
  "rules": {
    "@typescript-eslint/return-await": "error",
  }
}
async function test() {
  try {
    const anyCallback = () => {};
    return Promise.resolve(5); // not considered an error
  } finally {
    return Promise.resolve(2);
  }

Expected Result

I expect this rule to consider the comment-marked line an error, because a promise is returned without
being first awaited

Actual Result

But it isn't considered an error.
No errors are generated while linting.

PR

I submitted a fix PR (#3601). It uses a stack during AST
traversal to allow nested functions to be handled correctly.

Please let me know if there is anything I missed for contributing.

@MichaelBelousov MichaelBelousov added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jul 2, 2021
@bradzacher bradzacher added bug Something isn't working and removed triage Waiting for maintainers to take a look labels Jul 2, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
2 participants