Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
feat(eslint-plugin): [no-floating-promises] add an 'allowForKnownSafePromises' option#8502
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
'allowForKnownSafePromises' optionfixes:typescript-eslint#7008
Thanks for the PR, @arka1002! 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 onhttps://opencollective.com/typescript-eslint. |
netlifybot commentedFeb 18, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify site configuration. |
nx-cloudbot commentedFeb 18, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Haven't been able to look deeply yet, but - looks like there's a mismatch in naming?
Ahh... I think I made a terrible mistake. Thanks for the reviews though. Sorry for the inconvenience. |
👋 @arka1002 adding the new If not, no worries - I'd happily take this on myself. It's a nuanced rule with a lot of context around it. ❤️ |
Yes, I've almost done the tests, give me just 3 more days. I'll open it for review. |
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.
🆒 thanks for trimming down the test cases! I think this is looking pretty great. Just one last bug from my end and I think I'll be done requesting changes (hopefully, probably).
I'll also leave this open to get at least one other review from @typescript-eslint/triage-team. I've looked at it enough that I don't trust myself to not be missing something. 😄
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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.
Requesting some changes in#8502 (comment), but otherwise I think this is getting close! 🙂
Thanks for the reviews. I'm just writing down some notes for the future people who are going to stumble upon this pr.
|
@@ -2079,19 +2079,19 @@ promise; | |||
}, | |||
{ | |||
code: ` | |||
interfaceUnsafeThenable<T> { | |||
interfaceSafeThenable<T> { |
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.
Nit...this one,should be valid, because the overall expression results in aSafeThenable
rather than ordinary promise (due to the way theSafeThenable#then
is defined)
arkapratimcMay 26, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
Yes, there's an issue which exactly describesThenable
in this rule -#8433. (It also says thenables should be valid)
It'll be solved there.
kirkwaiblingerMay 29, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
That is a separate thing entirely (and if it were the case, it would make this entire PR moot, not just this test case). This option needs to be able to support expressions that result in one of the allowed types.
Please move this case to thevalid
array.
Uh oh!
There was an error while loading.Please reload this page.
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.
Hey @arka1002! 👋
Heads up that that this PR is blocking some high-priority no-floating-promises issues. We appreciate how much work you've put into it 🙏 , but we really need to wrap it up soon.
We're going to "time-box" this PR; if it isn't merged before Monday the 3rd, we'll plan to take it over ourselves in order to have it ready for the release ~1pm EST that day.
If you have time to iterate with us this week on the requested changes, that's awesome! If not, we also understand, and we have bandwidth to handle the final rounds of change requests on our side.
Thanks again for your work on this! ❤️
@@ -2079,19 +2079,19 @@ promise; | |||
}, | |||
{ | |||
code: ` | |||
interfaceUnsafeThenable<T> { | |||
interfaceSafeThenable<T> { |
kirkwaiblingerMay 29, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
That is a separate thing entirely (and if it were the case, it would make this entire PR moot, not just this test case). This option needs to be able to support expressions that result in one of the allowed types.
Please move this case to thevalid
array.
}, | ||
], | ||
create(context, [options]) { | ||
const services = getParserServices(context); | ||
const checker = services.program.getTypeChecker(); | ||
// TODO: #5439 | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const allowForKnownSafePromises = options.allowForKnownSafePromises!; | ||
return { | ||
ExpressionStatement(node): void { |
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.
Spinning off fromhttps://github.com/typescript-eslint/typescript-eslint/pull/8502/files/7422cf504ba51cc2e1855f0352e151877720755e#r1585695716, please move the duplicative checks fordoesTypeMatchSpecifier
throughout theExpressionStatement
handler into the start ofisPromiseLike
function down below. (this will also resolve the test case inhttps://github.com/typescript-eslint/typescript-eslint/pull/8502/files/7422cf504ba51cc2e1855f0352e151877720755e#r1605894419).
(You might need to pass in context or just moveisPromiseLike
into thecreate
function so it has access to the options and such, similarly to how you already handledisPromiseArray
🙂).
Uh oh!
There was an error while loading.Please reload this page.
PR Checklist
Overview
Hi, I'm really curious, is there any way to test code which haveimport
in them ?#4436 also didn't have them.Nvm, found it.
Let's discuss.