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

fix(eslint-plugin): [prefer-find] support ternary branches in prefer-find#8421

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

@kirkwaiblinger
Copy link
Member

PR Checklist

Overview

Adds support for recursively checking ternary branches.

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@kirkwaiblinger!

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.

@netlify
Copy link

netlifybot commentedFeb 9, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit9e599c0
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/65da2713759f0b0008172c9e
😎 Deploy Previewhttps://deploy-preview-8421--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: 90 (no change 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-cloud
Copy link

nx-cloudbot commentedFeb 9, 2024
edited
Loading

☁️ Nx Cloud Report

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

@kirkwaiblingerkirkwaiblinger changed the title8379: Support ternary branches in prefer-findfix(eslint-plugin): [prefer-find] support ternary branches in prefer-findFeb 9, 2024
@codecov
Copy link

codecovbot commentedFeb 9, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.06%. Comparing base(9c94b81) to head(9e599c0).
Report is 63 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@##             main    #8421      +/-   ##==========================================+ Coverage   86.94%   87.06%   +0.11%==========================================  Files         252      251       -1       Lines       12251    12278      +27       Branches     3861     3870       +9     ==========================================+ Hits        10652    10690      +38+ Misses       1332     1316      -16- Partials      267      272       +5
FlagCoverage Δ
unittest87.06% <100.00%> (+0.11%)⬆️

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

FilesCoverage Δ
packages/eslint-plugin/src/rules/prefer-find.ts100.00% <100.00%> (ø)

... and17 files with indirect coverage changes

@kirkwaiblingerkirkwaiblinger marked this pull request as ready for reviewFebruary 9, 2024 21:23
@kirkwaiblingerkirkwaiblinger deleted the add-support-for-ternaries branchFebruary 21, 2024 21:07
@kirkwaiblingerkirkwaiblinger restored the add-support-for-ternaries branchFebruary 21, 2024 21:09
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.

Code changes look great, nicely done! 👏

Just requesting changes on a bit more testing.

A League of Legends character dabbing in front of purple smoke and flames. Another character is fly-kicking down towards them from the air.

kirkwaiblinger reacted with thumbs up emoji
},
],
},
{
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldbergFeb 23, 2024
edited
Loading

Choose a reason for hiding this comment

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

[Testing] Just to be through, could you also add a test for a desired report with and within a ternary? Like thevalid case above, but either with two.filters or with the[0] on the other side of the last)?

(Math.random()<0.5  ?[1,2,3].filter(x=>false)  :[1,2,3].filter(x=>true))[0];
(Math.random()<0.5  ?[1,2,3].find(x=>true)  :[1,2,3].filter(x=>true)[0]);

The cases lower down are a bit more complex. It's nice to have more straightforward ones to use as a reference too.

kirkwaiblinger reacted with thumbs up emoji
},
{
code:`
declare const f: any, g: any;

Choose a reason for hiding this comment

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

[Testing] Nit: here and below, if there's no need to use anany, might as well avoid it:

Suggested change
declareconstf:any,g:any;
declareconstf:unknown,g:unknown;

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

it would have a type error without. I was just too lazy to write out the actual type of the filter callback (and the rule doesn't care about the type of the filter callback) so i went for the easiest way to not error :)

Choose a reason for hiding this comment

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

Ha, gotcha.#8298 ->#8351 tracks making tests error on type unhappiness. cc@auvred - do you think we should start asking folks to try to not have type errors?

kirkwaiblinger reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I'm +1 to avoid semantic errors, at least in newly added tests :)

Especially when it's not that hard:

- declare const f: any, g: any;+ declare const f: (x: unknown) => boolean, g: (x: unknown) => boolean;

kirkwaiblinger reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Fair enough, changed

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelFeb 23, 2024
@github-actionsgithub-actionsbot removed the awaiting responseIssues waiting for a reply from the OP or another party labelFeb 24, 2024
JoshuaKGoldberg
JoshuaKGoldberg previously approved these changesFeb 24, 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.

LGTM, nice! Since it's tricky logic being touched, will leave open for a bit under1 approval.

kirkwaiblinger reacted with thumbs up emoji
@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelFeb 24, 2024
auvred
auvred previously approved these changesFeb 24, 2024
Copy link
Member

@auvredauvred left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

kirkwaiblinger reacted with heart emoji
Copy link
Member

@auvredauvred left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for updating tests!

Man claps his hands

kirkwaiblinger reacted with thumbs up emojikirkwaiblinger reacted with hooray emoji
@JoshuaKGoldbergJoshuaKGoldberg merged commitc0e3267 intotypescript-eslint:mainMar 11, 2024
@kirkwaiblingerkirkwaiblinger deleted the add-support-for-ternaries branchMarch 11, 2024 13:31
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsMar 19, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@auvredauvredauvred approved these changes

@JoshuaKGoldbergJoshuaKGoldbergAwaiting requested review from JoshuaKGoldberg

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.

Bug: [prefer-find] Add support for checking ternaries

3 participants

@kirkwaiblinger@JoshuaKGoldberg@auvred

[8]ページ先頭

©2009-2025 Movatter.jp