Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions packages/eslint-plugin-react-hooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,62 @@ For users of 6.0 and beyond, add the `recommended` config.

```js
// eslint.config.js
import reactHooks from 'eslint-plugin-react-hooks';
import { defineConfig } from 'eslint/config';
import reactHooks from "eslint-plugin-react-hooks";
import { defineConfig } from "eslint/config";

export default defineConfig([
{
files: ["src/**/*.{js,jsx}"],
plugins: {
"react-hooks": reactHooks,
},
languageOptions: {
parserOptions: {
ecmaFeatures: { jsx: true },
},
},
extends: ["react-hooks/recommended"],
},
]);
```

If your project uses typescript, you'll also need to install [typescript-eslint](https://typescript-eslint.io) and enable its rules:

```js
// eslint.config.js
import reactHooks from "eslint-plugin-react-hooks";
import { defineConfig } from "eslint/config";
import tseslint from "typescript-eslint";

export default defineConfig([
{
files: ["src/**/*.{js,jsx,ts,tsx}"],
plugins: {
'react-hooks': reactHooks,
"react-hooks": reactHooks,
},
extends: ['react-hooks/recommended'],
extends: [tseslint.configs.recommended, "react-hooks/recommended"],
},
]);
```

You can opt into the latest [compiler powered rules](https://react.dev/reference/eslint-plugin-react-hooks#additional-rules) one by one:

```js
export default defineConfig( [
{
// ...
extends: ["react-hooks/recommended"],
rules: {
"react-hooks/purity": "error",
"react-hooks/immutability": "error",
//...
},
},
]);

```
Alternatively, use the `recommended-latest` preset, which enables these rules by default.

#### 5.2.0

For users of 5.2.0 (the first version with flat config support), add the `recommended-latest` config.
Expand Down