[eslint-v2][constructors] disallow unnecessary constructors

This commit is contained in:
Harrison Shoff
2016-02-13 13:57:38 -08:00
committed by Jordan Harband
parent 5109c84926
commit 1cbc628c49
2 changed files with 27 additions and 0 deletions

View File

@@ -883,6 +883,30 @@ Other Style Guides
}
```
- [9.5](#9.5) <a name='9.5'></a> Classes have a default constructor if one is not specified. An empty constructor function or one that just delegates to a parent class is unnecessary.
```javascript
// bad
class Jedi {
constructor() {}
getName() {
return this.name;
}
}
// good
class Rey extends Jedi {
constructor(...args) {
super(...args);
}
getName() {
return this.name;
}
}
```
**[⬆ back to top](#table-of-contents)**