question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add option to disable class-methods-use-this on inheritance

See original GitHub issue

What rule do you want to change? class-methods-use-this

Does this change cause the rule to produce more or fewer warnings? Fewer.

How will the change be implemented? (New option, new default behavior, etc.)? New option: disableOnInheritance.

Please provide some example code that this change will affect:

class ConfigService extends ConfigManager {
  provideConfigSpec() {
    return {
      ENV_VAR: 'test';
    };
  }
}

What does the rule currently do for this code? It throws the error because of the base class method provideConfigSpec that doesn’t use `this.

What will the rule do after it’s changed? Will disable the error when inheriting.

Are you willing to submit a pull request to implement this change? With some guidance, yes.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mdjermanoviccommented, Oct 8, 2019

Thanks for the info!

The enhancement is open for evaluation, it needs a champion and 3 other 👍 from the team to be accepted.

The option seems useful to avoid a long list in exceptMethods, but on the other hand looks like it would disable too much, i.e. limit the rule to check just base classes.

0reactions
eslint-deprecated[bot]commented, Nov 8, 2019

Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach accepted status after 21 days tend to never be accepted, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Disabling inherited method on derived class - java
You have a bad class heirarchy if you need to disable methods in child classes. Any subclass should be able to smoothly use...
Read more >
[Discussion] class-methods-use-this · Issue #263 - GitHub
This pattern is generally a sign that you are providing a bad public API for the class, and should either hide this method...
Read more >
class-methods-use-this - ESLint - Pluggable JavaScript Linter
This rule has two options: "exceptMethods" allows specified method names to be ignored with this rule. "enforceForClassFields" enforces that functions used as ...
Read more >
Overriding and Hiding Methods (The Java™ Tutorials ...
The ability of a subclass to override a method allows a class to inherit from a superclass whose behavior is "close enough" and...
Read more >
Replace Inheritance with Delegation - Refactoring.Guru
Problem: You have a subclass that uses only a portion of the methods of its superclass (or it's not possible to inherit superclass...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found