@@ -21,6 +21,7 @@ export const onlyExportComponents: TSESLint.RuleModule<
2121        allowConstantExport ?: boolean ; 
2222        checkJS ?: boolean ; 
2323        allowExportNames ?: string [ ] ; 
24+         customHOCs ?: string [ ] ; 
2425      } , 
2526    ] 
2627>  =  { 
@@ -47,6 +48,7 @@ export const onlyExportComponents: TSESLint.RuleModule<
4748          allowConstantExport : {  type : "boolean"  } , 
4849          checkJS : {  type : "boolean"  } , 
4950          allowExportNames : {  type : "array" ,  items : {  type : "string"  }  } , 
51+           customHOCs : {  type : "array" ,  items : {  type : "string"  }  } , 
5052        } , 
5153        additionalProperties : false , 
5254      } , 
@@ -58,6 +60,7 @@ export const onlyExportComponents: TSESLint.RuleModule<
5860      allowConstantExport =  false , 
5961      checkJS =  false , 
6062      allowExportNames, 
63+       customHOCs =  [ ] , 
6164    }  =  context . options [ 0 ]  ??  { } ; 
6265    const  filename  =  context . filename ; 
6366    // Skip tests & stories files 
@@ -79,6 +82,16 @@ export const onlyExportComponents: TSESLint.RuleModule<
7982      ? new  Set ( allowExportNames ) 
8083      : undefined ; 
8184
85+     const  reactHOCs  =  new  Set ( [ "memo" ,  "forwardRef" ,  ...customHOCs ] ) ; 
86+     const  canBeReactFunctionComponent  =  ( init : TSESTree . Expression  |  null )  =>  { 
87+       if  ( ! init )  return  false ; 
88+       if  ( init . type  ===  "ArrowFunctionExpression" )  return  true ; 
89+       if  ( init . type  ===  "CallExpression"  &&  init . callee . type  ===  "Identifier" )  { 
90+         return  reactHOCs . has ( init . callee . name ) ; 
91+       } 
92+       return  false ; 
93+     } ; 
94+ 
8295    return  { 
8396      Program ( program )  { 
8497        let  hasExports  =  false ; 
@@ -298,16 +311,6 @@ export const onlyExportComponents: TSESLint.RuleModule<
298311  } , 
299312} ; 
300313
301- const  reactHOCs  =  new  Set ( [ "memo" ,  "forwardRef" ] ) ; 
302- const  canBeReactFunctionComponent  =  ( init : TSESTree . Expression  |  null )  =>  { 
303-   if  ( ! init )  return  false ; 
304-   if  ( init . type  ===  "ArrowFunctionExpression" )  return  true ; 
305-   if  ( init . type  ===  "CallExpression"  &&  init . callee . type  ===  "Identifier" )  { 
306-     return  reactHOCs . has ( init . callee . name ) ; 
307-   } 
308-   return  false ; 
309- } ; 
310- 
311314type  ToString < T >  =  T  extends  `${infer V } ` ? V  : never ; 
312315const  notReactComponentExpression  =  new  Set < 
313316  ToString < TSESTree . Expression [ "type" ] > 
0 commit comments