All free skills / Other majors

eslint-plugin-react-hooks 7.x

Use eslint-plugin-react-hooks ^7.0.0 correctly, including its flat and legacy presets, rule names, custom-hook dependency configuration, and the preset-shape changes from older releases.

For
eslint-plugin-react-hooks@7.1.1
Verified
2026-09-08, 2 examples executed
Skill package
@modootoday/pmcp-eslint-plugin-react-hooks@7.0.0

Use this skill for free

No PMCP login or subscription is required. Download the original instructions, or install the content-only archive with your project's package manager.

Download SKILL.md · Download package archive

npm install --save-dev https://pmcp.build/skills/eslint-plugin-react-hooks/7/package.tgz

PMCP discovers the installed package's instructions. Connect your runtime after installation.

Archive integritysha512-oZuZeaqcRFpobIQ4lf4E5sqEpljVsaq4eoJ9R4UMmc9OZTPMzNOS9ZwPlxJDS7gM/jkQgSCsGB1OAnCttbQmIg==

Complete instructions

Verified against eslint-plugin-react-hooks@7.1.1 on 2026-09-08. 2 of 2 examples executed.

eslint-plugin-react-hooks ^7.0.0

eslint-plugin-react-hooks is an ESLint plugin, not a standalone hooks runtime. Its package entry point is ./index.js, its TypeScript declarations are ./index.d.ts, and it requires Node >=18.

Import the plugin object by package name:

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

Presets

Version 7 has two preset families:

  • recommended: the recommended rules, including the compiler rules enabled by default in this release.
  • recommended-latest: the recommended rules plus bleeding-edge experimental compiler rules.

For ESLint flat config, use the flat presets:

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

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

For ESLint versions using legacy configuration, the documented form is:

{
  "extends": ["plugin:react-hooks/recommended"]
}

Do not use the older flat/recommended preset name. In 7.0.0, flat/recommended and recommended-latest-legacy were removed. The current flat form is reactHooks.configs.flat.recommended.

Explicit rule configuration

When configuring rules yourself, register the plugin under the react-hooks key:

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

export default [
  {
    files: ['**/*.{js,jsx}'],
    plugins: { 'react-hooks': reactHooks },
    rules: {
      'react-hooks/rules-of-hooks': 'error',
      'react-hooks/exhaustive-deps': 'warn',
      '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',
    },
  },
];

The documented recommended rule names are:

  • exhaustive-deps
  • rules-of-hooks
  • component-hook-factories
  • config
  • error-boundaries
  • gating
  • globals
  • immutability
  • incompatible-library
  • preserve-manual-memoization
  • purity
  • refs
  • set-state-in-effect
  • set-state-in-render
  • static-components
  • unsupported-syntax
  • use-memo

Compiler diagnostics are exposed through these ESLint rules and can be used even when the application has not adopted the compiler.

exhaustive-deps and custom hooks

exhaustive-deps accepts an additionalHooks option containing a regular expression for custom hooks whose dependency arrays should also be checked:

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

Treat additionalHooks as an ESLint rule option; it is not a separate plugin API.

Runnable package-surface checks

These examples only inspect the package because the plugin itself is consumed by ESLint. They do not attempt to invoke describe, it, expect, or an ESLint runner.

Plugin rules and exports

import assert from 'node:assert/strict';
import reactHooks from 'eslint-plugin-react-hooks';

assert.equal(typeof reactHooks, 'object');
assert.equal(typeof reactHooks.rules, 'object');
assert.equal(typeof reactHooks.configs, 'object');

for (const name of [
  'exhaustive-deps',
  'rules-of-hooks',
  'component-hook-factories',
  'config',
  'error-boundaries',
  'gating',
  'globals',
  'immutability',
  'incompatible-library',
  'preserve-manual-memoization',
  'purity',
  'refs',
  'set-state-in-effect',
  'set-state-in-render',
  'static-components',
  'unsupported-syntax',
  'use-memo',
]) {
  assert.equal(typeof reactHooks.rules[name], 'object', `missing rule: ${name}`);
}

Flat and legacy preset shapes

import assert from 'node:assert/strict';
import reactHooks from 'eslint-plugin-react-hooks';

assert.equal(typeof reactHooks.configs.flat, 'object');
assert.equal(typeof reactHooks.configs.flat.recommended, 'object');
assert.equal(typeof reactHooks.configs.flat['recommended-latest'], 'object');

assert.ok('recommended' in reactHooks.configs);
assert.ok('recommended-latest' in reactHooks.configs);
assert.equal('recommended-latest-legacy' in reactHooks.configs, false);
assert.equal('flat/recommended' in reactHooks.configs, false);

What this skill does not cover

  • Running ESLint or integrating the plugin into a particular ESLint project.
  • The diagnostics or autofix behavior of individual rules.
  • The exact compiler rules included in each preset beyond the documented preset distinction.
  • ESLint configuration-file discovery, ignores, parser setup, or framework integration.
  • Repository development and test tooling such as building the compiler before running the package's own tests.