Skip to content

Commit

Permalink
Fix void-dom-elements-no-children crash on faulty createElement detec…
Browse files Browse the repository at this point in the history
…tion (fixes #1101)
  • Loading branch information
yannickcr committed May 9, 2017
1 parent f111e45 commit f7fb96b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/void-dom-elements-no-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ module.exports = {
return;
}

if (!utils.hasDestructuredReactCreateElement() && !utils.isReactCreateElement(node)) {
if (!utils.isReactCreateElement(node)) {
return;
}

Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/void-dom-elements-no-children.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ ruleTester.run('void-dom-elements-no-children', rule, {
'createElement("img")'
].join('\n'),
parser: 'babel-eslint'
}, {
code: [
'import React, {createElement, PureComponent} from \'react\';',
'class Button extends PureComponent {',
' handleClick = ev => {',
' ev.preventDefault();',
' }',
' render() {',
' return <div onClick={this.handleClick}>Hello</div>;',
' }',
'}'
].join('\n'),
parser: 'babel-eslint'
}
],
invalid: [
Expand Down

0 comments on commit f7fb96b

Please sign in to comment.