-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read 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
Description
#7008's allowForKnownSafePromises is a type-oriented approach to allowlisting safe types to be floating. For frameworks that have those Promises show up in many places (e.g. reduxjs/redux-toolkit#4101), marking the type 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 how node:test's it & similar return a Promise. Even if the Node types get some fancy branded SafePromise type added (one inconvenience), users really just want a way to mark that it() calls are safe. Asking users to know the Node.js-specific types is more learning curve for them (another inconvenience).
In other words, we think users would really want to mark specific functions as safe to call. A kind of allowForKnownSafePromiseReturns 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