Rule that checks if you remembered to call super.method()
See original GitHub issuePlease describe what the rule should do:
Tells you if you forgot to call super.method()
in a subclass. This is similar to the existing call-super
rule, but call-super
currently only applies to constructors.
Perhaps instead of making a new rule, call-super
could be extended to also include methods.
More often than not, I want to call a super method in a subclass method.
What category of rule is this? (place an “X” next to just one item)
[x] Warns about a potential error (problem) [ ] Suggests an alternate way of doing something (suggestion) [ ] Enforces code style (layout) [ ] Other (please specify:)
Provide 2-3 code examples that this rule will warn about:
class Foo {
method() {...}
}
class Bar extends Foo {
method() {
console.log(this.something)
// oops, forgot to call super.method()
}
}
Why should this rule be included in ESLint (instead of a plugin)?
Because, easier for people to turn it on.
Are you willing to submit a pull request to implement this rule?
I might be, time-allowing, but I haven’t done one before.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
I’m in favor of this if we can reliably know what methods are defined on the superclass. I’m not sure we can know that without type knowledge.
The
constructor
case is different, because we know all classes have a constructor.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.