Skip to content

Commit 70dcd5a

Browse files
committed
Support export { Component as default } (fixes #41) [publish]
1 parent b7e61e7 commit 70dcd5a

File tree

4 files changed

+14
-2
lines changed

4 files changed

+14
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.4.7
4+
5+
- Support `export { Component as default }` (fixes #41)
6+
37
## 0.4.6
48

59
- Ignore cypress test files (#39)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-refresh",
3-
"version": "0.4.6",
3+
"version": "0.4.7",
44
"type": "module",
55
"license": "MIT",
66
"scripts": {

src/only-export-components.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ const valid = [
136136
code: "export const loader = () => {}; export const meta = { title: 'Home' };",
137137
options: [{ allowExportNames: ["loader", "meta"] }],
138138
},
139+
{
140+
name: "Export as default",
141+
code: "export { App as default }; const App = () => <>Test</>;",
142+
},
139143
];
140144

141145
const invalid = [

src/only-export-components.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,11 @@ export const onlyExportComponents: TSESLint.RuleModule<
190190
hasExports = true;
191191
if (node.declaration) handleExportDeclaration(node.declaration);
192192
for (const specifier of node.specifiers) {
193-
handleExportIdentifier(specifier.exported);
193+
handleExportIdentifier(
194+
specifier.exported.name === "default"
195+
? specifier.local
196+
: specifier.exported,
197+
);
194198
}
195199
} else if (node.type === "VariableDeclaration") {
196200
for (const variable of node.declarations) {

0 commit comments

Comments
 (0)