Skip to content

Configs: include return-await in strict-type-checked preset #8667

Closed
@aseemk

Description

@aseemk

Before You File a Proposal Please Confirm You Have Done The Following...

Description

I recently debugged a difficult bug in my code where I was try-catching an async call that I was returning right away.

async function asyncFoo() {
  try {
    return asyncBar() // no await
  } catch (err) {
    // so my error handling code here wasn't getting hit
  }
}

I was surprised when I finally figured this out, because I love and rely on e.g. no-floating-promises to catch missing awaits, but it hadn't caught this one.

I found that return-await exists to help here, but was then also surprised that it wasn't included in the recommended-type-checked preset that we use.

I thought the whole purpose of that preset was to at least help ensure correctness (separate from style) — and this was definitely a correctness issue.

I've now enabled return-await in my codebase, and am feeling great. But can I suggest adding this to recommended-type-checked to prevent other developers from hitting easily preventable bugs like this?

Thank you for your consideration and for a great tool!

Impacted Configurations

recommended-type-checked

Additional Info

No response

Metadata

Metadata

Labels

locked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginpreset config changeProposal for an addition, removal, or general change to a preset configteam assignedA member of the typescript-eslint team should work on this.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions