Document `additionalHooks` option (#19005)
* Document `additionalHooks` option * Update README.md Co-authored-by: Aaron Pettengill <aaron.pettengill@echoman.com> Co-authored-by: Dan Abramov <dan.abramov@gmail.com>
Aaron Pettengill committed
May 27, 2020 at 10:27 UTC
9752d31f127037e8126177b0456ab1b0547eb2db
1 file changed
+18
packages/eslint-plugin-react-hooks/README.md
+18
@@ -48,6 +48,24 @@ If you want more fine-grained configuration, you can instead add a snippet like
48
```
49
50
51
+## Advanced Configuration
52
+
53
+`exhaustive-deps` can be configured to validate dependencies of custom Hooks with the `additionalHooks` option.
54
+This option accepts a regex to match the names of custom Hooks that have dependencies.
55
+
56
+```js
57
+{
58
+ "rules": {
59
+ // ...
60
+ "react-hooks/exhaustive-deps": ["warn", {
61
+ "additionalHooks": "(useMyCustomHook|useMyOtherCustomHook)"
62
+ }]
63
+ }
64
+}
65
+```
66
+
67
+We suggest to use this option **very sparingly, if at all**. Generally saying, we recommend most custom Hooks to not use the dependencies argument, and instead provide a higher-level API that is more focused around a specific use case.
68
+
69
## Valid and Invalid Examples
70
71
Please refer to the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html) documentation and the [Hooks FAQ](https://reactjs.org/docs/hooks-faq.html#what-exactly-do-the-lint-rules-enforce) to learn more about this rule.