File tree Expand file tree Collapse file tree 4 files changed +19
-3
lines changed Expand file tree Collapse file tree 4 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
- ## Unreleased
3
+ ## 0.4.1
4
4
5
5
- Ignore ` export type * ` (fixes #12 )
6
+ - Support for all-uppercase function wrapped in forwardRef/memo (#11 )
6
7
7
8
## 0.4.0
8
9
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " eslint-plugin-react-refresh" ,
3
- "version" : " 0.4.0 " ,
3
+ "version" : " 0.4.1 " ,
4
4
"license" : " MIT" ,
5
5
"scripts" : {
6
6
"build" : " scripts/bundle.ts" ,
Original file line number Diff line number Diff line change @@ -41,6 +41,10 @@ const valid = [
41
41
name : "Direct export uppercase function" ,
42
42
code : "export function CMS() {};" ,
43
43
} ,
44
+ {
45
+ name : "Uppercase component with forwardRef" ,
46
+ code : "export const SVG = forwardRef(() => <svg/>);" ,
47
+ } ,
44
48
{
45
49
name : "Direct export uppercase component" ,
46
50
code : "export const CMS = () => {};" ,
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ export const onlyExportComponents: TSESLint.RuleModule<
115
115
for ( const variable of node . declarations ) {
116
116
handleExportIdentifier (
117
117
variable . id ,
118
- variable . init ?. type === "ArrowFunctionExpression" ,
118
+ canBeReactFunctionComponent ( variable . init ) ,
119
119
variable . init ,
120
120
) ;
121
121
}
@@ -193,3 +193,14 @@ export const onlyExportComponents: TSESLint.RuleModule<
193
193
} ;
194
194
} ,
195
195
} ;
196
+
197
+ const canBeReactFunctionComponent = ( init : TSESTree . Expression | null ) => {
198
+ if ( ! init ) return false ;
199
+ if ( init . type === "ArrowFunctionExpression" ) return true ;
200
+ if ( init . type === "CallExpression" ) {
201
+ if ( init . callee . type === "Identifier" ) {
202
+ return [ "memo" , "forwardRef" ] . includes ( init . callee . name ) ;
203
+ }
204
+ }
205
+ return false ;
206
+ } ;
You can’t perform that action at this time.
0 commit comments