ESLint plugin for react-hook-form
npm install eslint-plugin-react-hook-form
$ npm i eslint --save-dev
`
Next, install eslint-plugin-react-hook-form:
`
$ npm install eslint-plugin-react-hook-form --save-dev
`
Usage
Add react-hook-form to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
`json
{
"plugins": ["react-hook-form"]
}
`
Then configure the rules you want to use under the rules section.
`json
{
"rules": {
"react-hook-form/destructuring-formstate": "error"
}
}
`
or start with the recommended rule set:
`json
{
"extends": "plugin:react-hook-form/recommended"
}
`
Supported Rules
| Rule | Description | Recommended | Fixable |
| -------------------------------------------------------------------- | --------------------------------------------------------------------- | ----------- | ------- |
| destructuring-formstate | Use destructuring assignment to access the properties of formState. | ⛔️ | |
| no-access-control | Avoid accessing the properties of control | ⛔️ | |
| no-nested-object-setvalue | Avoid nested object in second argument of setValue | ⛔️ | 🔧 |
| no-use-watch | Avoid using watch | | |
$3
| Icon | Description |
| ---- | ----------------------------------------------- |
| ⛔️ | Reports as error in recommended configuration |
| ⚠️ | Reports as warning in recommended configuration |
| 🔧 | Rule is fixable with eslint --fix` |