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): [no-unused-private-class-members] private destructed class member is defined but used#11785
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
base:main
Are you sure you want to change the base?
Conversation
Thanks for the PR,@YuyaYoshioka! 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 commentedNov 24, 2025 • 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 project configuration. |
nx-cloudbot commentedNov 24, 2025 • 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.
View yourCI Pipeline Execution ↗ for commit83c15c3
☁️Nx Cloud last updated this comment at |
bradzacher left a comment
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.
quickly looking, this misses the following cases:
classFoo{property=1;caseOne(){letproperty;({ property}=this);}caseTwo(){constfoo=({ property}=this,)=>{}}}
Instead of declaring an intermediate class propertydestructuredThisProperties and then writing to it, could we instead do it more localised -- eg do thecountReference entirely withinVariableDeclarator instead of splitting it acrossVariableDeclarator andIdentifier?
codecovbot commentedNov 24, 2025 • 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 Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (82.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust thetarget coverage. Additional details and impacted files@@ Coverage Diff @@## main #11785 +/- ##==========================================+ Coverage 90.49% 90.53% +0.04%========================================== Files 522 523 +1 Lines 53360 53146 -214 Branches 8911 8853 -58 ==========================================- Hits 48286 48114 -172+ Misses 5059 5019 -40+ Partials 15 13 -2
Flags with carried forward coverage won't be shown.Click here to find out more.
🚀 New features to boost your workflow:
|
YuyaYoshioka commentedNov 24, 2025
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.
(testing)
Please also include a few tests around the long form destructuring assignment, i.e.
classFoo{privateprivateMember;method(){const{unused:privateNember}=this;}}
classFoo{privateprivateMember;method(){const{privateNember:used}=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.
Thank you!
I fixed at83c15c3

Uh oh!
There was an error while loading.Please reload this page.
PR Checklist
Overview
Solution
This PR adds support for tracking destructured properties from
thisand counts them as member access at the point of destructuring.Key insight: Destructuring from
thisis semantically equivalent to property access.const { a } = thisis equivalent toconst a = this.a(readsthis.a)({ a } = this)is equivalent toa = this.a(readsthis.a)Implementation Details
Added a shared
handleThisDestructuringmethod that:ObjectPatterndestructuring fromthiscountReferencefor each destructured property at the point of destructuringconst { a } = this({ a } = this)(param = { a } = this) => {}Handles all destructuring patterns:
const { a } = thisconst { a: x } = this(still counts as accessingthis.a)const { a, b } = thisconst { staticMember } = thisin static methodsTest Coverage
Added comprehensive test cases:
({ property } = this))const { a: x } = this)