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 605d9ac
Show file tree
Hide file tree
Showing 2 changed files with 13 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
12 changes: 12 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,18 @@ 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 605d9ac

Please sign in to comment.