Skip to content

feat: add auto-accessor fields support to class-methods-use-this #19789

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

Merged
merged 3 commits into from
Jun 10, 2025

Conversation

sethamus
Copy link
Contributor

Prerequisites checklist

What is the purpose of this pull request? (put an "X" next to an item)

[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[x] Changes an existing rule (template)
[ ] Add autofix to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

Added support for TypeScript auto-accessor fields in the class-methods-use-this rule, aligning with the behavior of @typescript-eslint/class-methods-use-this. The rule now reports an error when an auto-accessor field (declared with the accessor keyword) doesn't use this in its initializer function.

Is there anything you'd like reviewers to focus on?

@sethamus sethamus requested a review from a team as a code owner May 29, 2025 03:46
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage May 29, 2025
Copy link

netlify bot commented May 29, 2025

Deploy Preview for docs-eslint ready!

Name Link
🔨 Latest commit d6bf23f
🔍 Latest deploy log https://app.netlify.com/projects/docs-eslint/deploys/684838c8db07d5000817216c
😎 Deploy Preview https://deploy-preview-19789--docs-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@eslint-github-bot eslint-github-bot bot added the feature This change adds a new feature to ESLint label May 29, 2025
@github-actions github-actions bot added the rule Relates to ESLint's core rules label May 29, 2025
@mdjermanovic mdjermanovic added the accepted There is consensus among the team that this change meets the criteria for inclusion label Jun 2, 2025
@mdjermanovic mdjermanovic moved this from Needs Triage to Implementing in Triage Jun 2, 2025
mdjermanovic
mdjermanovic previously approved these changes Jun 3, 2025
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Leaving it open for a second review.

@mdjermanovic mdjermanovic moved this from Implementing to Second Review Needed in Triage Jun 3, 2025
@nzakas
Copy link
Member

nzakas commented Jun 4, 2025

Code LGTM. Accessor properties are actually part of the decorators proposal, which is now in stage 3. I'm not sure if it makes sense to call this a TypeScript feature in the docs, especially given that the node type isn't TypeScript-specific (defined in ESTree).

While Espree doesn't yet support this syntax (because it's not stage 4) and TypeScript does, that will change soon. Maybe we should call this an "stage 3 syntax" rather than a TypeScript feature?

@nzakas
Copy link
Member

nzakas commented Jun 5, 2025

@sethamus please double-check your spam folder. I sent you an email earlier this week. 😄

@sethamus
Copy link
Contributor Author

@nzakas Yes, sorry, I replied.

Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@nzakas nzakas merged commit 677a283 into eslint:main Jun 10, 2025
31 checks passed
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Jun 10, 2025
@sethamus sethamus deleted the auto-accessor branch June 11, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion contributor pool feature This change adds a new feature to ESLint rule Relates to ESLint's core rules
Projects
Status: Complete
Development

Successfully merging this pull request may close these issues.

3 participants