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] improve checking optional callee#8178

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 1 commit intotypescript-eslint:mainfromyeonjuan:fix/7912
Jan 8, 2024

Conversation

yeonjuan
Copy link
Contributor

@yeonjuanyeonjuan commentedJan 3, 2024
edited
Loading

PR Checklist

Overview

This pr improves unnecessary optional chaining checking ofno-unnecessary-condition.
In below example, optional chain iny()?. is unnecessary becausey does not return nullable value.
As described in#7912, the currentno-unnecessary-condition does not check for the following case.

typeT1={y:()=>number}|null;declareconstx1:T1;x1?.y()?.toExponential();

I addedisCallExpressionNullableOriginFromCallee function.
This function takes a CallExpression node as an argument. It returnstrue if the call expression's nullable type is origin from callee otherwise returnsfalse.

// isCallExpressionNullableOriginFromCallee will return true for given call expression `y()`typeT1={y:()=>number}|null;declareconstx1:T1;x1?.y()?.toExponential();//    ^^^ y()'s nullable type is origin from T1's nullable type// isCallExpressionNullableOriginFromCallee will return false for given call expression `y()`typeT1={y:()=>number|null}|null;declareconstx1:T1;x1?.y()?.toExponential();//    ^^^ y()'s nullable type is origin from it's own definition. (() => number | null)

@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 3, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitd2acec3
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/65996385acf2ac00082030a5
😎 Deploy Previewhttps://deploy-preview-8178--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: 96 (🔴 down 3 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/7912 branch 2 times, most recently fromf11873b to3dd8119CompareJanuary 6, 2024 14:28
@yeonjuanyeonjuan changed the titlefix(eslint-plugin): [no-unnecessary-condition] handle nullable calleefix(eslint-plugin): [no-unnecessary-condition] improve checking optional calleeJan 6, 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.

Tricky 😄 but this look great. Thanks for working on it!

Posh older British lady saying 'excellent!' enthusiastically and clenching a fist

@JoshuaKGoldbergJoshuaKGoldberg merged commit10c0530 intotypescript-eslint:mainJan 8, 2024
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJan 16, 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
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Bug: [no-unnecessary-condition] Improper checking of optional chaining of defined method return value
2 participants
@yeonjuan@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp