包详细信息

eslint-plugin-react-hooks-extra

Rel1cx1.7mMIT1.52.3

ESLint React's ESLint plugin for React Hooks related rules.

react, hooks, hooks-extra, eslint

自述文件

eslint-plugin-react-hooks-extra

Extra rules for React Hooks.

Install

# npm
npm install --save-dev eslint-plugin-react-hooks-extra

Setup

// eslint.config.js

// @ts-check
import js from "@eslint/js";
import reactHooksExtra from "eslint-plugin-react-hooks-extra";
import tseslint from "typescript-eslint";

export default tseslint.config({
  files: ["**/*.ts", "**/*.tsx"],
  extends: [
    js.configs.recommended,
    tseslint.configs.recommended,
    reactHooksExtra.configs.recommended,
  ],
  languageOptions: {
    parser: tseslint.parser,
    parserOptions: {
      projectService: true,
      tsconfigRootDir: import.meta.dirname,
    },
  },
  rules: {
    // Put rules you want to override here
    "react-hooks-extra/no-unnecessary-use-prefix": "warn",
    "react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
  },
});

Rules

https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules