Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The additionalHooks option of the exhaustive-deps ESLint rule #2350

Closed
vkrol opened this issue Sep 16, 2019 · 5 comments
Closed

The additionalHooks option of the exhaustive-deps ESLint rule #2350

vkrol opened this issue Sep 16, 2019 · 5 comments

Comments

@vkrol
Copy link

vkrol commented Sep 16, 2019

Hello!

I didn't find any mention of that option anywhere. Is the additionalHooks option of the exhaustive-deps ESLint rule stable enough? If that's so, it's a good idea to document it.

https://github.com/facebook/react/blob/9e64bf18e11828d6b4c0363bff5ed2eca1ccd838/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js#L32
https://github.com/facebook/react/blob/9e64bf18e11828d6b4c0363bff5ed2eca1ccd838/packages/eslint-plugin-react-hooks/__tests__/ESLintRuleExhaustiveDeps-test.js#L260

@vkrol vkrol changed the title exhaustive-deps ESLint rule: is the additionalHooks option stable? The additionalHooks option of the exhaustive-deps ESLint rule Sep 16, 2019
@nightpool
Copy link

Agree, spent all day looking for this today. Would really like to have this documented!

@rickhanlonii
Copy link
Member

Hey @vkrol, thanks for submitting. This is documented on the NPM page here, which is the documentation for the package and is taken from the README linked above.

@ghost
Copy link

ghost commented Jun 6, 2024

In VS Code I'm getting this advice about a stableHooksPattern advanced configuration [1] but when I add that to my .eslintrc.cjs file and run eslint ., I am getting an error [2].

When I switch to using "additionalHooks": "(usePlatform|useWorkbench)" in .eslintrc.cjs the eslint . command works, but then VS Code doesn't work anymore.

[1]
image

[2]

Error: .eslintrc.cjs:
Configuration for rule "react-hooks/exhaustive-deps" is invalid:
Value {"stableHooksPattern":"usePlatform|useWorkbench"} should NOT have additional properties.

@ghost
Copy link

ghost commented Jun 6, 2024

Clarification - the suggestion @example shown above is from my own jsdoc comment. The actual error I'm receiving is that my React Hook is "received a function whose dependencies are unknown". but the code I'm calling is not even passing a function, e.g. usePlatform("logger", "workbench")

However, I realize now that this github repo is for the react.dev site and that these notes really don't belong here. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants