Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'react/forbid-prop-types' makes eslint crash on PropTypes.instanceOf #249

Closed
rhysd opened this issue Oct 14, 2015 · 0 comments · Fixed by #253
Closed

'react/forbid-prop-types' makes eslint crash on PropTypes.instanceOf #249

rhysd opened this issue Oct 14, 2015 · 0 comments · Fixed by #253

Comments

@rhysd
Copy link
Contributor

rhysd commented Oct 14, 2015

I've made code as short as possible from my app.

import {PropTypes} from 'react';

class App {
}

App.propTypes = {
    elem: PropTypes.instanceOf(HTMLElement)
};

And my shortened .eslintrc is:

{
    "rules": {
        "react/forbid-prop-types": 1,
    },
    "env": {
        "es6": true,
        "node": true,
        "browser": true
    },
    "extends": "eslint:recommended",
    "ecmaFeatures": {
        "modules": true,
        "experimentalObjectRestSpread": true
    },
    "plugins": [
        "react"
    ]
}

Then executing eslint blah.js crashes eslint with below error:

/usr/local/lib/node_modules/eslint/lib/rules/no-undef.js:59
    return parent.type === "UnaryExpression" && parent.operator === "typeof";
                 ^
TypeError: Cannot read property 'type' of undefined
    at hasTypeOfOperator (/usr/local/lib/node_modules/eslint/lib/rules/no-undef.js:59:18)
    at /usr/local/lib/node_modules/eslint/lib/rules/no-undef.js:84:21
    at Array.forEach (native)
    at EventEmitter.Program:exit (/usr/local/lib/node_modules/eslint/lib/rules/no-undef.js:80:33)
    at EventEmitter.emit (events.js:129:20)
    at NodeEventGenerator.leaveNode (/usr/local/lib/node_modules/eslint/lib/util/node-event-generator.js:51:22)
    at CommentEventGenerator.leaveNode (/usr/local/lib/node_modules/eslint/lib/util/comment-event-generator.js:111:23)
    at Controller.controller.traverse.leave (/usr/local/lib/node_modules/eslint/lib/eslint.js:785:36)
    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:485:28)

When I remove "react/forbid-prop-types" from .eslintrc, this error doesn't occur.

  • Versions
    • Node v0.12.4
    • eslint 1.6.0
    • eslint-plugin-react 3.5.1
rhysd added a commit to rhysd/eslint-plugin-react that referenced this issue Oct 16, 2015
rhysd added a commit to rhysd/eslint-plugin-react that referenced this issue Oct 16, 2015
yannickcr added a commit that referenced this issue Oct 18, 2015
Fix forbid-prop-types to do not modify AST directly (fixes #249)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant