Skip to content

Commit c0317bf

Browse files
committed
Fix support for nested function calls for extraHOCs [publish]
1 parent 42a1805 commit c0317bf

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.5.2
4+
5+
- Support nested function calls for extraHOCs (actually fixes [#104](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/104))
6+
37
## 0.5.1
48

59
- Mark ESLint v10 as supported

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-refresh",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"type": "module",
55
"license": "MIT",
66
"scripts": {

src/only-export-components.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ export function Button(props: PropsWithChildren): ReactNode {
284284
},
285285
{
286286
name: "Nested function calls for extraHOCs",
287-
code: "export const Component = styled('div').attrs({})`display: flex;`",
287+
code: "export const Link = () => {}; export const Styles = styled('div').attrs((props) => ({ className: 'form-control' }))``;",
288288
options: { extraHOCs: ["styled"] },
289289
},
290290
];

src/only-export-components.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ export const onlyExportComponents: TSESLint.RuleModule<
9696
) {
9797
return callee.object.name;
9898
}
99+
if (callee.object.type === "CallExpression") {
100+
return getHocName(callee.object);
101+
}
99102
}
100103

101104
// memo(...)

0 commit comments

Comments
 (0)