Skip to content

Commit

Permalink
Add additional messaging for RulesOfHooks lint error (#20692)
Browse files Browse the repository at this point in the history
* Add additional messaging for RulesOfHooks lint error

* Fix tests and spacing issue

* Prettify ESLintRulesOfHooks-test
  • Loading branch information
callmetwan committed Feb 23, 2021
1 parent 78d2f2d commit c62986c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -915,7 +915,8 @@ function functionError(hook, fn) {
message:
`React Hook "${hook}" is called in function "${fn}" that is neither ` +
'a React function component nor a custom React Hook function.' +
' React component names must start with an uppercase letter.',
' React component names must start with an uppercase letter.' +
' React Hook names must start with the word "use".',
};
}

Expand Down
3 changes: 2 additions & 1 deletion packages/eslint-plugin-react-hooks/src/RulesOfHooks.js
Expand Up @@ -482,7 +482,8 @@ export default {
`function "${context.getSource(codePathFunctionName)}" ` +
'that is neither a React function component nor a custom ' +
'React Hook function.' +
' React component names must start with an uppercase letter.';
' React component names must start with an uppercase letter.' +
' React Hook names must start with the word "use".';
context.report({node: hook, message});
} else if (codePathNode.type === 'Program') {
// These are dangerous if you have inline requires enabled.
Expand Down

0 comments on commit c62986c

Please sign in to comment.