-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
Please describe what the rule should do:
Forbid return statements in constructors.
What category of rule is this? (place an "X" next to just one item)
[x] Suggests an alternate way of doing something (suggestion)
Provide 2-3 code examples that this rule will warn about:
class Foo {
constructor () {
return Math;
}
}
class Goo {
constructor () {
return this;
}
}
Why should this rule be included in ESLint (instead of a plugin)?
In Javascript return value in constructor is allowed, and the return value is the evaluated value when the class is new-ed. A class created with pattern behaves very differently from a normal class in the OOP paradigm, for example, in that every new instance should be a separate object. There seemed to be no practical usage of this pattern. Forbidding this pattern prevents mistake resulting from unfamiliarity with the language or copy-paste error.
Are you willing to submit a pull request to implement this rule?
Possibly.