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 merge5 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 commitaa962d3
🔍 Latest deploy loghttps://app.netlify.com/projects/typescript-eslint/deploys/6928e01546e95e00081e4c1d
😎 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: 96 (🔴 down 2 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 commitaa962d3

CommandStatusDurationResult
nx test eslint-plugin --coverage=false✅ Succeeded5m 6sView ↗
nx run-many -t lint✅ Succeeded3m 19sView ↗
nx run-many -t typecheck✅ Succeeded1m 57sView ↗
nx test eslint-plugin-internal --coverage=false✅ Succeeded5sView ↗
nx test typescript-estree --coverage=false✅ Succeeded2sView ↗
nx run generate-configs✅ Succeeded8sView ↗
nx run types:build✅ Succeeded2sView ↗
nx run integration-tests:test✅ Succeeded4sView ↗
Additional runs (29)✅ Succeeded...View ↗

☁️Nx Cloud last updated this comment at2025-11-27 23:47:19 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 is76.00000% with12 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.47%. Comparing base (d622778) to head (aa962d3).

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

❌ Your patch check has failed because the patch coverage (76.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.47%   -0.02%==========================================  Files         522      522                Lines       53360    53409      +49       Branches     8911     8925      +14     ==========================================+ Hits        48286    48323      +37- Misses       5059     5071      +12  Partials       15       15
FlagCoverage Δ
unittest90.47% <76.00%> (-0.02%)⬇️

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.ts81.80% <76.00%> (-0.66%)⬇️
🚀 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
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@bradzacherbradzacherAwaiting requested review from bradzacher

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

2 participants

@YuyaYoshioka@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp