-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
feat(eslint-plugin): [no-floating-promises] add checkThenables option #9263
feat(eslint-plugin): [no-floating-promises] add checkThenables option #9263
Conversation
Thanks for the PR, @JoshuaKGoldberg! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
I don't get the motivation for this, TBH. How can something "happen to be thenable" without noticing? Does |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/e40cab53d9971a3e0b34e8fb18ece74240d9425d/types/bluebird/index.d.ts#L59: older projects that have polyfills which generally intentionally match something like Promises/A+. |
Why would one expect a polyfill to not be checked like a real promise? |
One example I've believe I've been told is that if a framework implements its own classes that happen to have a similar API to Promises, it's inconvenient to have the rule fire on them by default. cc @mcollina as I think this was from you and Fastify, but I might be mistaken / mistinterpreting. |
The issue mentions |
@Josh-Cena the Node issue does, but our #8433 -> this PR isn't around that I don't think. |
That issue doesn't mention a valid use case where you want a thenable to not be checked like a promise though. It just mentions polyfills but those are why we check thenables. |
Great points. Putting into draft per #8433 (comment). Thanks! |
#8433 was confirmed as good to go, so un-drafting. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code makes sense to me! only blocker is some test coverage
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9263 +/- ##
==========================================
+ Coverage 87.42% 88.24% +0.81%
==========================================
Files 261 416 +155
Lines 12724 14380 +1656
Branches 3975 4195 +220
==========================================
+ Hits 11124 12689 +1565
- Misses 1319 1372 +53
- Partials 281 319 +38
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Joshua Chen <[email protected]>
Confirmed with @Josh-Cena that we're good to merge with those docs suggestions. 🚀! |
63d17dd
into
typescript-eslint:main
PR Checklist
Overview
Adds a new
checkThenables
boolean
option to the rule that enables checking all shapes for matching the.then()
interface. It essentially gates the existing "does this have a.then()
with two parameters?" logic behind the option.checkThenables
istrue
by default in this PR so as to not cause a breaking change. If this PR goes in roughly as-is, I'd like to file a followup issue for v8 to turn it tofalse
by default.#8433 also mentioned adding in an option for adding additional types to what's flagged by default. I haven't heard anybody mention this as a strong need, so for now I'm holding off on adding that.
💖