diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js index b8ec97678aa16..03a3b4ce2717e 100644 --- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js +++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js @@ -561,6 +561,15 @@ const tests = { }; `, }, + { + code: normalizeIndent` + // Valid because React supports international languages + function ÄndraVärdeComponent() { + useHook(); + return
; + } + ` + }, ], invalid: [ { diff --git a/packages/eslint-plugin-react-hooks/src/RulesOfHooks.ts b/packages/eslint-plugin-react-hooks/src/RulesOfHooks.ts index 0ab0c5ff21e4b..ac60f9f625f37 100644 --- a/packages/eslint-plugin-react-hooks/src/RulesOfHooks.ts +++ b/packages/eslint-plugin-react-hooks/src/RulesOfHooks.ts @@ -42,7 +42,10 @@ function isHook(node: Node): boolean { * always start with an uppercase letter. */ function isComponentName(node: Node): boolean { - return node.type === 'Identifier' && /^[A-Z]/.test(node.name); + return node.type === 'Identifier' && + node.name[0] === node.name[0].toUpperCase() && + node.name[0] !== '_' && + node.name[0] !== '$'; } function isReactFunction(node: Node, functionName: string): boolean {