Skip to content

Commit 620568a

Browse files
committed
Support re-exporting namespace components (fixes #116) [publish]
1 parent 65c3172 commit 620568a

4 files changed

Lines changed: 13 additions & 1 deletion

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.6
4+
5+
- Support re-exporting namespace components (fixes [#116](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/116))
6+
37
## 0.5.5
48

59
- Fix SCREAMING_SNAKE_CASE constant exported via `export { Name }` incorrectly treated as React component [#114](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/pull/114) (fixes [#113](https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/113))

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.5",
3+
"version": "0.5.6",
44
"type": "module",
55
"license": "MIT",
66
"scripts": {

src/only-export-components.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ export function Button(props: PropsWithChildren): ReactNode {
295295
name: "SCREAMING_SNAKE_CASE constant and class exported via export { Name }",
296296
code: "const ENTITY_TYPE = 'Foo'; class SelectOption { constructor(label, value) { this.label = label; this.value = value; } } export { ENTITY_TYPE, SelectOption };",
297297
},
298+
{
299+
// https://github.com/ArnaudBarre/eslint-plugin-react-refresh/issues/116
300+
name: "Re-exporting namespace component",
301+
code: "const A = P.Root; const B = () => <div />; export { A, B }",
302+
},
298303
];
299304

300305
const invalid: {

src/only-export-components.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ export const onlyExportComponents: TSESLint.RuleModule<
167167
if (!hocName || !validHOCs.includes(hocName)) return false;
168168
return "needName";
169169
}
170+
if (exp.type === "MemberExpression" && !exp.computed) {
171+
return reactComponentNameRE.test(exp.property.name);
172+
}
170173
return false;
171174
};
172175

0 commit comments

Comments
 (0)