Skip to content

Commit 78ddd46

Browse files
Rogdhamljharb
authored andcommitted
[Fix] no-adjacent-inline-elements: prevent crash on nullish children
Fixes #2620
1 parent 80f3826 commit 78ddd46

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/rules/no-adjacent-inline-elements.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ module.exports = {
8484
function validate(node, children) {
8585
let currentIsInline = false;
8686
let previousIsInline = false;
87+
if (!children) {
88+
return;
89+
}
8790
for (let i = 0; i < children.length; i++) {
8891
currentIsInline = isInline(children[i]);
8992
if (previousIsInline && currentIsInline) {

tests/lib/rules/no-adjacent-inline-elements.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ ruleTester.run('no-adjacent-inline-elements', rule, {
6969
code: '<div><a></a> some text <a></a></div>;',
7070
parserOptions
7171
},
72+
{
73+
code: 'React.createElement("div", null, "some text");',
74+
parserOptions
75+
},
7276
{
7377
code: ('React.createElement("div", undefined, [React.createElement("a"), ' +
7478
'" some text ", React.createElement("a")]);'),

0 commit comments

Comments
 (0)