diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c15b12..9a54299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.4.11 + +- Ignore type exports (ex. `export type foo = string;`) (fixes #47) + ## 0.4.10 - Support `function Foo() {}; export default React.memo(Foo)` (#46) (thanks @SukkaW!) diff --git a/package.json b/package.json index 1caf7e2..6fd4c19 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,11 @@ { "name": "eslint-plugin-react-refresh", - "version": "0.4.10", + "version": "0.4.11", "type": "module", "license": "MIT", "scripts": { "build": "scripts/bundle.ts", + "test": "bun test", "lint": "bun lint-ci --fix --cache", "lint-ci": "eslint ./ --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "prettier": "bun prettier-ci --write", diff --git a/src/only-export-components.test.ts b/src/only-export-components.test.ts index a89591f..d7d3a93 100755 --- a/src/only-export-components.test.ts +++ b/src/only-export-components.test.ts @@ -114,6 +114,16 @@ const valid = [ code: "export type * from './module';", filename: "Test.tsx", }, + { + name: "export type { foo }", + code: "type foo = string; export const Foo = () => null; export type { foo };", + filename: "Test.tsx", + }, + { + name: "export type foo", + code: "export type foo = string; export const Foo = () => null;", + filename: "Test.tsx", + }, { name: "Mixed export in JS without checkJS", code: "export const foo = () => {}; export const Bar = () => {};", diff --git a/src/only-export-components.ts b/src/only-export-components.ts index c94bcf1..8574e35 100644 --- a/src/only-export-components.ts +++ b/src/only-export-components.ts @@ -214,6 +214,7 @@ export const onlyExportComponents: TSESLint.RuleModule< context.report({ messageId: "anonymousExport", node }); } } else if (node.type === "ExportNamedDeclaration") { + if (node.exportKind === "type") continue; hasExports = true; if (node.declaration) handleExportDeclaration(node.declaration); for (const specifier of node.specifiers) {