File tree Expand file tree Collapse file tree 2 files changed +27
-5
lines changed
Expand file tree Collapse file tree 2 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -201,6 +201,21 @@ const valid = [
201201 code : "const MyComponent = () => {}; export default observer(MyComponent);" ,
202202 options : [ { customHOCs : [ "observer" ] } ] ,
203203 } ,
204+ {
205+ name : "Curried HOC with styled (object form)" ,
206+ code : "export const Flex = styled('div')({display: 'flex'});" ,
207+ options : [ { customHOCs : [ "styled" ] } ] ,
208+ } ,
209+ {
210+ name : "Curried HOC with styled (template literal form)" ,
211+ code : "export const Flex = styled('div')`display: flex;`;" ,
212+ options : [ { customHOCs : [ "styled" ] } ] ,
213+ } ,
214+ {
215+ name : "Curried HOC only first call" ,
216+ code : "export const Flex = styled('div');" ,
217+ options : [ { customHOCs : [ "styled" ] } ] ,
218+ } ,
204219 {
205220 name : "Local constant with component casing and non component function" ,
206221 code : "const SomeConstant = 42; export function someUtility() { return SomeConstant }" ,
Original file line number Diff line number Diff line change @@ -82,11 +82,18 @@ export const onlyExportComponents: TSESLint.RuleModule<
8282 if ( ! init ) return false ;
8383 const jsInit = skipTSWrapper ( init ) ;
8484 if ( jsInit . type === "ArrowFunctionExpression" ) return true ;
85- if (
86- jsInit . type === "CallExpression"
87- && jsInit . callee . type === "Identifier"
88- ) {
89- return reactHOCs . includes ( jsInit . callee . name ) ;
85+ if ( jsInit . type === "CallExpression" ) {
86+ // memo(...)
87+ if ( jsInit . callee . type === "Identifier" ) {
88+ return reactHOCs . includes ( jsInit . callee . name ) ;
89+ }
90+ // Curried HOC: styled('div')({...})
91+ if (
92+ jsInit . callee . type === "CallExpression"
93+ && jsInit . callee . callee . type === "Identifier"
94+ ) {
95+ return reactHOCs . includes ( jsInit . callee . callee . name ) ;
96+ }
9097 }
9198 return false ;
9299 } ;
You can’t perform that action at this time.
0 commit comments