Registry / testing / eslint-plugin-react-hooks-addons

eslint-plugin-react-hooks-addons

JSON →
library0.5.1jsnpmunverified

ESLint plugin that adds the rule 'no-unused-deps' to detect unused dependencies in React Hook dependency arrays, complementing eslint-plugin-react-hooks. Current stable version is 0.5.1, released with support for ESLint v10. It flags variables in dependency arrays that are declared but not referenced inside the hook body, helping prevent unintended effect executions. Key differentiators: built-in support for static effect detection (unused deps), optional comment directive to mark intentional effect dependencies, and the ability to extend checking to custom hooks via `additionalHooks` option. It ships TypeScript types and provides both flat and legacy config.

npm install eslint-plugin-react-hooks-addons
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-REAC
E
eslint-plugin-react-hooks-addons
testingjavascriptv0.5.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

reactHooksAddons
import reactHooksAddons from 'eslint-plugin-react-hooks-addons'
const reactHooksAddons = require('eslint-plugin-react-hooks-addons')
Default export for flat config. With CommonJS, use require() but note that ESM is preferred for flat config.
plugin in .eslintrc
"plugins": ["react-hooks-addons"]
"plugins": ["eslint-plugin-react-hooks-addons"]
In legacy config, the plugin name is 'react-hooks-addons' without the prefix.
configs.recommended
reactHooksAddons.configs.recommended
reactHooksAddons.configs['recommended-legacy']
Use .recommended for flat config, .recommended-legacy for legacy config.

Installation, both flat and legacy config setup, and a React component demonstrating the rule.

// Install: npm install -D eslint-plugin-react-hooks-addons // Flat config (eslint.config.js): import reactHooksAddons from 'eslint-plugin-react-hooks-addons'; export default [ reactHooksAddons.configs.recommended ]; // Legacy config (.eslintrc): // { // "extends": ["plugin:react-hooks-addons/recommended-legacy"], // "rules": { // "react-hooks-addons/no-unused-deps": "warn" // } // } // Example usage with React effect: import { useEffect, useState } from 'react'; function Example() { const [user1, setUser1] = useState(); const [user2, setUser2] = useState(); useEffect(() => { fetch(`someUrl/${user1}`).then(/* ... */); // user2 is in deps but not used => warning! }, [user1, user2]); // Mark intentional dep: useEffect(() => { // fetch that depends on user1 }, [user1, /* effect dep */ user2]); return null; }
Debug
Known issues
gotchaThe rule only checks useEffect and useLayoutEffect by default; custom hooks need additionalHooks option.
fix
Add 'additionalHooks' pattern in rule options to match custom hooks.
affects: >=0.1.0
gotchaFlat config requires ESM import, not require().
fix
Use 'import reactHooksAddons from 'eslint-plugin-react-hooks-addons''.
affects: >=0.4.0
deprecatedThe 'customComment' option was renamed to 'effectComment' in v0.3.0.
fix
Rename option 'customComment' to 'effectComment'.
affects: <0.3.0
gotchaLegacy config uses 'recommended-legacy' not 'recommended'.
fix
Use 'extends: ["plugin:react-hooks-addons/recommended-legacy"]'.
affects: >=0.4.0
gotchaMust have eslint-plugin-react-hooks installed and configured for this plugin to be effective.
fix
Install both plugins: eslint-plugin-react-hooks and eslint-plugin-react-hooks-addons.
affects: >=0.1.0
Errors
Common errors & fixes
ESLint: Failed to load plugin 'eslint-plugin-react-hooks-addons': Cannot find module 'eslint-plugin-react-hooks-addons'
Package not installed or missing from node_modules.
fix
Run 'npm install -D eslint-plugin-react-hooks-addons'
ESLint: Configuration for rule 'react-hooks-addons/no-unused-deps' is invalid. Value '[object Object]' has unexpected property 'customComment'.
The option 'customComment' was renamed to 'effectComment' in v0.3.0.
fix
Change option name from 'customComment' to 'effectComment'.
Parsing error: The keyword 'import' is reserved
Using import syntax in a CommonJS file without transpilation.
fix
Use require() for CommonJS or set up a build step for ESM.
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency - required as the runtime for the plugin
Agent activity
2 hits · last 30 days
node
2
Resources
eslint-plugin-react-hooks-addons — npm install eslint-plugin-react-hooks-addons · libregistry