Skip to content

Commit

Permalink
Add warning for TS enums exports (fixes #19) [publish]
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Jul 9, 2023
1 parent dad0e9e commit e92bee7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions 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!
Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down
5 changes: 5 additions & 0 deletions src/only-export-components.test.ts
Expand Up @@ -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 = [<Tab />, <Tab />];",
Expand Down
2 changes: 2 additions & 0 deletions src/only-export-components.ts
Expand Up @@ -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);
}
};

Expand Down

0 comments on commit e92bee7

Please sign in to comment.