-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: [no-floating-promises] allowForKnownSafeCalls only matches types, not values #10686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This is because if you set maybe that's just a docs thing or maybe the rule should operate on symbol names instead |
Aha, thank you!
|
The issue isn't just that though. The promise doesn't come from the Put another way - your config should prevent flagging on useNavigation(); But not on const cb = useNavigation();
cb(); // error here |
Though still this option operates on types right now and That is possibly still an issue if we want the rule option to also allow allowing of symbol names rather than only types |
FYI @JoshuaKGoldberg #10660 also/already tracks matching values with |
Ideally the libraries return some nominally typed promise that a user can match the rule on - which was what we tried to push people to. Alternately |
Yeah I don't know that there's a way for us to do anything here. As mentioned in #10686 (comment), targeting the "@typescript-eslint/no-floating-promises": ["error", {
"allowForKnownSafeCalls": [
{ "from": "package", "name": "NavigateFunction", "package": "react-router" }
]
}] Closing out as non-actionable. Thanks all! |
Before You File a Bug Report Please Confirm You Have Done The Following...
Issue Description
Given this setting for
@typescript-eslint/no-floating-promises
:...I would have thought this code would not produce a lint report:
...but it does on my machine:
Sparked by a
#help
question in Discord: https://discord.com/channels/1026804805894672454/1326739019387899974Reproduction Repository Link
https://github.com/JoshuaKGoldberg/repros/tree/repro-tseslint-no-floating-promises-react-router-allow-useNavigate
Repro Steps
npm install
npm run lint
Versions
@typescript-eslint/eslint-plugin
8.20.0
TypeScript
5.7.3
ESLint
9.18.0
The text was updated successfully, but these errors were encountered: