Closed
Description
I've just updated to v6.10.0 and enabled void-dom-elements-no-children
.
It's crashing with this error:
TypeError: Cannot read property 'properties' of undefined
at EventEmitter.CallExpression ([...]/eslint-plugin-react/lib/rules/void-dom-elements-no-children.js:121:28)
[...]
It happens with this simple code:
document.createElement('img');
So here is the first problem:
- The rule thinks that every
.createElement(
is theReact.createElement
.
Now testing with the actual React
:
import React from 'react';
React.createElement('img');
The rule will crash too.
Second problem:
- The rule doesn't treat incomplete number of
createElement
's arguments (as while typingReact.createElement()
).
Activity
ljharb commentedon Feb 16, 2017
The first problem is intentional, as it looks for anything that could be a createElement call first, then refines.
The second is clearly a bug.
daltones commentedon Feb 16, 2017
Okay, but what is the point of the first problem being intentional when
document.createElement
could be a trivial false positive?Why can't it work same way as other rules that use
pragma
setting to verifyReact.(createClass|(Pure)?Component)
?daltones commentedon Feb 16, 2017
Oh, right, I missed something. Fixing the second problem would not warn about
document.createElement('img')
.But maybe first problem could turn into another issue to prevent some edge cases like
objectNothingAboutReact.createElement('img', {foo: bar}, 'baz')
.Thanks!
ljharb commentedon Feb 16, 2017
I believe that if the bug was fixed, only React
createElement
calls would be matched.jpickwell commentedon Mar 3, 2017
I just installed
master
in one of my projects, and I'm no longer getting theTypeError: Cannot read property 'properties' of undefined
error. So #1080 fixed that, which solved my problem. Thanks @jomasti.release(version): Release 1.1.0 [skip ci]
36 remaining items