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

no-danger-with-children crashes with undefined second argument. #1287

Closed
amanda-mitchell opened this issue Jul 5, 2017 · 1 comment
Closed

Comments

@amanda-mitchell
Copy link

This code works just fine with eslint:

React.createElement('div', null, 'content');

while this code (which Typescript encourages)

React.createElement('div', undefined, 'content')

Results in a crash with this stacktrace

Cannot read property 'node' of undefined
TypeError: Cannot read property 'node' of undefined
    at EventEmitter.CallExpression (/Users/dmitchell/Code/eslint-plugin-react-bug/node_modules/eslint-plugin-react/lib/rules/no-danger-with-children.js:100:45)
    at emitOne (events.js:96:13)
    at EventEmitter.emit (events.js:188:7)
    at NodeEventGenerator.applySelector (/Users/dmitchell/Code/eslint-plugin-react-bug/node_modules/eslint/lib/util/node-event-generator.js:265:26)
    at NodeEventGenerator.applySelectors (/Users/dmitchell/Code/eslint-plugin-react-bug/node_modules/eslint/lib/util/node-event-generator.js:294:22)
    at NodeEventGenerator.enterNode (/Users/dmitchell/Code/eslint-plugin-react-bug/node_modules/eslint/lib/util/node-event-generator.js:308:14)
    at CodePathAnalyzer.enterNode (/Users/dmitchell/Code/eslint-plugin-react-bug/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:602:23)
    at CommentEventGenerator.enterNode (/Users/dmitchell/Code/eslint-plugin-react-bug/node_modules/eslint/lib/util/comment-event-generator.js:98:23)
    at Traverser.enter (/Users/dmitchell/Code/eslint-plugin-react-bug/node_modules/eslint/lib/eslint.js:929:36)
    at Traverser.__execute (/Users/dmitchell/Code/eslint-plugin-react-bug/node_modules/estraverse/estraverse.js:397:31)

I've created a minimal repository that illustrates this issue at https://github.com/david-mitchell/eslint-plugin-react-bug

@ljharb
Copy link
Member

ljharb commented Jul 5, 2017

Thanks! In JS, it's idiomatic to use null over undefined, but both should work.

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

No branches or pull requests

2 participants