diff --git a/lib/rules/prefer-stateless-function.js b/lib/rules/prefer-stateless-function.js index ee7e6a9897..e128b2d6bf 100644 --- a/lib/rules/prefer-stateless-function.js +++ b/lib/rules/prefer-stateless-function.js @@ -186,6 +186,7 @@ module.exports = { const contextTypes = name === 'contextTypes'; const defaultProps = name === 'defaultProps'; const isUselessConstructor = property.kind === 'constructor' && + !!property.value.body && isRedundantSuperCall(property.value.body.body, property.value.params); const isRender = name === 'render'; return !isDisplayName && !isPropTypes && !contextTypes && !defaultProps && !isUselessConstructor && !isRender; diff --git a/tests/lib/rules/prefer-stateless-function.js b/tests/lib/rules/prefer-stateless-function.js index e6a151f57b..7f7e41bb06 100644 --- a/tests/lib/rules/prefer-stateless-function.js +++ b/tests/lib/rules/prefer-stateless-function.js @@ -157,6 +157,18 @@ ruleTester.run('prefer-stateless-function', rule, { } } ` + }, { + // Issue 2187 + code: ` + class Foo extends React.Component { + constructor(props) + + render() { + return