Bug: [email protected] only detects english component names
React version: [email protected]
Steps To Reproduce
- Create a functional component with a name such as
ÄndraVärdethat starts with a non english upper case letter - 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.
I would like to work on this!
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!
Bump. This is still an issue because no one has looked at my PR that fixes it. I rebased it recently.
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!
Bump.
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!
Bump again.
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!
Bump.