Skip to content

Commit 8a78051

Browse files
committed
eslint-plugin-react-hooks: Fix international component name compatibility
1 parent 2567726 commit 8a78051

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,15 @@ const tests = {
561561
};
562562
`,
563563
},
564+
{
565+
code: normalizeIndent`
566+
// Valid because React supports international languages
567+
function ÄndraVärdeComponent() {
568+
useHook();
569+
return <div />;
570+
}
571+
`
572+
},
564573
],
565574
invalid: [
566575
{

packages/eslint-plugin-react-hooks/src/RulesOfHooks.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ function isHook(node: Node): boolean {
4242
* always start with an uppercase letter.
4343
*/
4444
function isComponentName(node: Node): boolean {
45-
return node.type === 'Identifier' && /^[A-Z]/.test(node.name);
45+
return node.type === 'Identifier' &&
46+
node.name[0] === node.name[0].toUpperCase() &&
47+
node.name[0] !== '_' &&
48+
node.name[0] !== '$';
4649
}
4750

4851
function isReactFunction(node: Node, functionName: string): boolean {

0 commit comments

Comments
 (0)