File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ function isJSXElementOrReactCreateElement ( node ) {
2+ if ( node . type === 'JSXElement' ) {
3+ return true ;
4+ }
5+ if ( node . callee && node . callee . object && node . callee . object . name === 'React' && node . callee . property && node . callee . property . name === 'createElement' ) {
6+ return true ;
7+ }
8+
9+ if ( node . callee && node . callee . name === 'createElement' ) {
10+ return true ;
11+ }
12+ return false ;
13+ }
14+
115function isReturningJSXElement ( path ) {
216 /**
317 * Early exit for ArrowFunctionExpressions, there is no ReturnStatement node.
418 */
5- if ( path . node . init && path . node . init . body && path . node . init . body . type === 'JSXElement' ) {
19+ if ( path . node . init && path . node . init . body && isJSXElementOrReactCreateElement ( path . node . init . body ) ) {
620 return true ;
721 }
822
@@ -17,16 +31,14 @@ function isReturningJSXElement(path) {
1731
1832 const argument = path2 . get ( 'argument' ) ;
1933
20- if ( argument . node . type === 'JSXElement' ) {
34+ if ( isJSXElementOrReactCreateElement ( argument . node ) ) {
2135 visited = true ;
22- } else if ( argument . node . type === 'CallExpression' ) {
23-
24- const { node } = argument . get ( 'callee' ) ;
25- if ( node . name === 'createElement' || node . object . name === 'React' && node . property . name === 'createElement' ) {
26- visited = true ;
27- }
36+ return ;
37+ }
2838
29- const binding = path . scope . getBinding ( node . name ) ;
39+ if ( argument . node . type === 'CallExpression' ) {
40+ const name = argument . get ( 'callee' ) . node . name ;
41+ const binding = path . scope . getBinding ( name ) ;
3042
3143 if ( ! binding ) {
3244 return ;
@@ -36,7 +48,7 @@ function isReturningJSXElement(path) {
3648 visited = true ;
3749 }
3850 }
39- }
51+ } ,
4052 } ) ;
4153
4254 return visited ;
You can’t perform that action at this time.
0 commit comments