Skip to content

Commit 09608cc

Browse files
committed
[Fix] no-adjacent-inline-elements: avoid a crash
Fixes #2575
1 parent b833535 commit 09608cc

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ module.exports = {
104104
if (!node.callee || node.callee.type !== 'MemberExpression' || node.callee.property.name !== 'createElement') {
105105
return;
106106
}
107-
if (node.arguments.length < 2) {
107+
if (node.arguments.length < 2 || !node.arguments[2]) {
108108
return;
109109
}
110110
const children = node.arguments[2].elements;

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,19 @@ ruleTester.run('no-adjacent-inline-elements', rule, {
6767
},
6868
{
6969
code: '<div><a></a> some text <a></a></div>;',
70-
errors: [{message: ERROR}],
7170
parserOptions
7271
},
7372
{
7473
code: ('React.createElement("div", undefined, [React.createElement("a"), ' +
7574
'" some text ", React.createElement("a")]);'),
76-
errors: [{message: ERROR}],
7775
parserOptions
7876
},
7977
{
8078
code: 'React.createElement("div", undefined, [React.createElement("a"), " ", React.createElement("a")]);',
81-
errors: [{message: ERROR}],
79+
parserOptions
80+
},
81+
{
82+
code: 'React.createElement(a, b);',
8283
parserOptions
8384
}
8485
],

0 commit comments

Comments
 (0)