Skip to content

TypeError: Cannot read property 'parent' of null #1061

Closed
singapore/lint-condo
#262
@jakereps

Description

@jakereps

After updating using eslint-config-airbnb's instructions running my tests result in the following error (manually pathed to leave out other pieces of the test stack).

tracelog

[19:36] q2studio (master *) $ ./node_modules/eslint/bin/eslint.js app config --ext .js,.jsx --config config/eslint.yaml 
Cannot read property 'parent' of null
TypeError: Cannot read property 'parent' of null
    at EventEmitter.JSXOpeningElement (/Users/jakereps/Developer/caporasolab/q2studio/node_modules/eslint-plugin-react/lib/rules/jsx-indent.js:237:27)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.enterNode (/Users/jakereps/Developer/caporasolab/q2studio/node_modules/eslint/lib/util/node-event-generator.js:39:22)
    at CodePathAnalyzer.enterNode (/Users/jakereps/Developer/caporasolab/q2studio/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:607:23)
    at CommentEventGenerator.enterNode (/Users/jakereps/Developer/caporasolab/q2studio/node_modules/eslint/lib/util/comment-event-generator.js:98:23)
    at Controller.enter (/Users/jakereps/Developer/caporasolab/q2studio/node_modules/eslint/lib/eslint.js:928:36)
    at Controller.__execute (/Users/jakereps/Developer/caporasolab/q2studio/node_modules/estraverse/estraverse.js:397:31)
    at Controller.traverse (/Users/jakereps/Developer/caporasolab/q2studio/node_modules/estraverse/estraverse.js:501:28)
    at Controller.Traverser.controller.traverse (/Users/jakereps/Developer/caporasolab/q2studio/node_modules/eslint/lib/util/traverser.js:36:33)

package.json

// from
"eslint": "^2.6.0",
"eslint-config-airbnb": "^6.2.0",
"eslint-plugin-react": "^4.2.3",
// to
"eslint": "^3.15.0",
"eslint-config-airbnb": "^14.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0",

environment

[19:47] q2studio (master *) $ node -v
v7.2.0
[19:47] q2studio (master *) $ npm -v
3.10.9

I've had no luck searching for this issue, so resulted in submitting this issue. Any ideas? Dropping the --ext .js,.jsx works, but will only scan .js files.

Activity

ljharb

ljharb commented on Feb 5, 2017

@ljharb
Member

This is unrelated, but you want to use an npm run-script, or ./node_modules/.bin/eslint, not hardcode the path to the JS file.

This looks like there's some kind of code you might be using that eslint-plugin-react's jsx-indent rule is crashing on. If you open up that file (/Users/jakereps/Developer/caporasolab/q2studio/node_modules/eslint-plugin-react/lib/rules/jsx-indent.js, and on line 236, add console.log(context.getFileName()), and you check the last filename eslint reports before crashing, could you share that file's code?

jakereps

jakereps commented on Feb 5, 2017

@jakereps
Author

Oh for sure, just for this output I did the manual path. It was failing in the same manner using my npm t runs, which had unrelated output so I just ran it on its own.

That helped! Took a bit of playing around, but it turned out that having a multi-line ternary that didn't wrap each possibility on either side of the colon with parenthesis would fail. First one that was breaking it was this block, and once that was fixed it broke again once it got down to this block. All good now! Not sure if that is by design, as the previous version could handle it. If it is, this should be good to close, but otherwise I can rename it as a bug that ambiguous multiline ternary blocks break parsing.

Thanks @ljharb!

ljharb

ljharb commented on Feb 5, 2017

@ljharb
Member

Those links now show the same block - if you could provide the code that broke, it's definitely a bug we should be able to fix.

jakereps

jakereps commented on Feb 5, 2017

@jakereps
Author

Oops, got the second one updated.

gorangajic

gorangajic commented on Feb 8, 2017

@gorangajic

maybe it can be helpful, for me it's throwing when using template string

<Route
    path="/dashboard"
    render={props => <Redirect to={`/?login&next=${props.location.pathname}`} />}
/>
added a commit that references this issue on Feb 17, 2017
c6f4a5e

51 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @yannickcr@ljharb@gorangajic@jakereps

    Issue actions

      TypeError: Cannot read property 'parent' of null · Issue #1061 · jsx-eslint/eslint-plugin-react