Skip to content

Commit f2eb282

Browse files
docs: improve migration guide, mention defineConfig
1 parent 83f949e commit f2eb282

File tree

1 file changed

+51
-16
lines changed

1 file changed

+51
-16
lines changed

README.md

Lines changed: 51 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,70 @@ This ESLint plugin is intended to prevent issues with [RxJS](https://github.com/
77

88
Most of these rules require TypeScript typed linting and are indicated as such below.
99

10-
## Migrating from `eslint-plugin-rxjs`
10+
## Migration Guide from `eslint-plugin-rxjs`
1111

12-
This project is a fork of [`eslint-plugin-rxjs`](https://github.com/cartant/eslint-plugin-rxjs)
13-
initially started to support the new ESLint flat config format.
14-
There are some breaking changes:
12+
This project started as a fork of [`eslint-plugin-rxjs`](https://github.com/cartant/eslint-plugin-rxjs)
13+
but has since introduced new features which involve breaking changes.
1514

16-
- The old `.eslintrc` format is not supported.
17-
- If you need to continue using this old format, use the original `eslint-plugin-rxjs` or a different fork.
18-
- The plugin namespace specified in the `recommended` config was changed from `rxjs` to `rxjs-x`.
19-
- e.g. In your ESLint config, `rxjs/no-subject-value` should be renamed to `rxjs-x/no-subject-value`.
20-
- The rule `rxjs/no-ignored-observable` is renamed to `rxjs-x/no-floating-observables`.
15+
1. Migrate your config from the old `.eslintrc` format to `eslint.config.mjs` (or similar), and uninstall `eslint-plugin-rxjs`.
16+
- See ESLint's guide here: [https://eslint.org/docs/latest/use/configure/migration-guide].
17+
- If you need to continue using the deprecated format, use the original `eslint-plugin-rxjs` or a different fork.
18+
2. Install `eslint-plugin-rxjs-x`, and import it into your config.
2119

22-
A complete description of all changes are documented in the [CHANGELOG](CHANGELOG.md) file.
20+
```diff
21+
+ import rxjsX from 'eslint-plugin-rxjs-x';
22+
```
2323

24-
## Install
24+
3. If you previously used the `plugin:rxjs/recommended` shared config, add `rxjsX.configs.recommended` to your `configs` block:
25+
26+
```diff
27+
configs: {
28+
+ rxjsX.configs.recommended,
29+
},
30+
```
31+
32+
- Note: `eslint-plugin-rxjs-x` provides a `strict` shared config, so consider using `rxjsX.configs.strict` instead.
33+
4. If you previously did _not_ use a shared config, add the plugin to your `plugins` block with the new namespace:
34+
35+
```diff
36+
plugins: {
37+
+ 'rxjs-x': rxjsX,
38+
},
39+
```
40+
41+
- Note: this is unnecessary if you are using a shared config.
42+
5. In your `rules` block, replace the namespace `rxjs` with `rxjs-x`:
43+
44+
```diff
45+
- 'rxjs/no-subject-value': 'error',
46+
+ 'rxjs-x/no-subject-value': 'error',
47+
```
48+
49+
6. If you previously used `rxjs/no-ignored-observable`, replace it with `rxjs-x/no-floating-observables`.
50+
51+
```diff
52+
- 'rxjs/no-ignored-observable': 'error',
53+
+ 'rxjs-x/no-floating-observables': 'error',
54+
```
55+
56+
> [!TIP]
57+
> A complete description of all changes are documented in the [CHANGELOG](CHANGELOG.md) file.
58+
59+
## Installation Guide
2560

2661
See [typescript-eslint's Getting Started](https://typescript-eslint.io/getting-started) for a full ESLint setup guide.
2762

28-
Then use the `recommended` configuration in your `eslint.config.mjs` and enable typed linting:
63+
1. Enable typed linting.
64+
- See [Linting with Type Information](https://typescript-eslint.io/getting-started/typed-linting/) for more information.
65+
2. Start with the `recommended` shared config in your `eslint.config.mjs`.
2966

3067
```js
3168
// @ts-check
69+
import { defineConfig } from 'eslint/config';
3270
import tseslint from 'typescript-eslint';
3371
import rxjsX from 'eslint-plugin-rxjs-x';
3472

35-
export default tseslint.config({
73+
export default defineConfig({
3674
extends: [
3775
...tseslint.configs.recommended,
3876
rxjsX.configs.recommended,
@@ -45,9 +83,6 @@ export default tseslint.config({
4583
});
4684
```
4785

48-
The above example uses `typescript-eslint`'s built-in config to set up the TypeScript parser for us.
49-
Enabling `projectService` then turns on typed linting.
50-
See [Linting with Type Information](https://typescript-eslint.io/getting-started/typed-linting/) for details.
5186

5287
## Configs
5388

0 commit comments

Comments
 (0)