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 filter of undefined #2460

Merged
merged 1 commit into from Oct 15, 2019
Merged

Fix filter of undefined #2460

merged 1 commit into from Oct 15, 2019

Conversation

dustinyoste
Copy link
Contributor

@dustinyoste dustinyoste commented Oct 11, 2019

Cause of error:

<View 
  prop={ ' ' }
/>
TypeError: Cannot read property 'filter' of undefined
Occurred while linting <file>.js:346
    at hasAdjacentJsx (.../node_modules/eslint-plugin-react/lib/rules/jsx-curly-brace-presence.js:244:59)
    at shouldCheckForUnnecessaryCurly (.../node_modules/eslint-plugin-react/lib/rules/jsx-curly-brace-presence.js:272:49)
    at JSXExpressionContainer (.../node_modules/eslint-plugin-react/lib/rules/jsx-curly-brace-presence.js:304:13)
    at listeners.(anonymous function).forEach.listener (.../node_modules/eslint/lib/linter/safe-emitter.js:45:58)
    at Array.forEach (<anonymous>)
    at Object.emit (.../node_modules/eslint/lib/linter/safe-emitter.js:45:38)
    at NodeEventGenerator.applySelector (.../node_modules/eslint/lib/linter/node-event-generator.js:253:26)
    at NodeEventGenerator.applySelectors (.../node_modules/eslint/lib/linter/node-event-generator.js:282:22)
    at NodeEventGenerator.enterNode (.../node_modules/eslint/lib/linter/node-event-generator.js:296:14)
    at CodePathAnalyzer.enterNode (.../node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js:646:23)

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! Can you please provide a regression test?

@dustinyoste
Copy link
Contributor Author

dustinyoste commented Oct 12, 2019

@ljharb I'm having trouble reproducing the crash via a test rule 😅
I have my project set up with these rules:
"react/jsx-curly-brace-presence": [1, { "children": "never", "props": "always" }],

I'm not actually sure why children is undefined in my fix tbh.

@ljharb
Copy link
Member

ljharb commented Oct 12, 2019

Perhaps something in your eslint config? Are you using a parser that's not the default, like babel-eslint?

@dustinyoste
Copy link
Contributor Author

dustinyoste commented Oct 13, 2019

@ljharb yeah, I'm using babel-eslint as the parser

    'extends': 'airbnb',
    'parser': 'babel-eslint',
    'env': {
        'jest': true,
    },

I'll dig around and see if the problem is rooted there.

@dustinyoste
Copy link
Contributor Author

@ljharb regression test added!

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

Successfully merging this pull request may close these issues.

None yet

2 participants