diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e818d4..cb36828 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.4.7 + +- Support `export { Component as default }` (fixes #41) + ## 0.4.6 - Ignore cypress test files (#39) diff --git a/package.json b/package.json index 6b4939e..c270fd1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-react-refresh", - "version": "0.4.6", + "version": "0.4.7", "type": "module", "license": "MIT", "scripts": { diff --git a/src/only-export-components.test.ts b/src/only-export-components.test.ts index 938bdfb..aed984c 100755 --- a/src/only-export-components.test.ts +++ b/src/only-export-components.test.ts @@ -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 = [ diff --git a/src/only-export-components.ts b/src/only-export-components.ts index 1cc31ff..ae42c87 100644 --- a/src/only-export-components.ts +++ b/src/only-export-components.ts @@ -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) {