Skip to content

fix: apply ignoreClassesWithImplements to class expressions#21069

Merged
fasttime merged 1 commit into
mainfrom
fix/class-methods-use-this-class-expression-implements
Jul 10, 2026
Merged

fix: apply ignoreClassesWithImplements to class expressions#21069
fasttime merged 1 commit into
mainfrom
fix/class-methods-use-this-class-expression-implements

Conversation

@Pixel998

@Pixel998 Pixel998 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

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

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

Tell us about your environment (npx eslint --env-info):

  • Node version: v24.16.0
  • npm version: v11.13.0
  • Local ESLint version: v10.6.0
  • Global ESLint version: no
  • Operating System: windows

What parser are you using (place an "X" next to just one item)?

[x] Default (Espree)
[ ] @typescript-eslint/parser
[ ] @babel/eslint-parser
[ ] vue-eslint-parser
[ ] @angular-eslint/template-parser
[ ] Other

Please show your full configuration:

Configuration
export default [{}];

What did you do? Please include the actual source code causing the issue.

/* eslint class-methods-use-this: ["error", { "ignoreClassesWithImplements": "all" }] */

interface Base { method(): void; };

const Foo = class implements Base { method() {} };
class Bar implements Base { method() {} };

Playground

What did you expect to happen?

No report. Foo implements Base, so with ignoreClassesWithImplements: "all" the method should be ignored, exactly as it is for the equivalent class declaration.

What actually happened? Please include the actual, raw output from ESLint.

Expected 'this' to be used by class method 'method'.

What changes did you make? (Give an overview)

Updated the hasImplements helper in class-methods-use-this to also recognize ClassExpression, so the ignoreClassesWithImplements option applies to class expressions with an implements clause, matching class declarations.

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

@Pixel998
Pixel998 requested a review from a team as a code owner July 8, 2026 21:03
@eslint-github-bot eslint-github-bot Bot added the bug ESLint is working incorrectly label Jul 8, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Jul 8, 2026
@netlify

netlify Bot commented Jul 8, 2026

Copy link
Copy Markdown

Deploy Preview for docs-eslint canceled.

Name Link
🔨 Latest commit 1deab02
🔍 Latest deploy log https://app.netlify.com/projects/docs-eslint/deploys/6a4ebb294360890008482c10

@github-actions github-actions Bot added the rule Relates to ESLint's core rules label Jul 8, 2026
@fasttime fasttime moved this from Needs Triage to Implementing in Triage Jul 10, 2026
@fasttime fasttime added the accepted There is consensus among the team that this change meets the criteria for inclusion label Jul 10, 2026

@fasttime fasttime left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@fasttime
fasttime merged commit 3e7bf15 into main Jul 10, 2026
42 checks passed
@fasttime
fasttime deleted the fix/class-methods-use-this-class-expression-implements branch July 10, 2026 18:25
@github-project-automation github-project-automation Bot moved this from Implementing to Complete in Triage Jul 10, 2026
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 bug ESLint is working incorrectly rule Relates to ESLint's core rules

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

2 participants