From 605d9ac63e55d348d34059b453d1bd0f92c72960 Mon Sep 17 00:00:00 2001 From: Yannick Croissant Date: Wed, 10 May 2017 00:34:43 +0200 Subject: [PATCH] Fix void-dom-elements-no-children crash on faulty createElement detection (fixes #1101) --- lib/rules/void-dom-elements-no-children.js | 2 +- tests/lib/rules/void-dom-elements-no-children.js | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/rules/void-dom-elements-no-children.js b/lib/rules/void-dom-elements-no-children.js index 16db12f617..e2783b712d 100644 --- a/lib/rules/void-dom-elements-no-children.js +++ b/lib/rules/void-dom-elements-no-children.js @@ -98,7 +98,7 @@ module.exports = { return; } - if (!utils.hasDestructuredReactCreateElement() && !utils.isReactCreateElement(node)) { + if (!utils.isReactCreateElement(node)) { return; } diff --git a/tests/lib/rules/void-dom-elements-no-children.js b/tests/lib/rules/void-dom-elements-no-children.js index 6704f41ede..5fb6531a82 100644 --- a/tests/lib/rules/void-dom-elements-no-children.js +++ b/tests/lib/rules/void-dom-elements-no-children.js @@ -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
Hello
;', + ' }' + ].join('\n'), + parser: 'babel-eslint' } ], invalid: [