We are now going to set up the React Hooks eslint plugin to automatically enforce the rules of Hooks.
Let's start installing and enabling the eslint plugin:
- First, we have to install the plugin via npm:
> npm install --save-dev eslint-plugin-react-hooks
We use the --save-dev flag here, because eslint and its plugins are not required to be installed when deploying the app. We only need them during the development of our app.
- Then, we create a new .eslintrc.json file in the root of our project folder, with the following contents. We start by extending from the react-app ESLint configuration:
{ "extends": "react-app",
- Next, we include the react-hooks plugin that we installed earlier:
"plugins": [