Skip to content

Commit

Permalink
Support export { Component as default } (fixes #41) [publish]
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed May 9, 2024
1 parent b7e61e7 commit 70dcd5a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.4.7

- Support `export { Component as default }` (fixes #41)

## 0.4.6

- Ignore cypress test files (#39)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-plugin-react-refresh",
"version": "0.4.6",
"version": "0.4.7",
"type": "module",
"license": "MIT",
"scripts": {
Expand Down
4 changes: 4 additions & 0 deletions src/only-export-components.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ const valid = [
code: "export const loader = () => {}; export const meta = { title: 'Home' };",
options: [{ allowExportNames: ["loader", "meta"] }],
},
{
name: "Export as default",
code: "export { App as default }; const App = () => <>Test</>;",
},
];

const invalid = [
Expand Down
6 changes: 5 additions & 1 deletion src/only-export-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ export const onlyExportComponents: TSESLint.RuleModule<
hasExports = true;
if (node.declaration) handleExportDeclaration(node.declaration);
for (const specifier of node.specifiers) {
handleExportIdentifier(specifier.exported);
handleExportIdentifier(
specifier.exported.name === "default"
? specifier.local
: specifier.exported,
);
}
} else if (node.type === "VariableDeclaration") {
for (const variable of node.declarations) {
Expand Down

0 comments on commit 70dcd5a

Please sign in to comment.