@@ -93,9 +93,7 @@ export function useComponentCollector(
93
93
const onFunctionExit = ( ) => {
94
94
const entry = functionEntries . at ( - 1 ) ;
95
95
if ( entry == null ) return ;
96
- if ( ! entry . isComponent ) {
97
- return functionEntries . pop ( ) ;
98
- }
96
+ if ( ! entry . isComponent ) return functionEntries . pop ( ) ;
99
97
const shouldDrop = AST . getNestedReturnStatements ( entry . node . body )
100
98
. slice ( )
101
99
. reverse ( )
@@ -126,16 +124,12 @@ export function useComponentCollector(
126
124
":function[type]:exit" : onFunctionExit ,
127
125
"ArrowFunctionExpression[type][body.type!='BlockStatement']" ( ) {
128
126
const entry = getCurrentEntry ( ) ;
129
- if ( entry == null ) {
130
- return ;
131
- }
127
+ if ( entry == null ) return ;
132
128
const { body } = entry . node ;
133
129
const isComponent = hasNoneOrValidComponentName ( entry . node , context )
134
130
&& JSX . isJSXValue ( body , jsxCtx , hint )
135
131
&& hasValidHierarchy ( entry . node , context , hint ) ;
136
- if ( ! isComponent ) {
137
- return ;
138
- }
132
+ if ( ! isComponent ) return ;
139
133
const initPath = AST . getFunctionInitPath ( entry . node ) ;
140
134
const id = getFunctionComponentIdentifier ( entry . node , context ) ;
141
135
const name = getComponentNameFromIdentifier ( id ) ;
@@ -163,40 +157,29 @@ export function useComponentCollector(
163
157
: _ ;
164
158
const component = [ ...components . values ( ) ]
165
159
. findLast ( ( { name } ) => name != null && name === componentName ) ;
166
- if ( component == null ) {
167
- return ;
168
- }
160
+ if ( component == null ) return ;
169
161
component . displayName = right ;
170
162
} ,
171
163
}
172
164
: { } ,
173
165
...collectHookCalls
174
166
? {
175
167
"CallExpression[type]:exit" ( node : TSESTree . CallExpression ) {
176
- if ( ! isReactHookCall ( node ) ) {
177
- return ;
178
- }
168
+ if ( ! isReactHookCall ( node ) ) return ;
179
169
const entry = getCurrentEntry ( ) ;
180
- if ( entry == null ) {
181
- return ;
182
- }
170
+ if ( entry == null ) return ;
183
171
entry . hookCalls . push ( node ) ;
184
172
} ,
185
173
}
186
174
: { } ,
187
175
"ReturnStatement[type]" ( node : TSESTree . ReturnStatement ) {
188
176
const entry = getCurrentEntry ( ) ;
189
- if ( entry == null ) {
190
- return ;
191
- }
177
+ if ( entry == null ) return ;
192
178
const isComponent = hasNoneOrValidComponentName ( entry . node , context )
193
179
&& JSX . isJSXValue ( node . argument , jsxCtx , hint )
194
180
&& hasValidHierarchy ( entry . node , context , hint ) ;
195
- if ( ! isComponent ) {
196
- return ;
197
- }
198
- functionEntries . pop ( ) ;
199
- functionEntries . push ( { ...entry , isComponent } ) ;
181
+ if ( ! isComponent ) return ;
182
+ entry . isComponent = true ;
200
183
const initPath = AST . getFunctionInitPath ( entry . node ) ;
201
184
const id = getFunctionComponentIdentifier ( entry . node , context ) ;
202
185
const name = getComponentNameFromIdentifier ( id ) ;
0 commit comments