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-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

Open
YuyaYoshioka wants to merge6 commits intotypescript-eslint:main
base:main
Choose a base branch
Loading
fromYuyaYoshioka:issue-11771

Conversation

@YuyaYoshioka
Copy link
Contributor

@YuyaYoshiokaYuyaYoshioka commentedNov 24, 2025
edited
Loading

PR Checklist

Overview

Solution

This PR adds support for tracking destructured properties fromthis and counts them as member access at the point of destructuring.

Key insight: Destructuring fromthis is semantically equivalent to property access.

  • const { a } = this is equivalent toconst a = this.a (readsthis.a)
  • ({ a } = this) is equivalent toa = this.a (readsthis.a)

Implementation Details

Added a sharedhandleThisDestructuring method that:

  1. DetectsObjectPattern destructuring fromthis
  2. Directly callscountReference for each destructured property at the point of destructuring
  3. Supports multiple destructuring contexts:
    • Variable declarations:const { a } = this
    • Assignment expressions:({ a } = this)
    • Function parameters:(param = { a } = this) => {}

Handles all destructuring patterns:

  • ✅ Shorthand:const { a } = this
  • ✅ Renamed:const { a: x } = this (still counts as accessingthis.a)
  • ✅ Multiple properties:const { a, b } = this
  • ✅ Static members:const { staticMember } = this in static methods

Test Coverage

Added comprehensive test cases:

@typescript-eslint
Copy link
Contributor

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.

@netlify
Copy link

netlifybot commentedNov 24, 2025
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit83c15c3
🔍 Latest deploy loghttps://app.netlify.com/projects/typescript-eslint/deploys/692e3be20e39c1000800146f
😎 Deploy Previewhttps://deploy-preview-11785--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: 97 (🔴 down 1 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 92 (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 project configuration.

@nx-cloud
Copy link

nx-cloudbot commentedNov 24, 2025
edited
Loading

View yourCI Pipeline Execution ↗ for commit83c15c3

CommandStatusDurationResult
nx test eslint-plugin --coverage=false✅ Succeeded5m 9sView ↗
nx run-many -t lint✅ Succeeded3m 26sView ↗
nx run-many -t typecheck✅ Succeeded2m 1sView ↗
nx test eslint-plugin-internal --coverage=false✅ Succeeded4sView ↗
nx run integration-tests:test✅ Succeeded6sView ↗
nx test typescript-estree --coverage=false✅ Succeeded2sView ↗
nx run types:build✅ Succeeded2sView ↗
nx run generate-configs✅ Succeeded6sView ↗
Additional runs (29)✅ Succeeded...View ↗

☁️Nx Cloud last updated this comment at2025-12-02 01:19:11 UTC

@YuyaYoshiokaYuyaYoshioka changed the titlefix private destructed class member casefix(eslint-plugin): [no-unused-private-class-members] Private destructed class member is defined but usedNov 24, 2025
Copy link
Member

@bradzacherbradzacher left a 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?

YuyaYoshioka reacted with heart emojiYuyaYoshioka reacted with eyes emoji
@codecov
Copy link

codecovbot commentedNov 24, 2025
edited
Loading

Codecov Report

❌ Patch coverage is82.00000% with9 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.53%. Comparing base (d622778) to head (83c15c3).
⚠️ Report is 8 commits behind head on main.

Files with missing linesPatch %Lines
...rc/util/class-scope-analyzer/classScopeAnalyzer.ts82.00%9 Missing⚠️

❌ 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
FlagCoverage Δ
unittest90.53% <82.00%> (+0.04%)⬆️

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

Files with missing linesCoverage Δ
...rc/util/class-scope-analyzer/classScopeAnalyzer.ts82.37% <82.00%> (-0.08%)⬇️

... and10 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@YuyaYoshioka
Copy link
ContributorAuthor

Thank you for your review!
I fixedf7c6afec5c4417

@YuyaYoshiokaYuyaYoshioka changed the titlefix(eslint-plugin): [no-unused-private-class-members] Private destructed class member is defined but usedfix(eslint-plugin): [no-unused-private-class-members] private destructed class member is defined but usedNov 24, 2025

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;}}

Copy link
ContributorAuthor

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@bradzacherbradzacherAwaiting requested review from bradzacher

@kirkwaiblingerkirkwaiblingerAwaiting requested review from kirkwaiblinger

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Bug: [@typescript-eslint/no-unused-private-class-members] Private destructed class member is defined but used

3 participants

@YuyaYoshioka@bradzacher@kirkwaiblinger

[8]ページ先頭

©2009-2025 Movatter.jp