Added clear message for functional component starting with lowercase (#18881)
Rohith Srivathsav committed
May 10, 2020 at 06:22 UTC
ddcc69c83b59ef0f895aa5020196e2ae9de36133
2 files changed
+4
-2
packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js
+2
-1
@@ -916,7 +916,8 @@ function functionError(hook, fn) {
916
return {
917
message:
918
`React Hook "${hook}" is called in function "${fn}" that is neither ` +
919
- 'a React function component nor a custom React Hook function.',
919
+ 'a React function component nor a custom React Hook function.' +
920
+ ' React component names must start with an uppercase letter.',
921
};
922
}
923
packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
+2
-1
@@ -481,7 +481,8 @@ export default {
481
`React Hook "${context.getSource(hook)}" is called in ` +
482
`function "${context.getSource(codePathFunctionName)}" ` +
483
'that is neither a React function component nor a custom ' +
484
- 'React Hook function.';
484
+ 'React Hook function.' +
485
+ ' React component names must start with an uppercase letter.';
486
context.report({node: hook, message});
487
} else if (codePathNode.type === 'Program') {
488
// These are dangerous if you have inline requires enabled.