From ddcc69c83b59ef0f895aa5020196e2ae9de36133 Mon Sep 17 00:00:00 2001 From: Rohith Srivathsav Date: Sun, 10 May 2020 06:22:11 +0530 Subject: [PATCH] Added clear message for functional component starting with lowercase (#18881) --- .../__tests__/ESLintRulesOfHooks-test.js | 3 ++- packages/eslint-plugin-react-hooks/src/RulesOfHooks.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js index 12c4f8ffb7..2f12ee3d71 100644 --- a/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js +++ b/packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js @@ -916,7 +916,8 @@ function functionError(hook, fn) { return { message: `React Hook "${hook}" is called in function "${fn}" that is neither ` + - 'a React function component nor a custom React Hook function.', + 'a React function component nor a custom React Hook function.' + + ' React component names must start with an uppercase letter.', }; } diff --git a/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js b/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js index dda5a1ee3c..4e47a81e51 100644 --- a/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js +++ b/packages/eslint-plugin-react-hooks/src/RulesOfHooks.js @@ -481,7 +481,8 @@ export default { `React Hook "${context.getSource(hook)}" is called in ` + `function "${context.getSource(codePathFunctionName)}" ` + 'that is neither a React function component nor a custom ' + - 'React Hook function.'; + 'React Hook function.' + + ' React component names must start with an uppercase letter.'; context.report({node: hook, message}); } else if (codePathNode.type === 'Program') { // These are dangerous if you have inline requires enabled.