# eslint-plugin-react-hooks

> ESLint rules for React Hooks

Latest version **7.1.1** (published 2026-04-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install eslint-plugin-react-hooks
pnpm add eslint-plugin-react-hooks
yarn add eslint-plugin-react-hooks
bun add eslint-plugin-react-hooks
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; no vulnerabilities; high maintenance score; high quality score; popular repo; extremely popular.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 7.1.1 |
| Published | 2026-04-17 |
| First published | 2018-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=18 |
| Dependencies | 5 |
| Unpacked size | 3.9 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 250591 |
| Maintainers | react-bot |
| Keywords | eslint, eslint-plugin, eslintplugin, react |

## Links

- npm: https://www.npmjs.com/package/eslint-plugin-react-hooks
- Repository: https://github.com/facebook/react
- Homepage: https://react.dev/
- Issues: https://github.com/facebook/react/issues
- npm.io page: https://npm.io/package/eslint-plugin-react-hooks

## Dependencies (5)

- [zod](https://npm.io/package/zod.md) ^3.25.0 || ^4.0.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.24.4
- [@babel/parser](https://npm.io/package/@babel/parser.md) ^7.24.4
- [hermes-parser](https://npm.io/package/hermes-parser.md) ^0.25.1
- [zod-validation-error](https://npm.io/package/zod-validation-error.md) ^3.5.0 || ^4.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 7.1.1 (latest) — 2026-04-17
- 0.0.0-experimental-59aff3e1-20260918 (experimental) — 2026-09-18
- 7.1.1-canary-59aff3e1-20260918 (canary) — 2026-09-18
- 7.1.1-canary-d5736f09-20260507 (next) — 2026-05-08
- 6.0.0-rc.2 (rc) — 2025-08-28
- 5.1.0-beta-26f2496093-20240514 (beta) — 2024-05-14
- 0.0.0-experimental-2b19aecd-20260916 — 2026-09-16
- 7.1.1-canary-2b19aecd-20260916 — 2026-09-16
- 0.0.0-experimental-ff8f88fc-20260915 — 2026-09-15
- 7.1.1-canary-ff8f88fc-20260915 — 2026-09-15
- 7.1.1-canary-9b938532-20260914 — 2026-09-14
- 0.0.0-experimental-9b938532-20260914 — 2026-09-14
- 7.1.1-canary-019019be-20260911 — 2026-09-11
- 0.0.0-experimental-019019be-20260911 — 2026-09-11
- 7.1.1-canary-82c44beb-20260910 — 2026-09-10
- … 2775 more at https://npm.io/package/eslint-plugin-react-hooks/versions

## README

# `eslint-plugin-react-hooks`

The official ESLint plugin for [React](https://react.dev) which enforces the [Rules of React](https://react.dev/reference/eslint-plugin-react-hooks) and other best practices.

## Installation

Assuming you already have ESLint installed, run:

```sh
# npm
npm install eslint-plugin-react-hooks --save-dev

# yarn
yarn add eslint-plugin-react-hooks --dev
```

### Flat Config (eslint.config.js|ts)

Add the `recommended` config for all recommended rules:

```js
// eslint.config.js
import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  reactHooks.configs.flat.recommended,
]);
```

If you want to try bleeding edge experimental compiler rules, use `recommended-latest`.

```js
// eslint.config.js
import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';

export default defineConfig([
  reactHooks.configs.flat['recommended-latest'],
]);
```

### Legacy Config (.eslintrc)

If you are still using ESLint below 9.0.0, the `recommended` preset can also be used to enable all recommended rules.

```js
{
  "extends": ["plugin:react-hooks/recommended"],
  // ...
}

```

### Custom Configuration

If you want more fine-grained configuration, you can instead choose to enable specific rules. However, we strongly encourage using the recommended presets — see above — so that you will automatically receive new recommended rules as we add them in future versions of the plugin.

#### Flat Config (eslint.config.js|ts)

```js
import reactHooks from 'eslint-plugin-react-hooks';

export default [
  {
    files: ['**/*.{js,jsx}'],
    plugins: { 'react-hooks': reactHooks },
    // ...
    rules: {
      // Core hooks rules
      'react-hooks/rules-of-hooks': 'error',
      'react-hooks/exhaustive-deps': 'warn',

      // React Compiler rules
      'react-hooks/config': 'error',
      'react-hooks/error-boundaries': 'error',
      'react-hooks/gating': 'error',
      'react-hooks/globals': 'error',
      'react-hooks/immutability': 'error',
      'react-hooks/preserve-manual-memoization': 'error',
      'react-hooks/purity': 'error',
      'react-hooks/refs': 'error',
      'react-hooks/set-state-in-effect': 'error',
      'react-hooks/set-state-in-render': 'error',
      'react-hooks/static-components': 'error',
      'react-hooks/unsupported-syntax': 'warn',
      'react-hooks/use-memo': 'error',
      'react-hooks/incompatible-library': 'warn',
    }
  },
];
```

#### Legacy Config (.eslintrc)
```js
{
  "plugins": [
    // ...
    "react-hooks"
  ],
  "rules": {
    // ...
    // Core hooks rules
    "react-hooks/rules-of-hooks": "error",
    "react-hooks/exhaustive-deps": "warn",

    // React Compiler rules
    "react-hooks/config": "error",
    "react-hooks/error-boundaries": "error",
    "react-hooks/gating": "error",
    "react-hooks/globals": "error",
    "react-hooks/immutability": "error",
    "react-hooks/preserve-manual-memoization": "error",
    "react-hooks/purity": "error",
    "react-hooks/refs": "error",
    "react-hooks/set-state-in-effect": "error",
    "react-hooks/set-state-in-render": "error",
    "react-hooks/static-components": "error",
    "react-hooks/unsupported-syntax": "warn",
    "react-hooks/use-memo": "error",
    "react-hooks/incompatible-library": "warn"
  }
}
```

## Advanced Configuration

`exhaustive-deps` can be configured to validate dependencies of custom Hooks with the `additionalHooks` option.
This option accepts a regex to match the names of custom Hooks that have dependencies.

```js
{
  rules: {
    // ...
    "react-hooks/exhaustive-deps": ["warn", {
      additionalHooks: "(useMyCustomHook|useMyOtherCustomHook)"
    }]
  }
}
```

We suggest to use this option **very sparingly, if at all**. Generally saying, we recommend most custom Hooks to not use the dependencies argument, and instead provide a higher-level API that is more focused around a specific use case.

## Valid and Invalid Examples

Please refer to the [Rules of Hooks](https://react.dev/reference/rules/rules-of-hooks) documentation to learn more about this rule.

## License

MIT

---
_Source: https://npm.io/package/eslint-plugin-react-hooks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
