diff --git a/CHANGELOG.md b/CHANGELOG.md index fd3a3da..2919d93 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.3.1 + +Allow numbers in component names (Fixes #1) + ## 0.3.0 Report an error when a file that contains components that can't be fast-refreshed because: diff --git a/package.json b/package.json index 82c7a10..87fd362 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "eslint-plugin-react-refresh", - "version": "0.3.0", + "version": "0.3.1", "license": "MIT", "scripts": { "build": "scripts/bundle.ts", diff --git a/src/only-export-components.ts b/src/only-export-components.ts index df900dd..6511ba3 100644 --- a/src/only-export-components.ts +++ b/src/only-export-components.ts @@ -1,11 +1,11 @@ import { TSESLint } from "@typescript-eslint/utils"; import { TSESTree } from "@typescript-eslint/types"; -const possibleReactExportRE = /^[A-Z][a-zA-Z]*$/; -// Only letters, starts with uppercase and at least one lowercase +const possibleReactExportRE = /^[A-Z][a-zA-Z0-9]*$/; +// Starts with uppercase and at least one lowercase // This can lead to some false positive (ex: `const CMS = () => <>`) // But allow to catch `export const CONSTANT = 3` -const strictReactExportRE = /^[A-Z][a-zA-Z]*[a-z]+[a-zA-Z]*$/; +const strictReactExportRE = /^[A-Z][a-zA-Z0-9]*[a-z]+[a-zA-Z0-9]*$/; export const onlyExportComponents: TSESLint.RuleModule< | "exportAll" diff --git a/src/tests.ts b/src/tests.ts index 2690ff5..ddfb192 100755 --- a/src/tests.ts +++ b/src/tests.ts @@ -31,6 +31,10 @@ const valid = [ name: "Direct export AF component", code: "export const Foo = () => {};", }, + { + name: "Direct export AF component with number", + code: "export const Foo2 = () => {};", + }, { name: "Export AF component", code: "const Foo = () => {}; export { Foo };",