DEPRECATED: Use the @arabasta/eslint-plugin-require-useeffect-dependency-array package instead. See
- On NPM: https://www.npmjs.com/package/@arabasta/eslint-plugin-require-useeffect-dependency-array
- On Github: https://github.com/CloudNStoyan/arabasta
This ESLint plugin enforces that React useEffect has a dependency array.
Assuming you already have ESLint installed, run:
# npm
npm install eslint-plugin-require-useeffect-dependency-array --save-dev
# yarn
yarn add eslint-plugin-require-useeffect-dependency-array --dev
Then extend the recommended eslint config:
{
"extends": [
// ...
"plugin:require-useeffect-dependency-array/recommended"
]
}
✅ Set in the recommended
configuration
🔧 Automatically fixable by the --fix
CLI option
Rule | Description | ✅ | 🔧 |
---|---|---|---|
require-useeffect-dependency-array | Enforce that useEffect has a dependency array | ✅ | 🔧 |
Examples of incorrect code for this rule:
useEffect(() => {})
Examples of correct code for this rule:
useEffect(() => {}, [])
MIT