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.

Rule that checks if you remembered to call super.method()

See original GitHub issue

Please 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() {
    // 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:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

platinumazurecommented, Jul 9, 2019

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.

eslint-deprecated[bot]commented, Aug 9, 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

Calling super super class method - java - Stack Overflow
A's foo() can be called from C using only if B doesn't override A's foo(). – YoK. Aug 11, 2010 at 8:02....
Read more >
Super Keyword in Java - GeeksforGeeks
The super keyword in java is a reference variable that is used to refer to parent class objects. An understanding of Inheritance and ......
Read more >
Annotation/Keyword To Automatically Call Super in Override ...
Introduction. This proposal outlines a solution to a common problem: overriding a method but forgetting to call its super method first.
Read more >
Super keyword in java with example - BeginnersBook
The super keyword in java refers to the objects of immediate parent class. In this guide we will see the use of super...
Read more >
The “call super” anti-pattern - Otaku – Cedric's blog
In cases where I override setUp() and tearDown() and I anticipate people extending my own test, I often make the methods final then...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found