Skip to content

Commit

Permalink
Check for createElement being called from React
Browse files Browse the repository at this point in the history
Fixes #996. This will prevent document.createElement triggering a
false positive for react/display-name.
  • Loading branch information
jomasti committed Jan 2, 2017
1 parent 682ae68 commit c6264d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/util/Components.js
Expand Up @@ -258,6 +258,8 @@ function componentRule(rule, context) {
var returnsReactCreateElement =
node[property] &&
node[property].callee &&
node[property].callee.object &&
node[property].callee.object.name === 'React' &&
node[property].callee.property &&
node[property].callee.property.name === 'createElement'
;
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/display-name.js
Expand Up @@ -378,6 +378,13 @@ ruleTester.run('display-name', rule, {
')'
].join('\n'),
parser: 'babel-eslint'
}, {
code: [
'module.exports = {',
' createElement: tagName => document.createElement(tagName)',
'};'
].join('\n'),
parser: 'babel-eslint'
}],

invalid: [{
Expand Down

0 comments on commit c6264d0

Please sign in to comment.