Skip to content

fix(eslint-plugin): [no-unnecessary-condition] false positive on optional private field #9602

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

Conversation

StyleShit
Copy link
Contributor

@StyleShit StyleShit commented Jul 21, 2024

PR Checklist

Overview

This PR accounts for private identifiers when checking if a member expression is nullable

Not sure if/which additional test cases I should add here, so I'm open for suggestions 😄

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @StyleShit!

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 Jul 21, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit ef7539f
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/669d480b68b5d900087badac
😎 Deploy Preview https://deploy-preview-9602--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 (🟢 up 2 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (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

nx-cloud bot commented Jul 21, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit ef7539f. 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 1 target

Sent with 💌 from NxCloud.

@StyleShit StyleShit marked this pull request as ready for review July 21, 2024 15:56
Copy link

codecov bot commented Jul 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.45%. Comparing base (863eb86) to head (ef7539f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9602   +/-   ##
=======================================
  Coverage   88.45%   88.45%           
=======================================
  Files         422      422           
  Lines       14694    14695    +1     
  Branches     4299     4298    -1     
=======================================
+ Hits        12997    12998    +1     
  Misses       1372     1372           
  Partials      325      325           
Flag Coverage Δ
unittest 88.45% <100.00%> (+<0.01%) ⬆️

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

Files Coverage Δ
...slint-plugin/src/rules/no-unnecessary-condition.ts 98.57% <100.00%> (+<0.01%) ⬆️

@@ -211,15 +211,20 @@ export default createRule<Options, MessageId>({
}
const property = node.property;

if (property.type === AST_NODE_TYPES.Identifier) {
Copy link
Contributor Author

@StyleShit StyleShit Jul 21, 2024

Choose a reason for hiding this comment

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

This condition is unnecessary because the property type is Identifier | PrivateIdentifier,
and now we catch both of them

Copy link
Member

@kirkwaiblinger kirkwaiblinger left a comment

Choose a reason for hiding this comment

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

Looks good to me! Nice 🙂

@kirkwaiblinger kirkwaiblinger added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Jul 21, 2024
@JoshuaKGoldberg JoshuaKGoldberg merged commit f6c719f into typescript-eslint:main Jul 21, 2024
65 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Development

Successfully merging this pull request may close these issues.

Bug: [no-unnecessary-condition] false positive on optional private field
3 participants