-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Bug: [no-floating-promises] False negative calling .then with second argument undefined #6850
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
Nice spot - agreed. If the second argument to I think we'd want to special-case this error though. How about this?
Seeking bike-shedding on that error text. I'm not super satisfied with how that one repeats itself... |
I have no strong opinion on this. Just a thought, though, it might be worth explaining why it would become floating in that case. What about including in the message something like the phrase I would imagine though anyone reading it will make the connection with or without the hint, though. |
would you mind if I try my hand at a PR for this (pending consensus on error message)? |
Not just nullish handlers; but anything non-callable. |
Go ahead @kirk-waiblinger-trimble! 🚀 |
Good point... I hadn't thought to check since the TS declarations only allow Maybe "If the rejection handler is not a function, it will be ignored." or "If the rejection handler is not a function, it will be treated the same as if it were omitted." would be more general? |
I don't think we need to - TS giving an error is enough for users. No need for us to add an addition scream-in-your-face on top of it. It is nifty to know that JS natively ignores non-callable things though. |
I think "If the rejection handler is not a function, it will be ignored." is much better than "if it is nullish". The latter is technically not wrong (because it's a sufficient condition), but it doesn't give the full information. The former is also not too complex. |
…en with second argument undefined (#6881) * fix(eslint-plugin): [no-floating-promises] False negative calling .then with second argument undefined (Issue #6850) * use getTypeAtLocation correctly * clean up duplicate * correct mistake in IIFE abbreviation * purge the word invocated from the codebase
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play#ts=5.0.2&sourceType=module&code=PTAEGEHsCdoUwMYBcA2BPUAzFBDA5nnACYCwAUAArSQC2AlgM5wB08AVokgBQCUzSACzgA7Lr1ABeAHygA3qAC+PciFAAVAY1BbBcUAxw09gusLzbhoAFIBlZqACSSfUjooU2hqByWArsIEfIhRiUHZOOkhhZnIqWkYWcORefiFRcWk5RQAaUH8iOExTYh4gA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Jge1oDN4OBDfMwDmtYtA4BbSshTooiaBOiRwYAL4h1QA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkJemy0eAcgK6qoDCAFutAGsylBm3TgwAXxCSgA
Repro Code
ESLint Config
tsconfig
No response
Expected Result
I expect that .then(f, undefined) should be flagged as an error the same as .then(f)
Actual Result
No error
Additional Info
No response
The text was updated successfully, but these errors were encountered: