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-unsafe-return] check promise any#8693

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

Merged
JoshuaKGoldberg merged 22 commits intotypescript-eslint:mainfromyeonjuan:fix-8674
Aug 12, 2024

Conversation

@yeonjuan
Copy link
Contributor

PR Checklist

Overview

kirkwaiblinger reacted with thumbs up emoji
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@yeonjuan!

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.

@yeonjuanyeonjuan marked this pull request as draftMarch 17, 2024 07:52
@netlify
Copy link

netlifybot commentedMar 17, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit006d16c
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/669e79e1b9ebfd00092dabdb
😎 Deploy Previewhttps://deploy-preview-8693--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: 100 (🟢 up 6 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-cloud
Copy link

nx-cloudbot commentedMar 17, 2024
edited
Loading

☁️ Nx Cloud Report

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

@yeonjuanyeonjuan marked this pull request as ready for reviewApril 10, 2024 08:30
Copy link
Member

@kirkwaiblingerkirkwaiblinger left a comment
edited
Loading

Choose a reason for hiding this comment

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

A good start! Curious to see what ends up changing in order to support the added test cases.

And a thought - these are realllly tricky. I spent a lot of time myself getting confused over whether the code I was trying out actually should pass or fail 😆.

So, I wonder if we can help the user out by supplying a custom error message for the async cases that don't directly returnany, but whose type evaluates toany after beingAwaited? Feel free to ignore this if it's a hassle to implement. But, my thought would be something like "Unsafe return of typePromise<any> that is equivalent to simply returningany within an async function." I'm curious for your thoughts. And, as said, it's completely ok if you would prefer to ignore this idea!

yeonjuan reacted with thumbs up emoji
@kirkwaiblingerkirkwaiblinger added the awaiting responseIssues waiting for a reply from the OP or another party labelApr 21, 2024
messageId:'unsafeReturn',
line:4,
column:3,
endColumn:16,

Choose a reason for hiding this comment

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

(nit, optional) If you're gonna include theendColumn, might as well include theendLine too for consistency. Here and elsewhere

@yeonjuan
Copy link
ContributorAuthor

So, I wonder if we can help the user out by supplying a custom error message for the async cases that don't directly return any, but whose type evaluates to any after being Awaited? Feel free to ignore this if it's a hassle to implement. But, my thought would be something like "Unsafe return of type Promise that is equivalent to simply returning any within an async function." I'm curious for your thoughts. And, as said, it's completely ok if you would prefer to ignore this idea!

@kirkwaiblinger I agree, this is great, but how about making the error message a little more concise?"Unsafe return of type Promise<any> typed value"

@kirkwaiblinger
Copy link
Member

So, I wonder if we can help the user out by supplying a custom error message for the async cases that don't directly return any, but whose type evaluates to any after being Awaited? Feel free to ignore this if it's a hassle to implement. But, my thought would be something like "Unsafe return of type Promise that is equivalent to simply returning any within an async function." I'm curious for your thoughts. And, as said, it's completely ok if you would prefer to ignore this idea!

@kirkwaiblinger I agree, this is great, but how about making the error message a little more concise?"Unsafe return of type Promise<any> typed value"

👍 👍

# Conflicts:#packages/eslint-plugin/tests/rules/no-unsafe-return.test.ts
@codecov
Copy link

codecovbot commentedApr 30, 2024
edited
Loading

Codecov Report

Attention: Patch coverage is71.42857% with8 lines in your changes missing coverage. Please review.

Project coverage is 88.42%. Comparing base(d32d8f4) to head(006d16c).
Report is 158 commits behind head on main.

FilesPatch %Lines
packages/type-utils/src/predicates.ts0.00%8 Missing⚠️
Additional details and impacted files
@@            Coverage Diff             @@##             main    #8693      +/-   ##==========================================- Coverage   88.45%   88.42%   -0.03%==========================================  Files         422      422                Lines       14695    14717      +22       Branches     4298     4308      +10     ==========================================+ Hits        12998    13014      +16- Misses       1372     1378       +6  Partials      325      325
FlagCoverage Δ
unittest88.42% <71.42%> (-0.03%)⬇️

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

FilesCoverage Δ
...ckages/eslint-plugin/src/rules/no-unsafe-return.ts97.43% <100.00%> (+0.66%)⬆️
packages/type-utils/src/predicates.ts21.21% <0.00%> (-2.13%)⬇️

@yeonjuan
Copy link
ContributorAuthor

CI is failing, I created a separate PR to fix it.#9037

@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelMay 3, 2024
@yeonjuan
Copy link
ContributorAuthor

@kirkwaiblinger Thank you for your review. I added test cases and improved messsage.

kirkwaiblinger reacted with thumbs up emoji

@bradzacherbradzacher added the enhancementNew feature or request 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.

Hi@yeonjuan!

First off, I want to say I am very sorry for how long it's taken me to get to another review pass on this!

This is great stuff. A few more tweaks and questions for iteration, but I feel like we're getting close 🙂

?'any'
:anyType===AnyType.AnyArray
?'any[]'
:'Promise<any>',

Choose a reason for hiding this comment

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

Nit - not your fault, but this now runs into an "a" vs "an" issue in the generated string. I get
Unsafe return of an `Promise<any>` typed value

Would you change the wording a bit so that it's grammatically consistent?
For example,Unsafe return of a value of type {{type}}.

yeonjuan and JoshuaKGoldberg reacted with thumbs up emoji
Safe,
}
/**
*@returns `AnyType.Any` if the type is `any`, `AnyType.AnyArray` if the type is `any[]` or `readonly any[]`,

Choose a reason for hiding this comment

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

nit - comment will need updating

yeonjuan reacted with thumbs up emoji
@kirkwaiblingerkirkwaiblinger added the awaiting responseIssues waiting for a reply from the OP or another party labelJun 11, 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.

Only blocker remaining is resolution of#8693 (comment), I think

@kirkwaiblingerkirkwaiblinger added the awaiting responseIssues waiting for a reply from the OP or another party labelJul 15, 2024
*/
getTypeOfPropertyOfType(type:Type,propertyName:string):Type|undefined;
/**
* Return the awaited type of the given type.

Choose a reason for hiding this comment

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

Maybe add a TODO that this should no longer be necessary in a future TS version and link the TS issue?

yeonjuan reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sure!fcca5ec

JoshuaKGoldberg
JoshuaKGoldberg previously approved these changesJul 20, 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.

Yay! 🚀

@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelJul 20, 2024
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
{
code:`
declare const value: Promise<any>;
function foo() {

Choose a reason for hiding this comment

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

I thought this is supposed to be valid, since it's not anasync function, according to#8674 (comment). Did that decision get changed?

Choose a reason for hiding this comment

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

Note also that the error message for this case "Unsafe return of anPromise<any> typed value." is problematic, same as#8693 (comment)

Copy link
ContributorAuthor

@yeonjuanyeonjuanJul 22, 2024
edited
Loading

Choose a reason for hiding this comment

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

I've fixed! I had forgotten about those comments.

kirkwaiblinger reacted with thumbs up emoji
@auvredauvred removed the awaiting responseIssues waiting for a reply from the OP or another party labelJul 22, 2024
auvred
auvred previously approved these changesJul 22, 2024
Copy link
Member

@auvredauvred left a comment
edited
Loading

Choose a reason for hiding this comment

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

Looks great!

UPD: There seems to be a merge conflict with#9540.

yeonjuan reacted with thumbs up emoji
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.

Left a couple questions

auvred reacted with laugh emoji
@auvredauvred added the awaiting responseIssues waiting for a reply from the OP or another party labelJul 22, 2024
@JoshuaKGoldbergJoshuaKGoldberg removed the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelJul 29, 2024
@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelAug 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.

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 labelAug 1, 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.

Person in bear costume breakdancing with a boombox on a street

@JoshuaKGoldbergJoshuaKGoldberg merged commitc20bd2f intotypescript-eslint:mainAug 12, 2024
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsAug 20, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

@kirkwaiblingerkirkwaiblingerkirkwaiblinger approved these changes

@auvredauvredauvred 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 mergeenhancementNew feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Enhancement: [no-unsafe-return] Disallow return Promise<any>

5 participants

@yeonjuan@kirkwaiblinger@JoshuaKGoldberg@auvred@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp