Skip to content

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

@MichaelBelousov

Description

@MichaelBelousov
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions