no-danger-with-children crashes with undefined
second argument. #1287
Closed
Description
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