eslint-plugin-react-hooks
Advanced tools
Comparing version 0.0.0-experimental-ddff50469-20230829 to 0.0.0-experimental-de1eaa26-20250124
@@ -6,5 +6,5 @@ 'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/eslint-plugin-react-hooks.production.min.js'); | ||
module.exports = require('./cjs/eslint-plugin-react-hooks.production.js'); | ||
} else { | ||
module.exports = require('./cjs/eslint-plugin-react-hooks.development.js'); | ||
} |
{ | ||
"name": "eslint-plugin-react-hooks", | ||
"description": "ESLint rules for React Hooks", | ||
"version": "0.0.0-experimental-ddff50469-20230829", | ||
"version": "0.0.0-experimental-de1eaa26-20250124", | ||
"repository": { | ||
@@ -29,5 +29,5 @@ "type": "git", | ||
}, | ||
"homepage": "https://reactjs.org/", | ||
"homepage": "https://react.dev/", | ||
"peerDependencies": { | ||
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" | ||
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0" | ||
}, | ||
@@ -39,5 +39,7 @@ "devDependencies": { | ||
"@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0", | ||
"@typescript-eslint/parser-v5": "npm:@typescript-eslint/parser@^5.0.0-0", | ||
"babel-eslint": "^10.0.3" | ||
"@typescript-eslint/parser-v5": "npm:@typescript-eslint/parser@^5.62.0", | ||
"babel-eslint": "^10.0.3", | ||
"eslint-v7": "npm:eslint@^7.7.0", | ||
"eslint-v9": "npm:eslint@^9.0.0" | ||
} | ||
} |
# `eslint-plugin-react-hooks` | ||
This ESLint plugin enforces the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html). | ||
This ESLint plugin enforces the [Rules of Hooks](https://react.dev/reference/rules/rules-of-hooks). | ||
It is a part of the [Hooks API](https://reactjs.org/docs/hooks-intro.html) for React. | ||
It is a part of the [Hooks API](https://react.dev/reference/react/hooks) for React. | ||
@@ -21,4 +21,6 @@ ## Installation | ||
Then extend the recommended eslint config: | ||
### Legacy Config (.eslintrc) | ||
If you are still using ESLint below 9.0.0, please continue to use `recommended-legacy`. To avoid breaking changes, we still support `recommended` as well, but note that this will be changed to alias the flat recommended config in v6. | ||
```js | ||
@@ -28,3 +30,3 @@ { | ||
// ... | ||
"plugin:react-hooks/recommended" | ||
"plugin:react-hooks/recommended-legacy" | ||
] | ||
@@ -34,2 +36,15 @@ } | ||
### Flat Config (eslint.config.js) | ||
For [ESLint 9.0.0 and above](https://eslint.org/blog/2024/04/eslint-v9.0.0-released/) users, add the `recommended-latest` config. | ||
```js | ||
import reactHooks from 'eslint-plugin-react-hooks'; | ||
export default [ | ||
// ... | ||
reactHooks.configs['recommended-latest'], | ||
]; | ||
``` | ||
### Custom Configuration | ||
@@ -39,2 +54,4 @@ | ||
#### Legacy Config (.eslintrc) | ||
```js | ||
@@ -54,3 +71,20 @@ { | ||
#### Flat Config (eslint.config.js) | ||
```js | ||
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', | ||
} | ||
}, | ||
]; | ||
``` | ||
## Advanced Configuration | ||
@@ -76,3 +110,3 @@ | ||
Please refer to the [Rules of Hooks](https://reactjs.org/docs/hooks-rules.html) documentation and the [Hooks FAQ](https://reactjs.org/docs/hooks-faq.html#what-exactly-do-the-lint-rules-enforce) to learn more about this rule. | ||
Please refer to the [Rules of Hooks](https://react.dev/reference/rules/rules-of-hooks) documentation to learn more about this rule. | ||
@@ -79,0 +113,0 @@ ## License |
Sorry, the diff of this file is too big to display
184320
4212
110
8