Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
Closed
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I havesearched for related issues and found none that matched my issue.
- I haveread the FAQ and my problem is not listed.
Playground Link
Repro Code
constrandomAsyncFunction=async()=>{returnPromise.resolve(true)}randomAsyncFunction()
ESLint Config
module.exports={parser:"@typescript-eslint/parser",rules:{"@typescript-eslint/no-floating-promises":["error",{"allowForKnownSafeCalls":["randomAsyncFunction"]}]},};
tsconfig
{"compilerOptions": {"strictNullChecks":true }}
Expected Result
According to thedocs, there should be no lint issue with calling this function since it's listed in the allow list.
Actual Result
The lint rules still say it must be dealt with.
Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with thevoid
operator. 5:1 - 5:22
Add void operator to ignore.
Add await operator.
Additional Info
I believe this has to do withisKnownSafePromiseReturn
, it never callsvalueMatchesSomeSpecifier
. The incorrect behavior also happens when trying to reference a function from a local file with"from": "file"
.
Something like this?
functionisKnownSafePromiseReturn(node){if(node.type!==utils_1.AST_NODE_TYPES.CallExpression){returnfalse;}consttype=services.getTypeAtLocation(node.callee);if((0,util_1.valueMatchesSomeSpecifier)(node.callee,allowForKnownSafeCalls,services.program,type)){returntrue;}return(0,util_1.typeMatchesSomeSpecifier)(type,allowForKnownSafeCalls,services.program);}