diff --git a/CHANGELOG.md b/CHANGELOG.md index 44bb961..e383eda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.4.3 + +- Add warning for TS enums exports + ## 0.4.2 - Fix typos in messages (#15, #16). Thanks @adamschachne & @janikga! diff --git a/package.json b/package.json index 594745c..6f1fc0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-react-refresh", - "version": "0.4.2", + "version": "0.4.3", "license": "MIT", "scripts": { "build": "scripts/bundle.ts", diff --git a/src/only-export-components.test.ts b/src/only-export-components.test.ts index 7efbdd8..56c3213 100755 --- a/src/only-export-components.test.ts +++ b/src/only-export-components.test.ts @@ -156,6 +156,11 @@ const invalid = [ code: "export const CONSTANT = 3; export const Foo = () => {};", errorId: "namedExport", }, + { + name: "Component and enum", + code: "export enum Tab { Home, Settings }; export const Bar = () => {};", + errorId: "namedExport", + }, { name: "Unexported component and export", code: "const Tab = () => {}; export const tabs = [, ];", diff --git a/src/only-export-components.ts b/src/only-export-components.ts index f792fc2..13693f6 100644 --- a/src/only-export-components.ts +++ b/src/only-export-components.ts @@ -127,6 +127,8 @@ export const onlyExportComponents: TSESLint.RuleModule< } } else if (node.type === "CallExpression") { context.report({ messageId: "anonymousExport", node }); + } else if (node.type === "TSEnumDeclaration") { + nonComponentExports.push(node.id); } };