Skip to content

Commit 0397bde

Browse files
authored
Allow non-leading underscores (#94)
1 parent 6368815 commit 0397bde

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/only-export-components.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ const valid = [
2929
name: "Direct export AF component with number",
3030
code: "export const Foo2 = () => {};",
3131
},
32+
{
33+
name: "Direct export AF component with underscore",
34+
code: "export const Foo_ = () => {};",
35+
},
3236
{
3337
name: "Direct export uppercase function",
3438
code: "export function CMS() {};",
@@ -226,6 +230,11 @@ const invalid = [
226230
code: "export const foo = () => {}; export const Bar = () => {};",
227231
errorId: "namedExport",
228232
},
233+
{
234+
name: "Component and underscored component",
235+
code: "export const _Foo = () => {}; export const Foo = () => {};",
236+
errorId: "namedExport",
237+
},
229238
{
230239
name: "Component and function with allowConstantExport",
231240
code: "export const foo = () => {}; export const Bar = () => {};",

src/only-export-components.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { TSESLint } from "@typescript-eslint/utils";
22
import type { TSESTree } from "@typescript-eslint/types";
33

4-
const reactComponentNameRE = /^[A-Z][a-zA-Z0-9]*$/u;
4+
const reactComponentNameRE = /^[A-Z][a-zA-Z0-9_]*$/u;
55

66
export const onlyExportComponents: TSESLint.RuleModule<
77
| "exportAll"

0 commit comments

Comments
 (0)