-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
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 have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
Repro Code
const randomAsyncFunction = async () => {
return Promise.resolve(true)
}
randomAsyncFunction()
ESLint Config
module.exports = {
parser: "@typescript-eslint/parser",
rules: {
"@typescript-eslint/no-floating-promises": [
"error",
{
"allowForKnownSafeCalls": [
"randomAsyncFunction"
]
}
]
},
};
tsconfig
Expected Result
According to the docs, 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 the void
operator. 5:1 - 5:22
Add void operator to ignore.
Add await operator.
Additional Info
I believe this has to do with isKnownSafePromiseReturn
, it never calls valueMatchesSomeSpecifier
. The incorrect behavior also happens when trying to reference a function from a local file with "from": "file"
.
Something like this?
function isKnownSafePromiseReturn(node) {
if (node.type !== utils_1.AST_NODE_TYPES.CallExpression) {
return false;
}
const type = services.getTypeAtLocation(node.callee);
if ((0, util_1.valueMatchesSomeSpecifier)(node.callee, allowForKnownSafeCalls, services.program, type)) {
return true;
}
return (0, util_1.typeMatchesSomeSpecifier)(type, allowForKnownSafeCalls, services.program);
}
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebugSomething isn't workingSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin