Extra rules for React Hooks.
[!NOTE]
This plugin is already included in @eslint-react/eslint-plugin
. You don't need to install it separately if you are using @eslint-react/eslint-plugin
.
Install
npm install --save-dev eslint-plugin-react-hooks-extra
Setup
import js from "@eslint/js";
import reactHooksExtra from "eslint-plugin-react-hooks-extra";
export default [
js.configs.recommended,
{
files: ["**/*.{ts,tsx}"],
plugins: {
"react-hooks-extra": reactHooksExtra,
},
rules: {
"react-hooks-extra/no-direct-set-state-in-use-effect": "warn",
"react-hooks-extra/no-useless-custom-hooks": "warn",
"react-hooks-extra/prefer-use-state-lazy-initialization": "warn",
},
},
];
Rules
https://eslint-react.xyz/docs/rules/overview#hooks-extra-rules