Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Closed

Conversation

arkapratimc
Copy link
Contributor

@arkapratimcarkapratimc commentedFeb 18, 2024
edited by JoshuaKGoldberg
Loading

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.

'allowForKnownSafePromises' optionfixes:typescript-eslint#7008
@typescript-eslint
Copy link
Contributor

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.

@netlifyNetlify
Copy link

netlifybot commentedFeb 18, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitcbbda8a
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/665304aa7961aa000851b468
😎 Deploy Previewhttps://deploy-preview-8502--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 7 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to yourNetlify site configuration.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedFeb 18, 2024
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commitcbbda8a. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 31 targets

Sent with 💌 fromNxCloud.

@arkapratimcarkapratimc marked this pull request as draftFebruary 18, 2024 16:49
@arkapratimcarkapratimc marked this pull request as ready for reviewFebruary 18, 2024 17:23
@arkapratimcarkapratimc changed the titlefeat: [no-floating-promises] add an 'allowForKnownSafePromises' optionfeat(eslint-plugin): [no-floating-promises] add an 'allowForKnownSafePromises' optionFeb 19, 2024
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a 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?

@arkapratimc
Copy link
ContributorAuthor

Ahh... I think I made a terrible mistake.

Thanks for the reviews though.
I'm marking this as draft. I need some more time to thoroughly read the issues once again.

Sorry for the inconvenience.

JoshuaKGoldberg reacted with heart emoji

@JoshuaKGoldberg
Copy link
Member

👋 @arka1002 adding the newallow* options tono-floating-promises is one of our priorities for the next few months. I'd like to make sure this is actively moving towards completion. Do you think you'll be able to make a lot of progress over the next week?

If not, no worries - I'd happily take this on myself. It's a nuanced rule with a lot of context around it. ❤️

@arkapratimc
Copy link
ContributorAuthor

Yes, I've almost done the tests, give me just 3 more days. I'll open it for review.

JoshuaKGoldberg reacted with thumbs up emojiJoshuaKGoldberg reacted with heart emojiJoshuaKGoldberg reacted with rocket emoji

@arkapratimcarkapratimc marked this pull request as ready for reviewMarch 19, 2024 14:25
@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelApr 27, 2024
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a 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. 😄

arkapratimcand others added2 commitsApril 29, 2024 13:09
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
@JoshuaKGoldbergJoshuaKGoldberg requested review froma team and removed request forStyleShitApril 29, 2024 12:25
@kirkwaiblingerkirkwaiblinger added awaiting responseIssues waiting for a reply from the OP or another party and removed awaiting responseIssues waiting for a reply from the OP or another party labelsMay 1, 2024
Copy link
Member

@kirkwaiblingerkirkwaiblinger left a 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! 🙂

@arkapratimc
Copy link
ContributorAuthor

Thanks for the reviews. I'm just writing down some notes for the future people who are going to stumble upon this pr.

  1. then andcatch functions with 1 and 0 arguments should be reported based on the above review comment. Here are thetests.
  2. About mixed arrays, its very interesting though, Typescript actually reduces the type of the array if it contains any branded type or anything else. Here is theminimum repro(check the 2 slash comments). I have added1 test. I think if in any future version typescript changes the type to( Promise<number> | A )[] ( which might be the correct one ), we have to change the logic in this rule.

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelMay 11, 2024
@@ -2079,19 +2079,19 @@ promise;
},
{
code: `
interfaceUnsafeThenable<T> {
interfaceSafeThenable<T> {

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)

Copy link
ContributorAuthor

@arkapratimcarkapratimcMay 26, 2024
edited
Loading

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.

Copy link
Member

@kirkwaiblingerkirkwaiblingerMay 29, 2024
edited
Loading

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.

@kirkwaiblingerkirkwaiblinger added the awaiting responseIssues waiting for a reply from the OP or another party labelMay 18, 2024
@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelMay 26, 2024
@bradzacherbradzacher added the enhancement: plugin rule optionNew rule option for an existing eslint-plugin rule labelMay 28, 2024
Copy link
Member

@kirkwaiblingerkirkwaiblinger left a 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! ❤️

JoshuaKGoldberg and arkapratimc reacted with thumbs up emoji
@@ -2079,19 +2079,19 @@ promise;
},
{
code: `
interfaceUnsafeThenable<T> {
interfaceSafeThenable<T> {
Copy link
Member

@kirkwaiblingerkirkwaiblingerMay 29, 2024
edited
Loading

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 {

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 🙂).

@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJun 10, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@StyleShitStyleShitStyleShit requested changes

@kirkwaiblingerkirkwaiblingerkirkwaiblinger requested changes

@JoshuaKGoldbergJoshuaKGoldbergAwaiting requested review from JoshuaKGoldberg

Assignees
No one assigned
Labels
enhancement: plugin rule optionNew rule option for an existing eslint-plugin rule
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Enhancement: [no-floating-promises] add an 'allowForKnownSafePromises' option
5 participants
@arkapratimc@JoshuaKGoldberg@StyleShit@kirkwaiblinger@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp