Skip to content

fix(eslint-plugin): [promise-function-async] use a different error message for functions with promise and non-promise types #10950

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

Conversation

ronami
Copy link
Member

@ronami ronami commented Mar 14, 2025

PR Checklist

Overview

This PR addresses #10687 and adds a custom error message for functions with hybrid return types (and no return type annotation).

Random thought: Should this be a suggestion instead of an auto-fix in this case?

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @ronami!

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.

Copy link

netlify bot commented Mar 14, 2025

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 489037c
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/67f1160a714f270008760b1d
😎 Deploy Preview https://deploy-preview-10950--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 5 from production)
Accessibility: 100 (no change from production)
Best Practices: 100 (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 your Netlify site configuration.

Copy link

nx-cloud bot commented Mar 14, 2025

View your CI Pipeline Execution ↗ for commit 489037c.

Command Status Duration Result
nx run-many --target=build --exclude website --... ✅ Succeeded 2s View ↗
nx run-many --target=clean ✅ Succeeded 10s View ↗

☁️ Nx Cloud last updated this comment at 2025-04-07 12:12:16 UTC

Copy link

codecov bot commented Mar 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.03%. Comparing base (052b7f9) to head (489037c).
Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10950   +/-   ##
=======================================
  Coverage   88.03%   88.03%           
=======================================
  Files         470      470           
  Lines       16801    16805    +4     
  Branches     4745     4747    +2     
=======================================
+ Hits        14790    14794    +4     
  Misses       1664     1664           
  Partials      347      347           
Flag Coverage Δ
unittest 88.03% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
.../eslint-plugin/src/rules/promise-function-async.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ronami ronami marked this pull request as ready for review March 14, 2025 14:55
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

LGTM! Just one suggestion on the phrasing?

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Mar 17, 2025
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
@kirkwaiblinger
Copy link
Member

kirkwaiblinger commented Mar 18, 2025

Random thought: Should this be a suggestion instead of an auto-fix in this case?

I personally like the idea of providing two suggestions:

  • add async (demoted from autofix)
  • add explicit return type

TBH it's suspect to me that this is ever an autofix rather than a suggestion, since I don't like autofixing runtime behavior changes based on type information, but that's neither here nor there.

@kirkwaiblinger kirkwaiblinger added awaiting response Issues waiting for a reply from the OP or another party 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge and removed 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labels Mar 18, 2025
@JoshuaKGoldberg JoshuaKGoldberg removed the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Mar 24, 2025
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

👍 My vote: mentioning the type being a union, as Kirk suggested?

ronami and others added 2 commits April 1, 2025 18:50
Co-authored-by: Kirk Waiblinger <53019676+kirkwaiblinger@users.noreply.github.com>
@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Apr 1, 2025
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Great! Just pinging @kirkwaiblinger to confirm, this looks lovely to me.

Walton Goggins as Rick Hatchett in White Lotus smiling with sunglasses, moving his hands from a prayer symbol to pointing at a person

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Apr 7, 2025
Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

❤️ 🚀

@JoshuaKGoldberg JoshuaKGoldberg merged commit 128d95b into typescript-eslint:main Apr 14, 2025
58 checks passed
@ronami ronami deleted the promise-function-async-mixed-return-type branch April 14, 2025 14:07
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Apr 17, 2025
| datasource | package                          | from   | to     |
| ---------- | -------------------------------- | ------ | ------ |
| npm        | @typescript-eslint/eslint-plugin | 8.29.0 | 8.30.1 |
| npm        | @typescript-eslint/parser        | 8.29.0 | 8.30.1 |


## [v8.30.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8301-2025-04-14)

##### 🩹 Fixes

-   **eslint-plugin:** fix mistake with eslintrc config generation ([#11072](typescript-eslint/typescript-eslint#11072))

##### ❤️ Thank You

-   Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.


## [v8.30.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8300-2025-04-14)

##### 🚀 Features

-   **eslint-plugin:** \[no-explicit-any] suggest to replace keyof any with PropertyKey ([#11032](typescript-eslint/typescript-eslint#11032))

##### 🩹 Fixes

-   **eslint-plugin:** \[promise-function-async] use a different error message for functions with promise and non-promise types ([#10950](typescript-eslint/typescript-eslint#10950))

##### ❤️ Thank You

-   Dima Barabash [@dbarabashh](https://github.com/dbarabashh)
-   Ronen Amiel

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.


## [v8.29.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8291-2025-04-07)

##### 🩹 Fixes

-   **eslint-plugin:** \[no-deprecated] report on deprecated imported variable used as property ([#10998](typescript-eslint/typescript-eslint#10998))

##### ❤️ Thank You

-   Ronen Amiel

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Apr 17, 2025
| datasource | package                          | from   | to     |
| ---------- | -------------------------------- | ------ | ------ |
| npm        | @typescript-eslint/eslint-plugin | 8.29.0 | 8.30.1 |
| npm        | @typescript-eslint/parser        | 8.29.0 | 8.30.1 |


## [v8.30.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8301-2025-04-14)

##### 🩹 Fixes

-   **eslint-plugin:** fix mistake with eslintrc config generation ([#11072](typescript-eslint/typescript-eslint#11072))

##### ❤️ Thank You

-   Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.


## [v8.30.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8300-2025-04-14)

##### 🚀 Features

-   **eslint-plugin:** \[no-explicit-any] suggest to replace keyof any with PropertyKey ([#11032](typescript-eslint/typescript-eslint#11032))

##### 🩹 Fixes

-   **eslint-plugin:** \[promise-function-async] use a different error message for functions with promise and non-promise types ([#10950](typescript-eslint/typescript-eslint#10950))

##### ❤️ Thank You

-   Dima Barabash [@dbarabashh](https://github.com/dbarabashh)
-   Ronen Amiel

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.


## [v8.29.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8291-2025-04-07)

##### 🩹 Fixes

-   **eslint-plugin:** \[no-deprecated] report on deprecated imported variable used as property ([#10998](typescript-eslint/typescript-eslint#10998))

##### ❤️ Thank You

-   Ronen Amiel

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Apr 19, 2025
| datasource | package                          | from   | to     |
| ---------- | -------------------------------- | ------ | ------ |
| npm        | @typescript-eslint/eslint-plugin | 8.29.0 | 8.30.1 |
| npm        | @typescript-eslint/parser        | 8.29.0 | 8.30.1 |


## [v8.30.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8301-2025-04-14)

##### 🩹 Fixes

-   **eslint-plugin:** fix mistake with eslintrc config generation ([#11072](typescript-eslint/typescript-eslint#11072))

##### ❤️ Thank You

-   Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.


## [v8.30.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8300-2025-04-14)

##### 🚀 Features

-   **eslint-plugin:** \[no-explicit-any] suggest to replace keyof any with PropertyKey ([#11032](typescript-eslint/typescript-eslint#11032))

##### 🩹 Fixes

-   **eslint-plugin:** \[promise-function-async] use a different error message for functions with promise and non-promise types ([#10950](typescript-eslint/typescript-eslint#10950))

##### ❤️ Thank You

-   Dima Barabash [@dbarabashh](https://github.com/dbarabashh)
-   Ronen Amiel

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.


## [v8.29.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8291-2025-04-07)

##### 🩹 Fixes

-   **eslint-plugin:** \[no-deprecated] report on deprecated imported variable used as property ([#10998](typescript-eslint/typescript-eslint#10998))

##### ❤️ Thank You

-   Ronen Amiel

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
renovate bot added a commit to andrei-picus-tink/auto-renovate that referenced this pull request Apr 20, 2025
| datasource | package                          | from   | to     |
| ---------- | -------------------------------- | ------ | ------ |
| npm        | @typescript-eslint/eslint-plugin | 8.29.0 | 8.30.1 |
| npm        | @typescript-eslint/parser        | 8.29.0 | 8.30.1 |


## [v8.30.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8301-2025-04-14)

##### 🩹 Fixes

-   **eslint-plugin:** fix mistake with eslintrc config generation ([#11072](typescript-eslint/typescript-eslint#11072))

##### ❤️ Thank You

-   Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.


## [v8.30.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8300-2025-04-14)

##### 🚀 Features

-   **eslint-plugin:** \[no-explicit-any] suggest to replace keyof any with PropertyKey ([#11032](typescript-eslint/typescript-eslint#11032))

##### 🩹 Fixes

-   **eslint-plugin:** \[promise-function-async] use a different error message for functions with promise and non-promise types ([#10950](typescript-eslint/typescript-eslint#10950))

##### ❤️ Thank You

-   Dima Barabash [@dbarabashh](https://github.com/dbarabashh)
-   Ronen Amiel

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.


## [v8.29.1](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8291-2025-04-07)

##### 🩹 Fixes

-   **eslint-plugin:** \[no-deprecated] report on deprecated imported variable used as property ([#10998](typescript-eslint/typescript-eslint#10998))

##### ❤️ Thank You

-   Ronen Amiel

You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Development

Successfully merging this pull request may close these issues.

Bug: promise-function-async is reporting on () => A | Promise<B>
3 participants