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

Fix failures of jsx-max-depth on empty nodes #1720

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

j-martyn
Copy link

@j-martyn j-martyn commented Mar 12, 2018

On some my code (didn't check what code exactly) I got this:

Cannot read property 'type' of null
TypeError: Cannot read property 'type' of null
    at find (/path/to/package/node_modules/eslint-plugin-react/lib/rules/jsx-max-depth.js:93:27)
    at findJSXElement (/path/to/package/node_modules/eslint-plugin-react/lib/rules/jsx-max-depth.js:102:49)
    at JSXExpressionContainer (/path/to/package/node_modules/eslint-plugin-react/lib/rules/jsx-max-depth.js:137:25)

So, for now, I just have fixed it. No tests have been changed as I didn't investigate it.

Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

It's pretty important to find the code this broke on, so that we can add a regression test.

@@ -90,7 +90,8 @@ module.exports = {

return isJSXElement(writeExpr)
&& writeExpr
|| writeExpr.type === 'Identifier'
|| writeExpr
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably this whole chain should be rewritten for clarity; at the least, let's use parens so as to not mix && and || :-)

@ljharb ljharb added the bug label Mar 13, 2018
@ferhatelmas
Copy link
Contributor

@j-martyn @ljharb Any ETA ? I see this crash too.

FYI, it happens on files with jsx-control-statements.

@ljharb
Copy link
Member

ljharb commented Jun 4, 2018

@ferhatelmas if you could provide a failing test case (on a branch in your fork), and link it here, i'll add it to the PR and we can get this in.

@ljharb
Copy link
Member

ljharb commented Dec 27, 2018

cc @alexzherdev if you're interested in taking a look at this one, i'm happy to add any commits you like to this PR branch :-) (cc #1824)

@alexzherdev
Copy link
Contributor

I'll see if I can reproduce this 👍

@ljharb
Copy link
Member

ljharb commented May 9, 2020

ping @alexzherdev, any progress?

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

Successfully merging this pull request may close these issues.

None yet

4 participants