Skip to content

Commit 7fd3375

Browse files
committed
Fix class properties retrieval in prefer-stateless-function (fixes jsx-eslint#499)
1 parent f24d0cb commit 7fd3375

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/rules/prefer-stateless-function.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ module.exports = Components.detect(function(context, components, utils) {
4343
*/
4444
function getComponentProperties(node) {
4545
switch (node.type) {
46+
case 'ClassExpression':
4647
case 'ClassDeclaration':
4748
return node.body.body;
4849
case 'ObjectExpression':

tests/lib/rules/prefer-stateless-function.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,18 @@ ruleTester.run('prefer-stateless-function', rule, {
179179
'});'
180180
].join('\n'),
181181
parserOptions: parserOptions
182+
}, {
183+
code: [
184+
'export default (Component) => (',
185+
' class Test extends React.Component {',
186+
' componentDidMount() {}',
187+
' render() {',
188+
' return <Component />;',
189+
' }',
190+
' }',
191+
');'
192+
].join('\n'),
193+
parser: 'babel-eslint'
182194
}
183195
],
184196

0 commit comments

Comments
 (0)