ESLint cannot find the react-hooks/exhaustive-deps rule
Definition for rule 'react-hooks/exhaustive-deps' was not foundShort answer
ESLint only knows a rule when the plugin that owns it is registered in the config that applies to the file. This error means eslint-plugin-react-hooks is not installed, is not listed under plugins, or was written in the old .eslintrc style while ESLint reads eslint.config.js. Register the plugin once in the config style your ESLint version uses.
Fix it fast
1Find out which cause you have
Find out which config style your project really uses. A file called eslint.config.js (or .mjs/.ts) means flat config; a .eslintrc file means the legacy style. Then check that the plugin is installed.
ls -a | grep -i eslint npx eslint --version npm ls eslint-plugin-react-hooks2Match what you see, then jump to its fix
- 1
The rule name appears under rules, but no plugins entry named react-hooks exists next to itThe plugin is not registered in the configFix - 2
ESLint 9 or newer, a config with extends: ["plugin:react-hooks/recommended"], and the rule still not foundA legacy .eslintrc style config is read by a flat-config ESLintFix
- 1
What does the error look like?
Definition for rule 'react-hooks/exhaustive-deps' was not foundDefinition for rule 'react-hooks/rules-of-hooks' was not found
Cause 1 of 2
The plugin is not registered in the config
1Check
Open your ESLint config and look for the plugin. A rule such as react-hooks/exhaustive-deps only exists after the react-hooks plugin has been loaded under that namespace.
grep -n "react-hooks" eslint.config.* .eslintrc* package.json 2>/dev/null2Fix
Install the package as a dev dependency, then register it. In flat config, import it and add it under plugins. The plugin's own README also offers a ready-made recommended preset.
npm install eslint-plugin-react-hooks --save-dev
// eslint.config.js
import reactHooks from 'eslint-plugin-react-hooks';
export default [
{
files: ['**/*.{js,jsx,ts,tsx}'],
plugins: { 'react-hooks': reactHooks },
rules: {
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
},
];3Verify
Lint a file that uses a hook. The error about the missing definition is gone; real warnings can now appear.
npx eslint src/Confirmed by github.com
Cause 2 of 2
A legacy .eslintrc style config is read by a flat-config ESLint
1Check
ESLint has used eslint.config.js as its default since v9.0.0. The plugin README documents the extends string only for the legacy .eslintrc format used by ESLint below 9, so mixing the two leaves the plugin unloaded.
npx eslint --version
ls -a | grep -iE "eslint(rc|\.config)"2Fix
Move the setting into eslint.config.js and use the flat preset the plugin exports. If you must stay on ESLint 8, keep the legacy form instead.
// eslint.config.js (ESLint 9+)
import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';
export default defineConfig([
reactHooks.configs.flat.recommended,
]);
// .eslintrc.json (ESLint below 9 only)
{ "extends": ["plugin:react-hooks/recommended"] }3Verify
Run ESLint on the project and confirm the hooks rules report on a file you know has a missing dependency.
npx eslint src/Confirmed by eslint.org
How do I stop it coming back?
- Keep one config file per project and delete the other style when you migrate.
- Pin eslint and eslint-plugin-react-hooks together in package.json so an upgrade changes both at once.
- Prefer the plugin's recommended preset over copying rule names by hand.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
The exhaustive-deps warning on useEffect, and how to clear it properly
React Hook useEffect has a missing dependency: 'fetchData'
The linter found a prop, state value or function the effect reads that is not in its dependency array.
4 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fix