TypeError: Cannot read property 'type' of null (prop/variable of same name across components) #130
Closed
Description
opened on Jun 28, 2015
I've just tried upgrading to 2.6.0 from 2.5.2, if I put this minimal test case in a jsx file, it is now causing eslint to completely fail:
var TestComp1 = React.createClass({
propTypes: {
messageList: React.PropTypes.arrayOf(React.PropTypes.object).isRequired
},
render: function() {
return null;
}
});
var TestComp2 = React.createClass({
render: function() {
var messageList;
return null;
}
});
The error is:
/usr/local/lib/node_modules/eslint-plugin-react/lib/rules/prop-types.js:536
if (node.init.type !== 'ThisExpression' || node.id.type !== 'ObjectPatte
^
TypeError: Cannot read property 'type' of null
at EventEmitter.VariableDeclarator (/usr/local/lib/node_modules/eslint-plugin-react/lib/rules/prop-types.js:536:20)
at EventEmitter.emit (events.js:117:20)
at Controller.controller.traverse.enter (/usr/local/lib/node_modules/eslint/lib/eslint.js:724:25)
at Controller.__execute (/usr/local/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:397:31)
at Controller.traverse (/usr/local/lib/node_modules/eslint/node_modules/estraverse/estraverse.js:495:28)
at EventEmitter.module.exports.api.verify (/usr/local/lib/node_modules/eslint/lib/eslint.js:717:24)
at processText (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:201:27)
at processFile (/usr/local/lib/node_modules/eslint/lib/cli-engine.js:226:12)
at /usr/local/lib/node_modules/eslint/lib/cli-engine.js:322:26
at walk (/usr/local/lib/node_modules/eslint/lib/util/traverse.js:81:9)
Commenting out the var messageList;
is the only way of "fixing" it, I've tried some different variable names, but i seems to be the var that is triggering this.
Metadata
Assignees
Labels
No labels
Activity