File tree Expand file tree Collapse file tree 5 files changed +23
-4
lines changed
Expand file tree Collapse file tree 5 files changed +23
-4
lines changed Original file line number Diff line number Diff line change 1313 node-version : 22
1414 - uses : oven-sh/setup-bun@v2
1515 - run : bun install
16- - run : bun ci
16+ - run : bun run ci
Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## 0.4.25
4+
5+ - Report cases like ` export const ENUM = Object.keys(TABLE) as EnumType[]; ` (fixes [ #93 ] ( https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/93 ) )
6+ - Allow ` _ ` in component names ([ #94 ] ( https://github.com/ArnaudBarre/eslint-plugin-react-refresh/pull/94 ) )
7+
38## 0.4.24
49
510- Add ` "generateImageMetadata" ` , ` "generateSitemaps" ` & ` "generateStaticParams" ` to ` allowExportNames ` in Next config
Original file line number Diff line number Diff line change 11{
22 "name" : " eslint-plugin-react-refresh" ,
3- "version" : " 0.4.24 " ,
3+ "version" : " 0.4.25 " ,
44 "type" : " module" ,
55 "license" : " MIT" ,
66 "scripts" : {
Original file line number Diff line number Diff line change @@ -338,6 +338,11 @@ const invalid = [
338338 code : "const MyComponent = () => {}; export default observer(MyComponent);" ,
339339 errorId : [ "localComponents" , "anonymousExport" ] ,
340340 } ,
341+ {
342+ name : "Object.keys" ,
343+ code : "const MyComponent = () => {}; export const ENUM = Object.keys(TABLE) as EnumType[];" ,
344+ errorId : "localComponents" ,
345+ } ,
341346] ;
342347
343348const it = ( name : string , cases : Parameters < typeof ruleTester . run > [ 2 ] ) => {
Original file line number Diff line number Diff line change @@ -106,8 +106,9 @@ export const onlyExportComponents: TSESLint.RuleModule<
106106 const handleExportIdentifier = (
107107 identifierNode : TSESTree . BindingName | TSESTree . StringLiteral ,
108108 isFunction ?: boolean ,
109- init ?: TSESTree . Expression | null ,
109+ initParam ?: TSESTree . Expression | null ,
110110 ) => {
111+ const init = initParam ? skipTSWrapper ( initParam ) : null ;
111112 if ( identifierNode . type !== "Identifier" ) {
112113 nonComponentExports . push ( identifierNode ) ;
113114 return ;
@@ -116,7 +117,7 @@ export const onlyExportComponents: TSESLint.RuleModule<
116117 if (
117118 allowConstantExport
118119 && init
119- && constantExportExpressions . has ( skipTSWrapper ( init ) . type )
120+ && constantExportExpressions . has ( init . type )
120121 ) {
121122 return ;
122123 }
@@ -141,6 +142,14 @@ export const onlyExportComponents: TSESLint.RuleModule<
141142 reactContextExports . push ( identifierNode ) ;
142143 return ;
143144 }
145+ if ( init && init . type === "CallExpression" ) {
146+ if ( isHOCCallExpression ( init ) ) {
147+ hasReactExport = true ;
148+ } else {
149+ nonComponentExports . push ( identifierNode ) ;
150+ }
151+ return ;
152+ }
144153 if (
145154 init
146155 // Switch to allowList?
You can’t perform that action at this time.
0 commit comments