Skip to content

TypeError: Cannot read property 'type' of null in jsx-no-bind rule #1548

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

Closed
jluxenberg-scoot opened this issue Nov 19, 2017 · 3 comments
Closed

Comments

@jluxenberg-scoot
Copy link

The following file seems to cause the jsx-no-bind rule to crash:

let foo;

He's a full set of reproduction steps. See the attached package.json and yarn.lock files for specific versions (2017-11-18_eslint-bug-jluxenberg.zip):

jareds-mbp:~ jared$ mkdir eslint-bug
jareds-mbp:~ jared$ cd eslint-bug/
jareds-mbp:eslint-bug jared$ yarn init .
...
jareds-mbp:eslint-bug jared$ ls
package.json
jareds-mbp:eslint-bug jared$ yarn add -D eslint eslint-plugin-react
jareds-mbp:eslint-bug jared$ cat > test.js
let foo;
jareds-mbp:eslint-bug jared$ cat > .eslintrc.json
{
  "extends": [
    "airbnb",
    "prettier"
  ],
  "rules": {
    "react/jsx-curly-spacing": [2, { "when": "always" }]
  }
}
jareds-mbp:eslint-bug jared$ yarn add -D eslint-config-airbnb eslint-config-prettier eslint-plugin-jsx-a11y eslint-plugin-import
jareds-mbp:eslint-bug jared$ node_modules/.bin/eslint test.js
Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
    at getNodeViolationType (/Users/jared/eslint-bug/node_modules/eslint-plugin-react/lib/rules/jsx-no-bind.js:72:29)
    at VariableDeclarator (/Users/jared/eslint-bug/node_modules/eslint-plugin-react/lib/rules/jsx-no-bind.js:139:39)
    at listeners.(anonymous function).forEach.listener (/Users/jared/eslint-bug/node_modules/eslint/lib/util/safe-emitter.js:47:58)
    at Array.forEach (<anonymous>)
    at Object.emit (/Users/jared/eslint-bug/node_modules/eslint/lib/util/safe-emitter.js:47:38)
    at NodeEventGenerator.applySelector (/Users/jared/eslint-bug/node_modules/eslint/lib/util/node-event-generator.js:251:26)
    at NodeEventGenerator.applySelectors (/Users/jared/eslint-bug/node_modules/eslint/lib/util/node-event-generator.js:280:22)
    at NodeEventGenerator.enterNode (/Users/jared/eslint-bug/node_modules/eslint/lib/util/node-event-generator.js:294:14)
    at CodePathAnalyzer.enterNode (/Users/jared/eslint-bug/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
    at Traverser.enter (/Users/jared/eslint-bug/node_modules/eslint/lib/linter.js:959:32)
@jseminck
Copy link
Contributor

This is already reported ( #1543 ) and a fix has been merged ( #1544 ).

Hopefully a v7.5.1 will go out later today!

Thanks for understanding 👍

@jluxenberg-scoot
Copy link
Author

Hah! Just tried to reproduce on master and couldn't (was going to open a PR). Thanks for your response!

@ljharb
Copy link
Member

ljharb commented Nov 19, 2017

Duplicate of #1543.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants