Add additional messaging for RulesOfHooks lint error #20692
Merged
+4
−2
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ec4b81d:
|
|
Hey @callmetwan, thanks for the suggestion. Looks like tests are failing and the whitespace is off. This seems like an improvement to me, but I defer to @gaearon. |
|
@rickhanlonii Sorry about the delay on this. Fixed the whitespace issue and updated tests. |
|
@rickhanlonii Just wanted to follow up on this. |
|
LGTM! |
c62986c
into
facebook:master
36 checks passed
36 checks passed
ci/circleci: yarn_test--r=stable --env=development --persistent
Your tests passed on CircleCI!
Details
ci/circleci: yarn_test--r=www-classic --env=development --variant
Your tests passed on CircleCI!
Details
ci/circleci: yarn_test--r=www-classic --env=production --variant
Your tests passed on CircleCI!
Details
ci/circleci: yarn_test--r=www-modern --env=development --variant
Your tests passed on CircleCI!
Details
ci/circleci: yarn_test--r=www-modern --env=production --variant
Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_build---project=devtools -r=experimental
Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_build--r=experimental --env=development
Your tests passed on CircleCI!
Details
ci/circleci: yarn_test_build--r=experimental --env=production
Your tests passed on CircleCI!
Details
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Summary
The ESLint rule eslint-plugin-react-hooks enforces a naming convention on hooks; they must all start with use. This is in line with the documentation around writing custom hooks. This is all good, works as intended.
The error message you get does not tell you this though. Example:
Resulting message:
It is not clear from the error that the issue is the name. This PR simply adds more information to the error reported.
Test Plan
Create a new React project.
Create a custom hook that does not begin with the word use:
Run
yarn lint,yarn linc, or view IDE reported lint warnings.The message should be:
Emphasis added for my addition.