How to configure react-hooks/exhaustive-deps additionalHooks for modules?

Viewed 200

I have a useCustomHook defined in a module that I want to include in the react-hooks/exhaustive-deps check. I've tried adding it to the additionalHooks option, but that doesn't work if I use a qualified import.

import * as MyMod from 'my_module'
.
.
.
const value = MyMod.useCustomHook(() => depA + missingDep, [depA])

I've tried using a regex for anything ending in this hook name:

      "react-hooks/exhaustive-deps": [ "warn", {
         "additionalHooks": '(.*\.useCustomHook)'
      }],

But it doesn't match. I've tried with and without a ., without the prefix (useCustomHook), and few other module specific names. I can't get any of them to match the use.

How should I write the regex to match the use of the hook via a module name?

1 Answers

please use it like this:

 "react-hooks/exhaustive-deps": [ "warn", {
     "additionalHooks": '(useCustomHook)'
  }],
Related