diff --git a/README.md b/README.md index 32c966ce..952b135a 100644 --- a/README.md +++ b/README.md @@ -883,6 +883,30 @@ Other Style Guides } ``` + - [9.5](#9.5) 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)** diff --git a/packages/eslint-config-airbnb/rules/es6.js b/packages/eslint-config-airbnb/rules/es6.js index 08b58891..f55d6b9b 100644 --- a/packages/eslint-config-airbnb/rules/es6.js +++ b/packages/eslint-config-airbnb/rules/es6.js @@ -34,6 +34,9 @@ module.exports = { 'no-this-before-super': 0, // require let or const instead of var 'no-var': 2, + // disallow unnecessary constructor + // http://eslint.org/docs/rules/no-useless-constructor + 'no-useless-constructor': 2, // require method and property shorthand syntax for object literals // https://github.com/eslint/eslint/blob/master/docs/rules/object-shorthand.md 'object-shorthand': [2, 'always'],