Description
Coming over from typescript-eslint/typescript-eslint#7008 (comment): there is a known annoyance with the @typescript-eslint/no-floating-promises lint rule that it flags the Promises created by createAsyncThunk
as "floating" if not handled, despite those Promises being known "safe" ones that never resolve. There's no way for the lint rule to know that these Promises are safe.
That issue tracks adding an allow
option to the lint rule that would let users allowlist these Promises. But in order to help with RTK, the known safe Promises would need some kind of specific type that can be added to the rule's allowlist. +1 to @phryneas's suggestion:
So, it would be nice if we could mark those promises with some kind of branded type to them to signal to eslint that these promises can be handled, but don't need to.
We're up for adding in allow
on our end if you're up for adding that branded type here! Is that something you're up for? Even if this issue is marked as blocked on us implementing the allow
option, as long as that's the only blocker we're good to go.
I'd be happy to contribute the actual code change to RTK myself if you think it's doable for a first-timer. 😄
Edit: to be clear, this is roughly what users would be able to specify in their ESLint config once typescript-eslint/typescript-eslint#7008 is resolved (pending naming bikeshedding):
"@typescript-eslint/no-floating-promises": ["error", {
"allowForKnownSafePromises": [
{ "from": "package", "name": "SafePromise", "package": "@reduxjs/toolkit"
]
}]