Closed
Description
It seems that the react/style-prop-object
rule crashes when the style
tag of a <div>
is empty with the following error:
CLI:
Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
at EventEmitter.JSXAttribute (C:\Temp\github\linter-eslint_GH702\node_modules\eslint-plugin-react\lib\rules\style-prop-object.js:70:21)
at emitOne (events.js:96:13)
at EventEmitter.emit (events.js:188:7)
at NodeEventGenerator.enterNode (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\util\node-event-generator.js:40:22)
at CodePathAnalyzer.enterNode (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\code-path-analysis\code-path-analyzer.js:608:23)
at CommentEventGenerator.enterNode (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\util\comment-event-generator.js:97:23)
at Controller.enter (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\eslint.js:918:36)
at Controller.__execute (C:\Temp\github\linter-eslint_GH702\node_modules\estraverse\estraverse.js:397:31)
at Controller.traverse (C:\Temp\github\linter-eslint_GH702\node_modules\estraverse\estraverse.js:501:28)
at Controller.Traverser.controller.traverse (C:\Temp\github\linter-eslint_GH702\node_modules\eslint\lib\util\traverser.js:36:33)
The trace is similar through the Node.js API.
You can reproduce this error with the following configuration:
.eslintrc.js:
module.exports = {
rules: {
'react/style-prop-object': 'error',
},
plugins: [
'react'
],
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 2016,
sourceType: 'module'
},
ecmaFeatures: {
jsx: true
},
};
package.json:
{
"private": true,
"license": "MIT",
"description": "Test package for linter-eslint #702",
"scripts": {
"lint": "eslint foo.jsx"
},
"dependencies": {
"eslint": "3.5.0",
"eslint-plugin-react": "6.2.1"
}
}
foo.jsx:
const foo = (
<div style></div>
);
For convenience here is a ZIP file containing the files use to reproduce this: linter-eslint_GH702.zip
Note: This was originally filed as AtomLinter/linter-eslint#702.