Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Enhancement: [no-floating-promises] add an 'allowForKnownSafePromises' option #7008

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulelocked 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-plugin
Milestone
@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

For years, various community members have asked to add a type allowlist/blocklist or other"stop complaining about these specific areas" forno-floating-promises:

(including clearly duplicate issues to show how this is a relatively more requested option, and to surface the different use cases requested for)

Out of those,#5844'snode:test is most convincing - asnode:test is stable as of Node 20.0.0 (nodejs/node#46642 ->nodejs/node#46983), and returnsPromise<void> for tests:https://github.com/DefinitelyTyped/DefinitelyTyped/blob/8730660c37a33dc0768b3f1e36b679294acc4988/types/node/test.d.ts#L134.

I propose we adopt the format discussed in#6017 & implemented in#4436 (see v6 docs) as a newallow option forno-floating-promises. We'd want to add some very explicitly, strongly worded descriptions in the docs as to why it's not an option we recommend using lightly.

Fail

asyncfunctiontest(name:string,executor:()=>Promise<void>){// ...}test("example",()=>{});

Pass

importtestfrom'node:test';test("example",()=>{});

Additional Info

cc@armano2@bradzacher as past people who, like me, have previously disagreed with the suggestion of adding this option.

Edit: to be clear, this is roughly what users would be able to specify in their ESLint config(pending naming bikeshedding):

"@typescript-eslint/no-floating-promises":["error",{"allowForKnownSafePromises":[{"from":"package","name":"SafePromise","package":"some-fancy-package"]}]

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 rulelocked 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-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp