@@ -79,7 +79,9 @@ export function useComponentCollector(
7979 } ;
8080 const onFunctionExit = ( ) => {
8181 const { key, node, isComponent } = functionEntries . at ( - 1 ) ?? { } ;
82- if ( ! key || ! node || ! isComponent ) return functionEntries . pop ( ) ;
82+ if ( ! key || ! node || ! isComponent ) {
83+ return functionEntries . pop ( ) ;
84+ }
8385 const shouldDrop = AST . getNestedReturnStatements ( node . body )
8486 . slice ( )
8587 . reverse ( )
@@ -88,7 +90,9 @@ export function useComponentCollector(
8890 && r . argument !== null
8991 && ! JSX . isJSXValue ( r . argument , jsxCtx , hint ) ;
9092 } ) ;
91- if ( shouldDrop ) components . delete ( key ) ;
93+ if ( shouldDrop ) {
94+ components . delete ( key ) ;
95+ }
9296 return functionEntries . pop ( ) ;
9397 } ;
9498
@@ -107,13 +111,17 @@ export function useComponentCollector(
107111 ":function[type]:exit" : onFunctionExit ,
108112 "ArrowFunctionExpression[type][body.type!='BlockStatement']" ( ) {
109113 const mbEntry = getCurrentFunction ( ) ;
110- if ( O . isNone ( mbEntry ) ) return ;
114+ if ( O . isNone ( mbEntry ) ) {
115+ return ;
116+ }
111117 const entry = mbEntry . value ;
112118 const { body } = entry . node ;
113119 const isComponent = hasNoneOrValidComponentName ( entry . node , context )
114120 && JSX . isJSXValue ( body , jsxCtx , hint )
115121 && hasValidHierarchy ( entry . node , context , hint ) ;
116- if ( ! isComponent ) return ;
122+ if ( ! isComponent ) {
123+ return ;
124+ }
117125 const initPath = AST . getFunctionInitPath ( entry . node ) ;
118126 const id = getFunctionComponentIdentifier ( entry . node , context ) ;
119127 const name = O . flatMapNullable ( id , getComponentNameFromIdentifier ) ;
@@ -138,33 +146,45 @@ export function useComponentCollector(
138146 const mbComponentName = match ( left . object )
139147 . with ( { type : T . Identifier } , n => O . some ( n . name ) )
140148 . otherwise ( O . none ) ;
141- if ( O . isNone ( mbComponentName ) ) return ;
149+ if ( O . isNone ( mbComponentName ) ) {
150+ return ;
151+ }
142152 const componentName = mbComponentName . value ;
143153 const component = Array
144154 . from ( components . values ( ) )
145155 . findLast ( ( { name } ) => O . exists ( name , n => n === componentName ) ) ;
146- if ( ! component ) return ;
156+ if ( ! component ) {
157+ return ;
158+ }
147159 components . set ( component . _ , {
148160 ...component ,
149161 displayName : O . some ( right ) ,
150162 } ) ;
151163 } ,
152164 "CallExpression[type]:exit" ( node : TSESTree . CallExpression ) {
153- if ( ! isReactHookCall ( node ) ) return ;
165+ if ( ! isReactHookCall ( node ) ) {
166+ return ;
167+ }
154168 const mbEntry = getCurrentFunction ( ) ;
155- if ( O . isNone ( mbEntry ) ) return ;
169+ if ( O . isNone ( mbEntry ) ) {
170+ return ;
171+ }
156172 const entry = mbEntry . value ;
157173 functionEntries . pop ( ) ;
158174 functionEntries . push ( { ...entry , hookCalls : [ ...entry . hookCalls , node ] } ) ;
159175 } ,
160176 "ReturnStatement[type]" ( node : TSESTree . ReturnStatement ) {
161177 const mbEntry = getCurrentFunction ( ) ;
162- if ( O . isNone ( mbEntry ) ) return ;
178+ if ( O . isNone ( mbEntry ) ) {
179+ return ;
180+ }
163181 const entry = mbEntry . value ;
164182 const isComponent = hasNoneOrValidComponentName ( entry . node , context )
165183 && JSX . isJSXValue ( node . argument , jsxCtx , hint )
166184 && hasValidHierarchy ( entry . node , context , hint ) ;
167- if ( ! isComponent ) return ;
185+ if ( ! isComponent ) {
186+ return ;
187+ }
168188 functionEntries . pop ( ) ;
169189 functionEntries . push ( { ...entry , isComponent } ) ;
170190 const initPath = AST . getFunctionInitPath ( entry . node ) ;
0 commit comments