Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Proposal: no-useless-constructor #4785
Rule Proposal: Empty or Useless ES6 Constructor
When the rules will warn. Include a description as well as sample code.
In ES6 classes both of the above forms are redundant, as they are the default constructor if none is specified. As such they can be considered Dead Code as they aren't doing anything.
Many times if code is here it is because implied constructors are not known well by the developer or they are left-overs after some other relevant non-redundant code has been removed.
This proposal is to provide and eslint rule to warn against this type of redundant dead code so it can be removed. This rule is similar to empty method, unused method types of eslint rules.
Whether the rule prevents an error or is stylistic.
It is mostly stylistic, but it could prevent an error if the developer feels that this code is doing something different than the default constructor.
Why the rule should be in the core instead of creating a custom rule.
This seems pretty core to removing dead or redundant code.
Are you willing to create the rule yourself?
Not at this time no.
I'm sorry, I don't understand what you're requesting. Please see our guide for proposing new rules: http://eslint.org/docs/1.10.3/developer-guide/contributing/new-rules