From 1b17bcd2fbcf9f95679b2d64b0017c0aa682bc49 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Wed, 27 May 2020 15:27:35 +0100 Subject: [PATCH] Update README.md --- packages/eslint-plugin-react-hooks/README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/eslint-plugin-react-hooks/README.md b/packages/eslint-plugin-react-hooks/README.md index ed4bd56c7a086..ab2bbf13f70e6 100644 --- a/packages/eslint-plugin-react-hooks/README.md +++ b/packages/eslint-plugin-react-hooks/README.md @@ -45,20 +45,24 @@ Or use the recommended config: } ``` -## Configuration +## Advanced Configuration -`exhaustive-deps` can be configured to validate custom hooks via the `additionalHooks` option. -This option accepts a regex to match the names of custom hooks. +`exhaustive-deps` can be configured to validate dependencies of custom Hooks with the `additionalHooks` option. +This option accepts a regex to match the names of custom Hooks that have dependencies. ```js { "rules": { // ... - "react-hooks/exhaustive-deps": ["warn", { "additionalHooks": "(useMyCustomHook|useMyOtherCustomHook)" }] + "react-hooks/exhaustive-deps": ["warn", { + "additionalHooks": "(useMyCustomHook|useMyOtherCustomHook)" + }] } } ``` +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. + ## Valid and Invalid Examples 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.