Skip to content

Commit 4a35536

Browse files
authored
Merge pull request #1226 from kokobeware/patch-1
Fix void-dom-elements-no-children crash
2 parents 690832f + 433cff8 commit 4a35536

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/rules/void-dom-elements-no-children.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ module.exports = {
103103
}
104104

105105
const args = node.arguments;
106+
107+
if (args.length < 1) {
108+
// React.createElement() should not crash linter
109+
return;
110+
}
111+
106112
const elementName = args[0].value;
107113

108114
if (!isVoidDOMElement(elementName)) {

tests/lib/rules/void-dom-elements-no-children.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ ruleTester.run('void-dom-elements-no-children', rule, {
5555
},
5656
{
5757
code: 'React.createElement("img");'
58+
}, {
59+
code: 'React.createElement();'
60+
}, {
61+
code: 'document.createElement();'
5862
}, {
5963
code: `
6064
const props = {};

0 commit comments

Comments
 (0)