Skip to content

Commit

Permalink
Fix A Crash
Browse files Browse the repository at this point in the history
In standard (latest `master`) when I enable `experimentalObjectRestSpread` in eslint. We run into this issue when using eslint 1.1.0 and eslint-plugin-react 3.2.1.


```js
~/dev/standard (master) $ node bin/cmd.js test.js
standard: Unexpected linter output:

TypeError: Cannot read property 'type' of undefined
    at isPropTypesDeclaration (/Users/jamuferguson/dev/standard/node_modules/eslint-plugin-react/lib/rules/prop-types.js:49:13)
    at /Users/jamuferguson/dev/standard/node_modules/eslint-plugin-react/lib/rules/prop-types.js:589:14
    at Array.forEach (native)
    at EventEmitter.ObjectExpression (/Users/jamuferguson/dev/standard/node_modules/eslint-plugin-react/lib/rules/prop-types.js:588:23)
    at EventEmitter.emit (events.js:129:20)
    at Controller.controller.traverse.enter (/Users/jamuferguson/dev/standard/node_modules/eslint/lib/eslint.js:824:25)
    at Controller.__execute (/Users/jamuferguson/dev/standard/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/Users/jamuferguson/dev/standard/node_modules/estraverse/estraverse.js:495:28)
    at EventEmitter.module.exports.api.verify (/Users/jamuferguson/dev/standard/node_modules/eslint/lib/eslint.js:817:24)
    at processText (/Users/jamuferguson/dev/standard/node_modules/eslint/lib/cli-engine.js:199:27)
```

By all means tell me to file an issue first or whatever the correct approach is :)
  • Loading branch information
xjamundx committed Aug 11, 2015
1 parent 13fa214 commit 87a42c9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module.exports = function(context) {

// Special case for class properties
// (babel-eslint does not expose property name so we have to rely on tokens)
if (node.type === 'ClassProperty') {
if (node && node.type === 'ClassProperty') {
var tokens = context.getFirstTokens(node, 2);
if (
tokens[0].value === 'propTypes' ||
Expand Down

0 comments on commit 87a42c9

Please sign in to comment.