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): [promise-function-async] check for promises in implicit return types#6330

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

ericbf
Copy link
Contributor

@ericbfericbf commentedJan 12, 2023
edited
Loading

When we return a union containing a promise from a function implicitly, it's often a mistake. This commit makes it so if the return type is explicit, anyPromise in the return type (whether it's part of a union or not) will flag the function. If it is intentional, make the return type explicit.

Fixes#6329

PR Checklist

Overview

This implements the heuristic that@bradzacher suggested. If the return type is explicit, it allows unions with non-Promise types, but if it is implicit, it flags those.

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@ericbf!

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.

@nx-cloud
Copy link

nx-cloudbot commentedJan 12, 2023
edited
Loading

☁️ Nx Cloud Report

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

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 fromNxCloud.

@netlify
Copy link

netlifybot commentedJan 12, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitbe9531d
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/63e6abc43fc01b0008da403d
😎 Deploy Previewhttps://deploy-preview-6330--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@codecov
Copy link

codecovbot commentedJan 12, 2023
edited
Loading

Codecov Report

Merging#6330 (be9531d) intomain (bbfed02) willdecrease coverage by0.03%.
The diff coverage is0.00%.

Additional details and impacted files
@@            Coverage Diff             @@##             main    #6330      +/-   ##==========================================- Coverage   90.61%   90.59%   -0.03%==========================================  Files         372      372                Lines       12709    12712       +3       Branches     3739     3743       +4     ==========================================  Hits        11516    11516- Misses        853      856       +3  Partials      340      340
FlagCoverage Δ
unittest90.59% <0.00%> (-0.03%)⬇️

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

Impacted FilesCoverage Δ
.../eslint-plugin/src/rules/promise-function-async.ts98.07% <ø> (ø)
packages/type-utils/src/containsAllTypesByName.ts0.00% <0.00%> (ø)

@ericbfericbf changed the title[promise-function-async] Only allow unions in explicit return typesfeat(eslint-plugin): check for promises in implicit return typesJan 12, 2023
@ericbfericbfforce-pushed thepromise-function-async-allow-union-in-explicit-types-only branch from3527630 toc65b905CompareJanuary 12, 2023 22:19
@bradzacherbradzacher changed the titlefeat(eslint-plugin): check for promises in implicit return typesfeat(eslint-plugin): [promise-function-async] check for promises in implicit return typesFeb 10, 2023
Copy link
Member

@bradzacherbradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

overall the changes look good - but we'll need to ensure we're not breaking the API

@bradzacherbradzacher added enhancementNew feature or request awaiting responseIssues waiting for a reply from the OP or another party labelsFeb 10, 2023
When we return a union containing a promise from a functionimplicitly, it's often a mistake. This commit makes it so if thereturn type is explicit, any `Promise` in the return type (whetherit's part of a union or not) will flag the function. If it isintentional, make the return type explicit.Fixestypescript-eslint#6329
@ericbfericbfforce-pushed thepromise-function-async-allow-union-in-explicit-types-only branch fromc30bf71 tobe9531dCompareFebruary 10, 2023 20:40
@bradzacherbradzacher removed the awaiting responseIssues waiting for a reply from the OP or another party labelFeb 13, 2023
Copy link
Member

@bradzacherbradzacher 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 this!

@bradzacherbradzacher added this pull request to the merge queueFeb 20, 2023
Merged via the queue intotypescript-eslint:main with commitde1e5ceFeb 20, 2023
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsFeb 28, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@bradzacherbradzacherbradzacher approved these changes

Assignees

@bradzacherbradzacher

Labels
enhancementNew feature or request
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Enhancement: [promise-function-async] flag non-async functions returning unions with non-Promise types
2 participants
@ericbf@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp