Skip to content

Commit e92bee7

Browse files
committed
Add warning for TS enums exports (fixes #19) [publish]
1 parent dad0e9e commit e92bee7

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.4.3
4+
5+
- Add warning for TS enums exports
6+
37
## 0.4.2
48

59
- Fix typos in messages (#15, #16). Thanks @adamschachne & @janikga!

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "eslint-plugin-react-refresh",
3-
"version": "0.4.2",
3+
"version": "0.4.3",
44
"license": "MIT",
55
"scripts": {
66
"build": "scripts/bundle.ts",

src/only-export-components.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ const invalid = [
156156
code: "export const CONSTANT = 3; export const Foo = () => {};",
157157
errorId: "namedExport",
158158
},
159+
{
160+
name: "Component and enum",
161+
code: "export enum Tab { Home, Settings }; export const Bar = () => {};",
162+
errorId: "namedExport",
163+
},
159164
{
160165
name: "Unexported component and export",
161166
code: "const Tab = () => {}; export const tabs = [<Tab />, <Tab />];",

src/only-export-components.ts

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ export const onlyExportComponents: TSESLint.RuleModule<
127127
}
128128
} else if (node.type === "CallExpression") {
129129
context.report({ messageId: "anonymousExport", node });
130+
} else if (node.type === "TSEnumDeclaration") {
131+
nonComponentExports.push(node.id);
130132
}
131133
};
132134

0 commit comments

Comments
 (0)