Skip to content

Commit 199793e

Browse files
committed
Support nested function calls for extraHOCs (fixes #104)
1 parent 26b3c15 commit 199793e

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- Support false positives with TypeScript function overloading (fixes [#105](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/105))
6+
- Support nested function calls for extraHOCs (fixes [#104](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/104))
67

78
## 0.5.0
89

src/only-export-components.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,17 @@ const valid: {
276276
code: "export default class MyComponent extends Component { render() { return <div>Hello</div>; } }",
277277
},
278278
{
279-
name: "Direct export uppercase function",
279+
name: "Function overloading",
280280
code: `export function Button(props: PropsWithChildren<{ onClick: () => void }>): ReactNode;
281281
export function Button(props: PropsWithChildren): ReactNode {
282282
return <button {...props}>{props.children}</button>;
283283
}`,
284284
},
285+
{
286+
name: "Nested function calls for extraHOCs",
287+
code: "export const Component = styled('div').attrs({})`display: flex;`",
288+
options: { extraHOCs: ["styled"] },
289+
},
285290
];
286291

287292
const invalid: {

src/only-export-components.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ export const onlyExportComponents: TSESLint.RuleModule<
7878
// react-redux: connect(mapStateToProps, mapDispatchToProps)(...);
7979
// TanStack: createRootRoute()({ component: Foo });
8080
// styled-components: styled('div')`display: flex;`; or styled('div')({ display: 'flex' });
81-
if (
82-
callee.type === "CallExpression"
83-
&& callee.callee.type === "Identifier"
84-
) {
81+
if (callee.type === "CallExpression") {
8582
return getHocName(callee);
8683
}
8784
// React.memo(...)

0 commit comments

Comments
 (0)