File tree 6 files changed +47
-8
lines changed
6 files changed +47
-8
lines changed Original file line number Diff line number Diff line change
1
+ name : CI
2
+ on :
3
+ pull_request :
4
+ branches :
5
+ - main
6
+ jobs :
7
+ ci :
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ - uses : actions/checkout@v4
11
+ - uses : oven-sh/setup-bun@v2
12
+ - run : bun install
13
+ - run : bun ci
Original file line number Diff line number Diff line change 8
8
runs-on : ubuntu-latest
9
9
if : ${{ contains(github.event.head_commit.message, '[publish]') }}
10
10
steps :
11
- - uses : actions/checkout@v3
12
- - uses : oven-sh/setup-bun@v1
11
+ - uses : actions/checkout@v4
12
+ - uses : oven-sh/setup-bun@v2
13
13
- run : bun install
14
14
- run : bun ci
15
15
- uses : ArnaudBarre/npm-publish@v1
Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
+ ## 0.4.10
4
+
5
+ - Support ` function Foo() {}; export default React.memo(Foo) ` (#46 ) (thanks @SukkaW !)
6
+
3
7
## 0.4.9
4
8
5
- - Support ` function Foo() {}; export default memo(Foo) ` (fixes #44 )
9
+ - Support ` function Foo() {}; export default memo(Foo) ` (fixes #44 ) (thanks @ SukkaW !)
6
10
7
11
## 0.4.8
8
12
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " eslint-plugin-react-refresh" ,
3
- "version" : " 0.4.9 " ,
3
+ "version" : " 0.4.10 " ,
4
4
"type" : " module" ,
5
5
"license" : " MIT" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change @@ -89,14 +89,26 @@ const valid = [
89
89
name : "export default memo function" ,
90
90
code : "export default memo(function Foo () {});" ,
91
91
} ,
92
+ {
93
+ name : "export default React.memo function" ,
94
+ code : "export default React.memo(function Foo () {});" ,
95
+ } ,
92
96
{
93
97
name : "export default memo function assignment" ,
94
98
code : "const Foo = () => {}; export default memo(Foo);" ,
95
99
} ,
100
+ {
101
+ name : "export default React.memo function assignment" ,
102
+ code : "const Foo = () => {}; export default React.memo(Foo);" ,
103
+ } ,
96
104
{
97
105
name : "export default memo function declaration" ,
98
106
code : "function Foo() {}; export default memo(Foo);" ,
99
107
} ,
108
+ {
109
+ name : "export default React.memo function declaration" ,
110
+ code : "function Foo() {}; export default React.memo(Foo);" ,
111
+ } ,
100
112
{
101
113
name : "export type *" ,
102
114
code : "export type * from './module';" ,
Original file line number Diff line number Diff line change @@ -157,10 +157,20 @@ export const onlyExportComponents: TSESLint.RuleModule<
157
157
handleExportIdentifier ( node . id , true ) ;
158
158
}
159
159
} else if ( node . type === "CallExpression" ) {
160
- if (
161
- node . callee . type !== "Identifier" ||
162
- ! reactHOCs . has ( node . callee . name )
163
- ) {
160
+ // we rule out non HoC first
161
+ if ( node . callee . type !== "Identifier" ) {
162
+ // export default React.memo(function Foo() {})
163
+ // export default Preact.memo(function Foo() {})
164
+ if (
165
+ node . callee . type === "MemberExpression" &&
166
+ node . callee . property . type === "Identifier" &&
167
+ reactHOCs . has ( node . callee . property . name )
168
+ ) {
169
+ mayHaveReactExport = true ;
170
+ } else {
171
+ context . report ( { messageId : "anonymousExport" , node } ) ;
172
+ }
173
+ } else if ( ! reactHOCs . has ( node . callee . name ) ) {
164
174
// we rule out non HoC first
165
175
context . report ( { messageId : "anonymousExport" , node } ) ;
166
176
} else if (
You can’t perform that action at this time.
0 commit comments