Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I havesearched for related issues and found none that match my proposal.
- I have searched thecurrent rule list and found no rules that match my proposal.
- I haveread the FAQ and my problem is not listed.
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
#7008'sallowForKnownSafePromises
is atype-oriented approach to allowlisting safetypes to be floating. For frameworks that have those Promises show up in many places (e.g.reduxjs/redux-toolkit#4101), marking thetype as safe is a reasonable solution.
But (paraphrasing private remarks from@Josh-Cena): that requires framework authors to set things up in a very specific way that feels like jumping through hoops specific to another, tangential technology (us). For example,nodejs/node#51292 tracks hownode:test
'sit
& similar return aPromise
. Even if the Node types get some fancy brandedSafePromise
type added (one inconvenience), users really just want a way to mark thatit()
calls are safe. Asking users to know the Node.js-specifictypes is more learning curve for them (another inconvenience).
In other words, we think users would really want to mark specificfunctions as safe to call. A kind ofallowForKnownSafePromiseReturns
option.
"@typescript-eslint/no-floating-promises":["error",{"allowForKnownSafePromiseReturns":[{"from":"package","name":"it","package":"node:test"}]}]
Fail
import{it}from"node:test";it("...",()=>{/* ... */});
Pass
/* "allowForKnownSafePromiseReturns": [{ "from": "package", "name": "it", "package": "node:test" }] */import{it}from"node:test";it("...",()=>{/* ... */});
Additional Info
No response