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): [no-unnecessary-condition] fix false positive for type variable#8235

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 2 commits intotypescript-eslint:mainfromyeonjuan:fix/7850
Jan 19, 2024

Conversation

yeonjuan
Copy link
Contributor

PR Checklist

Overview

Fix the following false positive cases.

functionfoo<Textendsobject>(arg:T,key:keyofT):void{constt1=arg[key]==null;constt2=null==arg[key];constt3=arg[key]!=null;constt4=null!=arg[key];constt5=arg[key]==undefined;constt6=undefined==arg[key];constt7=arg[key]!=undefined;constt8=undefined!=arg[key];constt9=arg[key]===null;constt10=null===arg[key];constt11=arg[key]!==null;constt12=null!==arg[key];constt13=arg[key]===undefined;constt14=undefined===arg[key];constt15=arg[key]!==undefined;constt16=undefined!==arg[key];arg[key]??'default';arg[key]??='default';arg[key]||='default';}

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

@netlifyNetlify
Copy link

netlifybot commentedJan 10, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitc2fbb1c
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/65aa5ac8fd342e0008166fcd
😎 Deploy Previewhttps://deploy-preview-8235--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 (🔴 down 7 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.

@yeonjuanyeonjuanforce-pushed thefix/7850 branch 2 times, most recently fromd7befe4 tob7741f8CompareJanuary 10, 2024 16:54
JoshuaKGoldberg
JoshuaKGoldberg previously approved these changesJan 11, 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.

This looks great to me, thanks for the fix!

Just one note on testing, but I'm happy to merge as-is or make the cleanup myself given that the tests for this rule already do the "test a lot in one case" thing.

Lime yellow wacky inflatable arm tube thing dancing happily

@JoshuaKGoldbergJoshuaKGoldberg added 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge awaiting responseIssues waiting for a reply from the OP or another party labelsJan 11, 2024
Comment on lines 257 to 259
function foo<T extends object>(arg: T, key: keyof T): void {
const t1 = arg[key] == null;
const t2 = null == arg[key];
const t3 = arg[key] != null;
const t4 = null != arg[key];
const t5 = arg[key] == undefined;
const t6 = undefined == arg[key];
const t7 = arg[key] != undefined;
const t8 = undefined != arg[key];
const t9 = arg[key] === null;
const t10 = null === arg[key];
const t11 = arg[key] !== null;
const t12 = null !== arg[key];
const t13 = arg[key] === undefined;
const t14 = undefined === arg[key];
const t15 = arg[key] !== undefined;
const t16 = undefined !== arg[key];
}
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Suggested change
functionfoo<Textendsobject>(arg:T,key:keyofT):void{
constt1=arg[key]==null;
constt2=null==arg[key];
constt3=arg[key]!=null;
constt4=null!=arg[key];
constt5=arg[key]==undefined;
constt6=undefined==arg[key];
constt7=arg[key]!=undefined;
constt8=undefined!=arg[key];
constt9=arg[key]===null;
constt10=null===arg[key];
constt11=arg[key]!==null;
constt12=null!==arg[key];
constt13=arg[key]===undefined;
constt14=undefined===arg[key];
constt15=arg[key]!==undefined;
constt16=undefined!==arg[key];
}
functionfoo<Textendsobject>(arg:T,key:keyofT):void{
arg[key]==null;
}

Comment on lines 770 to 773
function foo<T extends object>(arg: T, key: keyof T): void {
arg[key] ??= 'default';
arg[key] ||= 'default';
arg[key] &&= 'default';
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Suggested change
functionfoo<Textendsobject>(arg:T,key:keyofT):void{
arg[key]??='default';
arg[key]||='default';
arg[key]&&='default';
functionfoo<Textendsobject>(arg:T,key:keyofT):void{
arg[key]??='default';

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.

💯 looks great, thanks as always!

Animation of a happy blue animal with raised hands. The animal wipes and spins from left of view to right of view

@JoshuaKGoldbergJoshuaKGoldberg merged commit920f909 intotypescript-eslint:mainJan 19, 2024
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJan 27, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

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: [no-unnecessary-condition] false positive on indexed access of a generic type
2 participants
@yeonjuan@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp