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 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)
…whitespace inside jsx attr curlies
Copy link
Collaborator

ljharb left a comment

Thanks! Can you please provide a regression test?

@dustinyoste

This comment has been minimized.

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

This comment has been minimized.

Copy link
Collaborator

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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

dustinyoste commented Oct 14, 2019

@ljharb regression test added!

@ljharb
ljharb approved these changes Oct 15, 2019
@ljharb ljharb merged commit 2a595fd into yannickcr:master Oct 15, 2019
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage decreased (-0.02%) to 97.534%
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.