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 checkThenables option#9263

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

Conversation

JoshuaKGoldberg
Copy link
Member

PR Checklist

Overview

Adds a newcheckThenablesboolean 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.

💖

@typescript-eslint
Copy link
Contributor

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 onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedJun 4, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitdac381c
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/668996765b425e00089b41b5
😎 Deploy Previewhttps://deploy-preview-9263--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: 96 (🟢 up 2 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (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 commentedJun 4, 2024
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commitdac381c. 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


🟥 Failed Commands
nx test eslint-plugin --coverage=false
✅ Successfully ran 29 targets

Sent with 💌 fromNxCloud.

@Josh-Cena
Copy link
Member

I don't get the motivation for this, TBH. How can something "happen to be thenable" without noticing? Doesthen have any other meaning other than interoperating with promises? JavaScript itself resolves thenables, so if your thenable is not supposed to quack like a promise you will shoot yourself in the foot everywhere, like returning it from an async function, etc.

@JoshuaKGoldbergJoshuaKGoldberg changed the titlefeat(eslint-plugin): [no-floating-promises] add checkAllThenables optionfeat(eslint-plugin): [no-floating-promises] add checkThenables optionJun 4, 2024
kirkwaiblinger
kirkwaiblinger previously approved these changesJun 4, 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.

rocket

@JoshuaKGoldberg
Copy link
MemberAuthor

How can something "happen to be thenable" without noticing?

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+.

@Josh-Cena
Copy link
Member

Why would one expect a polyfill tonot be checked like a real promise?

@JoshuaKGoldberg
Copy link
MemberAuthor

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.

@Josh-Cena
Copy link
Member

The issue mentionsnode:test, but doesn'ttest() return a real promise?

@JoshuaKGoldberg
Copy link
MemberAuthor

@Josh-Cena the Node issue does, but our#8433 -> this PR isn't around that I don't think.

@Josh-Cena
Copy link
Member

Josh-Cena commentedJun 5, 2024
edited
Loading

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 arewhy we check thenables.

@JoshuaKGoldberg
Copy link
MemberAuthor

Great points. Putting into draft per#8433 (comment). Thanks!

Josh-Cena reacted with thumbs up emoji

@JoshuaKGoldbergJoshuaKGoldberg marked this pull request as draftJune 5, 2024 13:26
@JoshuaKGoldberg
Copy link
MemberAuthor

#8433 was confirmed as good to go, so un-drafting. 👍

@JoshuaKGoldbergJoshuaKGoldberg marked this pull request as ready for reviewJune 29, 2024 19:53
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.

Code makes sense to me! only blocker is some test coverage

@codecovCodecov
Copy link

codecovbot commentedJul 1, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.24%. Comparing base(dfae228) to head(6078b07).
Report is 111 commits behind head on main.

Current head6078b07 differs from pull request most recent headdac381c

Pleaseupload reports for the commitdac381c to get more accurate results.

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
FlagCoverage Δ
unittest88.24% <100.00%> (+0.81%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

FilesCoverage Δ
...es/eslint-plugin/src/rules/no-floating-promises.ts100.00% <100.00%> (ø)

... and187 files with indirect coverage changes

kirkwaiblinger
kirkwaiblinger previously approved these changesJul 3, 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.

yay

@kirkwaiblingerkirkwaiblinger added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelJul 3, 2024
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
@JoshuaKGoldberg
Copy link
MemberAuthor

Confirmed with@Josh-Cena that we're good to merge with those docs suggestions. 🚀!

kirkwaiblinger reacted with thumbs up emoji

@JoshuaKGoldbergJoshuaKGoldberg merged commit63d17dd intotypescript-eslint:mainJul 6, 2024
52 of 58 checks passed
@JoshuaKGoldbergJoshuaKGoldberg deleted the no-floating-promises-check-all-thenables branchJuly 6, 2024 19:18
kirkwaiblinger pushed a commit that referenced this pull requestJul 8, 2024
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJul 14, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@Josh-CenaJosh-CenaJosh-Cena left review comments

@kirkwaiblingerkirkwaiblingerkirkwaiblinger left review comments

Assignees
No one assigned
Labels
1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Enhancement: [no-floating-promises] Don't check coincidentally Promise-like (Thenable) type values by default
3 participants
@JoshuaKGoldberg@Josh-Cena@kirkwaiblinger

[8]ページ先頭

©2009-2025 Movatter.jp