Skip to content

Commit

Permalink
Fix display-name false negative on es6-style method in React.createCl…
Browse files Browse the repository at this point in the history
…ass (fixes #852)
  • Loading branch information
yannickcr committed Sep 21, 2016
1 parent 8ae52a9 commit 644b2ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/display-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ module.exports = {
var namedFunctionExpression = (
(node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression') &&
node.parent &&
(node.parent.type === 'VariableDeclarator' || node.parent.method === true)
(node.parent.type === 'VariableDeclarator' || node.parent.method === true) &&
(!node.parent.parent || !utils.isES5Component(node.parent.parent))
);

if (
Expand Down
12 changes: 12 additions & 0 deletions tests/lib/rules/display-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,18 @@ ruleTester.run('display-name', rule, {
errors: [{
message: 'Component definition is missing display name'
}]
}, {
code: [
'module.exports = React.createClass({',
' render() {',
' return <div>Hello {this.props.name}</div>;',
' }',
'});'
].join('\n'),
parser: 'babel-eslint',
errors: [{
message: 'Component definition is missing display name'
}]
}, {
code: [
'var Hello = React.createClass({',
Expand Down

0 comments on commit 644b2ee

Please sign in to comment.