You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

eslint-plugin-react-hooks

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-react-hooks - npm Package Compare versions

Comparing version

to
0.0.0-experimental-3fbfb9ba-20250409

@@ -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-3fb11eed9",
"version": "0.0.0-experimental-3fbfb9ba-20250409",
"repository": {

@@ -13,5 +13,5 @@ "type": "git",

"README.md",
"build-info.json",
"cjs",
"index.js",
"cjs"
"index.d.ts"
],

@@ -24,2 +24,7 @@ "keywords": [

],
"scripts": {
"build:compiler": "cd ../../compiler && yarn workspace babel-plugin-react-compiler build",
"test": "yarn build:compiler && jest",
"typecheck": "tsc --noEmit"
},
"license": "MIT",

@@ -29,14 +34,39 @@ "bugs": {

},
"main": "./index.js",
"types": "./index.d.ts",
"engines": {
"node": ">=10"
"node": ">=18"
},
"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"
"eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0 || ^9.0.0"
},
"dependencies": {
"@babel/core": "^7.24.4",
"@babel/parser": "^7.24.4",
"@babel/plugin-transform-private-methods": "^7.24.4",
"hermes-parser": "^0.25.1",
"zod": "^3.22.4",
"zod-validation-error": "^3.0.3"
},
"devDependencies": {
"@babel/eslint-parser": "^7.11.4",
"@babel/preset-typescript": "^7.26.0",
"@babel/types": "^7.19.0",
"@tsconfig/strictest": "^2.0.5",
"@typescript-eslint/parser-v2": "npm:@typescript-eslint/parser@^2.26.0",
"@typescript-eslint/parser-v3": "npm:@typescript-eslint/parser@^3.10.0",
"@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0"
"@typescript-eslint/parser-v4": "npm:@typescript-eslint/parser@^4.1.0",
"@typescript-eslint/parser-v5": "npm:@typescript-eslint/parser@^5.62.0",
"@types/eslint": "^8.56.12",
"@types/estree": "^1.0.6",
"@types/estree-jsx": "^1.0.5",
"@types/node": "^20.2.5",
"babel-eslint": "^10.0.3",
"eslint-v7": "npm:eslint@^7.7.0",
"eslint-v8": "npm:eslint@^8.57.1",
"eslint-v9": "npm:eslint@^9.0.0",
"jest": "^29.5.0",
"typescript": "^5.4.3"
}
}
# `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,8 +21,40 @@ ## Installation

Then extend the recommended eslint config:
### Flat Config (eslint.config.js|ts)
#### 5.2.0
For users of 5.2.0 (the first version with flat config support), add the `recommended-latest` config.
```js
import * as reactHooks from 'eslint-plugin-react-hooks';
export default [
// ...
reactHooks.configs['recommended-latest'],
];
```
### Legacy Config (.eslintrc)
#### >= 5.2.0
If you are still using ESLint below 9.0.0, you can use `recommended-legacy` for accessing a legacy version of the recommended config.
```js
{
"extends": [
// ...
"plugin:react-hooks/recommended-legacy"
]
}
```
#### < 5.2.0
If you're using a version earlier than 5.2.0, the legacy config was simply `recommended`.
```js
{
"extends": [
// ...
"plugin:react-hooks/recommended"

@@ -37,3 +69,22 @@ ]

#### Flat Config (eslint.config.js|ts)
```js
import * as 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',
}
},
];
```
#### Legacy Config (.eslintrc)
```js
{

@@ -52,3 +103,2 @@ "plugins": [

## Advanced Configuration

@@ -61,6 +111,6 @@

{
"rules": {
rules: {
// ...
"react-hooks/exhaustive-deps": ["warn", {
"additionalHooks": "(useMyCustomHook|useMyOtherCustomHook)"
additionalHooks: "(useMyCustomHook|useMyOtherCustomHook)"
}]

@@ -75,3 +125,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.

@@ -78,0 +128,0 @@ ## License

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet