Add additional messaging for RulesOfHooks lint error (#20692)

* Add additional messaging for RulesOfHooks lint error

* Fix tests and spacing issue

* Prettify ESLintRulesOfHooks-test
This commit is contained in:
Anthony Garritano 2021-02-22 19:17:13 -05:00 committed by GitHub
parent 78d2f2d301
commit c62986cfd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -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".',
};
}

View File

@ -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.