@@ -99,15 +99,6 @@ export const onlyExportComponents: TSESLint.RuleModule<
99
99
) [ ] = [ ] ;
100
100
const reactContextExports : TSESTree . Identifier [ ] = [ ] ;
101
101
102
- const handleLocalIdentifier = (
103
- identifierNode : TSESTree . BindingName ,
104
- ) => {
105
- if ( identifierNode . type !== "Identifier" ) return ;
106
- if ( reactComponentNameRE . test ( identifierNode . name ) ) {
107
- localComponents . push ( identifierNode ) ;
108
- }
109
- } ;
110
-
111
102
const handleExportIdentifier = (
112
103
identifierNode : TSESTree . BindingName | TSESTree . StringLiteral ,
113
104
isFunction ?: boolean ,
@@ -264,10 +255,18 @@ export const onlyExportComponents: TSESLint.RuleModule<
264
255
}
265
256
} else if ( node . type === "VariableDeclaration" ) {
266
257
for ( const variable of node . declarations ) {
267
- handleLocalIdentifier ( variable . id ) ;
258
+ if (
259
+ variable . id . type === "Identifier" &&
260
+ reactComponentNameRE . test ( variable . id . name ) &&
261
+ canBeReactFunctionComponent ( variable . init )
262
+ ) {
263
+ localComponents . push ( variable . id ) ;
264
+ }
268
265
}
269
266
} else if ( node . type === "FunctionDeclaration" ) {
270
- handleLocalIdentifier ( node . id ) ;
267
+ if ( reactComponentNameRE . test ( node . id . name ) ) {
268
+ localComponents . push ( node . id ) ;
269
+ }
271
270
} else if (
272
271
node . type === "ImportDeclaration" &&
273
272
node . source . value === "react"
0 commit comments