replace some hooks by other hooks
You'll first need to install ESLint:
npm i eslint --save-dev
Next, install eslint-plugin-replace-hooks
:
npm install eslint-plugin-replace-hooks --save-dev
Add replace-hooks
to the plugins section of your .eslintrc
configuration file. You can omit the eslint-plugin-
prefix:
{
"plugins": [
"replace-hooks" // this must be placed before `import`
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"replace-hooks/no-forbidden-hooks": [
"error",
{ "useState": { "tip": "your custom hooks", "dependency": "your module" } }
]
}
}
- no-forbidden-hooks
-
this plugin should work with
eslint-plugin-import
, especially the rulesimport/no-duplicates
to help merge import from same modules. -
the plugin must be placed before
eslint-plugin-import
plugins: [ // other plugins, 'replace-hooks', 'import', ]