Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
fix(eslint-plugin): [prefer-optional-chain] only look at left operand forrequireNullish
#8559
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
fix(eslint-plugin): [prefer-optional-chain] only look at left operand forrequireNullish
#8559
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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 onhttps://opencollective.com/typescript-eslint. |
netlifybot commentedFeb 27, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview fortypescript-eslint ready!
To edit notification comments on pull requests, go to yourNetlify site configuration. |
nx-cloudbot commentedFeb 27, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
codecovbot commentedFeb 27, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
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
Flags with carried forward coverage won't be shown.Click here to find out more.
|
auvred left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this 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?
packages/eslint-plugin/src/rules/prefer-optional-chain-utils/gatherLogicalOperands.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/eslint-plugin/tests/rules/prefer-optional-chain/prefer-optional-chain.test.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
packages/eslint-plugin/src/rules/prefer-optional-chain-utils/gatherLogicalOperands.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
…refer-optional-chain
…refer-optional-chain
…refer-optional-chain
…refer-optional-chain
packages/eslint-plugin/src/rules/prefer-optional-chain-utils/checkNullishAndReport.tsShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this 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 🙂
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this 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 withmain
branch inpackages/eslint-plugin/src/rules/prefer-optional-chain-utils/analyzeChain.ts
file. Could you please resolve it?
packages/eslint-plugin/src/rules/prefer-optional-chain-utils/analyzeChain.ts OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this 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 🚀
There was a problem hiding this 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.
Uh oh!
There was an error while loading.Please reload this page.
PR Checklist
requireNullish
istrue
#8487Overview
As mentioned in the linked issue,
requireNullish: true
wrongly disables all checking for this rule. This is because it mistakenly applies therequireNullish
logic to both the left and right operands, rather than only the left.