diff --git a/packages/eslint-plugin-react-hooks/README.md b/packages/eslint-plugin-react-hooks/README.md index a1b4bcabb59f..dcb3109c0ae2 100644 --- a/packages/eslint-plugin-react-hooks/README.md +++ b/packages/eslint-plugin-react-hooks/README.md @@ -135,12 +135,14 @@ This option accepts a regex to match the names of custom Hooks that have depende rules: { // ... "react-hooks/exhaustive-deps": ["warn", { - additionalHooks: "(useMyCustomHook|useMyOtherCustomHook)" + additionalHooks: "^(useMyCustomHook|useMyOtherCustomHook)$" }] } } ``` +**Note:** The regex should use anchors (`^` and `$`) to ensure exact matching. Without anchors, the pattern `(useMyCustomHook|useMyOtherCustomHook)` would also match `useMyCustomHook2` or `useMyOtherCustomHookTest`. + 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