Skip to content

Commit

Permalink
eslint-plugin-react-hooks: Fix international component name compatibi…
Browse files Browse the repository at this point in the history
…lity
  • Loading branch information
DavidZidar committed Feb 24, 2025
1 parent 2567726 commit 8a78051
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,15 @@ const tests = {
};
`,
},
{
code: normalizeIndent`
// Valid because React supports international languages
function ÄndraVärdeComponent() {
useHook();
return <div />;
}
`
},
],
invalid: [
{
Expand Down
5 changes: 4 additions & 1 deletion packages/eslint-plugin-react-hooks/src/RulesOfHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8a78051

Please sign in to comment.