Skip to content

Commit

Permalink
docs(eslint-plugin-react-hooks): clarify config details for prior ver…
Browse files Browse the repository at this point in the history
…sions (#32498)

This change adds more details about prior versions of the plugin's
config, to help people as they migrate from legacy to flat configs
across multiple versions of this plugin. At some point in the 6.0 or 7.0
cycle, it would probably make sense to re-consolidate this into a single
version.

Closes #32494
  • Loading branch information
michaelfaith authored Mar 4, 2025
1 parent d4e24b3 commit 443b7ff
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions packages/eslint-plugin-react-hooks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@ yarn add eslint-plugin-react-hooks --dev

### Flat Config (eslint.config.js|ts)

For [ESLint 9.0.0 and above](https://eslint.org/blog/2024/04/eslint-v9.0.0-released/), add the `recommended` config.
#### 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'],
reactHooks.configs['recommended-latest'],
];
```

### Legacy Config (.eslintrc)

If you are still using ESLint below 9.0.0, you can use `recommended-legacy` for accessing the recommended config.
#### >= 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
{
Expand All @@ -44,6 +48,19 @@ If you are still using ESLint below 9.0.0, you can use `recommended-legacy` for
}
```

#### < 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"
]
}
```

### Custom Configuration

If you want more fine-grained configuration, you can instead add a snippet like this to your ESLint configuration file:
Expand Down

0 comments on commit 443b7ff

Please sign in to comment.