Skip to content
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

fix(eslint-plugin): [prefer-optional-chain] only look at left operand for requireNullish #8559

Merged

Conversation

abrahamguo
Copy link
Contributor

@abrahamguo abrahamguo commented Feb 27, 2024

PR Checklist

Overview

As mentioned in the linked issue, requireNullish: true wrongly disables all checking for this rule. This is because it mistakenly applies the requireNullish logic to both the left and right operands, rather than only the left.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @abrahamguo!

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 Feb 27, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 15d7dbc
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66131281a8d8e2000859235e
😎 Deploy Preview https://deploy-preview-8559--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: 93 (🟢 up 2 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 your Netlify site configuration.

Copy link

codecov bot commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.24%. Comparing base (716b783) to head (fd2b38f).
Report is 18 commits behind head on main.

❗ Current head fd2b38f differs from pull request most recent head 15d7dbc. Consider uploading reports for the commit 15d7dbc to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8559      +/-   ##
==========================================
- Coverage   88.02%   87.24%   -0.78%     
==========================================
  Files         405      252     -153     
  Lines       14089    12344    -1745     
  Branches     4125     3882     -243     
==========================================
- Hits        12402    10770    -1632     
+ Misses       1382     1305      -77     
+ Partials      305      269      -36     
Flag Coverage Δ
unittest 87.24% <100.00%> (-0.78%) ⬇️

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

Files Coverage Δ
.../rules/prefer-optional-chain-utils/analyzeChain.ts 100.00% <100.00%> (ø)
...efer-optional-chain-utils/checkNullishAndReport.ts 100.00% <100.00%> (ø)
...efer-optional-chain-utils/gatherLogicalOperands.ts 100.00% <ø> (ø)
...s/eslint-plugin/src/rules/prefer-optional-chain.ts 97.61% <100.00%> (+0.05%) ⬆️

... and 176 files with indirect coverage changes

Copy link
Member

@auvred auvred left a comment

Choose a reason for hiding this comment

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

I haven't looked deep into the source code of the rule yet, so I can't suggest any complete solutions. Requesting changes to prevent one potential bug and to improve the tests.


It also looks like you linked the wrong issue in the PR description. I believe you should link this one: #8487. Right?

@auvred auvred added the awaiting response Issues waiting for a reply from the OP or another party label Feb 27, 2024
@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Mar 12, 2024
@abrahamguo abrahamguo requested a review from auvred March 12, 2024 12:38
@auvred auvred added the awaiting response Issues waiting for a reply from the OP or another party label Mar 12, 2024
@abrahamguo abrahamguo requested a review from auvred March 13, 2024 22:56
@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Mar 13, 2024
Copy link
Member

@auvred auvred left a comment

Choose a reason for hiding this comment

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

The overall code changes look great to me! Although, I haven't gotten deep enough into the rule code to 100% understand the logic yet. I'll try to take the time to figure out how it works internally, and then I can do a more thorough review 🙂

@auvred auvred added the awaiting response Issues waiting for a reply from the OP or another party label Mar 16, 2024
@abrahamguo abrahamguo requested a review from auvred March 16, 2024 13:41
@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Mar 16, 2024
@bradzacher bradzacher added the bug Something isn't working label Apr 4, 2024
Copy link
Member

@auvred auvred left a comment

Choose a reason for hiding this comment

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

Mostly LGTM!

But there is conflict with main branch in packages/eslint-plugin/src/rules/prefer-optional-chain-utils/analyzeChain.ts file. Could you please resolve it?

@auvred auvred added the awaiting response Issues waiting for a reply from the OP or another party label Apr 6, 2024
@abrahamguo abrahamguo requested a review from auvred April 7, 2024 17:25
@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Apr 7, 2024
Copy link
Member

@auvred auvred 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 working on this 🚀

@auvred auvred added the 1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready label Apr 8, 2024
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!

Since @bradzacher touched a ton of this stuff in #6397, will wait for a bit in case Brad has time to review.

@JoshuaKGoldberg JoshuaKGoldberg merged commit eef257b into typescript-eslint:main Apr 22, 2024
57 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [prefer-optional-chain] doesn't report at all when requireNullish is true
4 participants