Skip to content

Enhancement: [no-floating-promises] Add suggestion fixer to add an 'await' #5924

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

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

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/no-floating-promises

Description

Sometimes -but not always- with @typescript-eslint/no-floating-promises, the right fix is to add an await before a Promise. It'd be convenient if the rule could provide a suggestion to add "await " to the text before the violating promise.

Fail

fetch("my/fancy/api");

Pass

await fetch("my/fancy/api");

Additional Info

@typescript-eslint/await-thenable has a suggestion to Remove unnecessary 'await'. THat'd be a good reference for implementing this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulegood first issueGood for newcomerspackage: 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