Skip to content

Rule Change: [class-methods-use-this] Add ignoreOverrideMethods option #19506

@JoshuaKGoldberg

Description

@JoshuaKGoldberg

What rule do you want to change?

class-methods-use-this

What change do you want to make?

Generate fewer warnings

How do you think the change should be implemented?

A new option

Example code

abstract class Base {
  abstract method(): void;
  abstract property: () => void;
}

class Derived extends Base {
  override method() {}
  override property = () => {};
}

What does the rule currently do for this code?

Reports on the method and property for not using this.

This is sub-optimal because some projects prefer organizing code in class extensions even when derived methods don't always need to use this.

What will the rule do after it's changed?

If the user has enabled a new ignoreOverrideMethods option, ignore methods and method-likes that are declared with the override keyword. No reports would be generated for that code.

Participation

  • I am willing to submit a pull request to implement this change.

Additional comments

Following #19498, this feature request corresponds to the existing typescript-eslint rule option: https://typescript-eslint.io/rules/class-methods-use-this/#ignoreoverridemethods

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionenhancementThis change enhances an existing feature of ESLintruleRelates to ESLint's core rules

    Type

    No type

    Projects

    Status

    Complete

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions