react icon indicating copy to clipboard operation
react copied to clipboard

Bug: [email protected] only detects english component names

Open DavidZidar opened this issue 1 year ago • 9 comments

React version: [email protected]

Steps To Reproduce

  1. Create a functional component with a name such as ÄndraVärde that starts with a non english upper case letter
  2. Run the linter

The current behavior

Sample error:

23:20 error React Hook "useSelectedState" is called in function "ÄndraVärde" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use" react-hooks/rules-of-hooks

The expected behavior

The linting should allow non english component names, React does.

The problem

Version 5.0.0 included the changes made in #25162 which modified the following method: https://github.com/facebook/react/blob/e1378902bbb322aa1fe1953780f4b2b5f80d26b1/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js#L43-L50

This code only allows english upper case letters A-Z which is not enough.

Proposed solution

Use .toUpperCase() and compare the result:

function isComponentName(node) { 
  return node.type === 'Identifier' && node.name[0] == node.name[0].toUpperCase(); 
} 

This should work with a lot more languages at least.

DavidZidar avatar Nov 07 '24 08:11 DavidZidar

I would like to work on this!

garyguo123456789 avatar Nov 08 '24 02:11 garyguo123456789

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Feb 06 '25 03:02 github-actions[bot]

Bump. This is still an issue because no one has looked at my PR that fixes it. I rebased it recently.

DavidZidar avatar Feb 06 '25 07:02 DavidZidar

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Jun 07 '25 17:06 github-actions[bot]

Bump.

DavidZidar avatar Jun 07 '25 17:06 DavidZidar

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Sep 05 '25 18:09 github-actions[bot]

Bump again.

DavidZidar avatar Sep 05 '25 19:09 DavidZidar

This issue has been automatically marked as stale. If this issue is still affecting you, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

github-actions[bot] avatar Dec 04 '25 20:12 github-actions[bot]

Bump.

DavidZidar avatar Dec 04 '25 21:12 DavidZidar