Skip to content

Commit c62986c

Browse files
authored
Add additional messaging for RulesOfHooks lint error (#20692)
* Add additional messaging for RulesOfHooks lint error * Fix tests and spacing issue * Prettify ESLintRulesOfHooks-test
1 parent 78d2f2d commit c62986c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/eslint-plugin-react-hooks/__tests__/ESLintRulesOfHooks-test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,8 @@ function functionError(hook, fn) {
915915
message:
916916
`React Hook "${hook}" is called in function "${fn}" that is neither ` +
917917
'a React function component nor a custom React Hook function.' +
918-
' React component names must start with an uppercase letter.',
918+
' React component names must start with an uppercase letter.' +
919+
' React Hook names must start with the word "use".',
919920
};
920921
}
921922

packages/eslint-plugin-react-hooks/src/RulesOfHooks.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,8 @@ export default {
482482
`function "${context.getSource(codePathFunctionName)}" ` +
483483
'that is neither a React function component nor a custom ' +
484484
'React Hook function.' +
485-
' React component names must start with an uppercase letter.';
485+
' React component names must start with an uppercase letter.' +
486+
' React Hook names must start with the word "use".';
486487
context.report({node: hook, message});
487488
} else if (codePathNode.type === 'Program') {
488489
// These are dangerous if you have inline requires enabled.

0 commit comments

Comments
 (0)