eslint-plugin-rxjs-x 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -43
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +244 -122
- package/dist/index.mjs +276 -154
- package/docs/rules/ban-operators.md +2 -0
- package/docs/rules/macro.md +4 -0
- package/docs/rules/no-exposed-subjects.md +2 -2
- package/docs/rules/no-ignored-default-value.md +29 -0
- package/docs/rules/no-nested-subscribe.md +2 -2
- package/docs/rules/throw-error.md +14 -25
- package/package.json +9 -9
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Disallow banned operators (`rxjs-x/ban-operators`)
|
|
2
2
|
|
|
3
|
+
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
4
|
+
|
|
3
5
|
<!-- end auto-generated rule header -->
|
|
4
6
|
|
|
5
7
|
This rule can be configured so that developers can ban any operators they want to avoid in their project.
|
package/docs/rules/macro.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# Require the use of the RxJS Tools Babel macro (`rxjs-x/macro`)
|
|
2
2
|
|
|
3
|
+
❌ This rule is deprecated.
|
|
4
|
+
|
|
3
5
|
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
|
4
6
|
|
|
5
7
|
<!-- end auto-generated rule header -->
|
|
6
8
|
|
|
7
9
|
This rule ensures that modules that import `rxjs` also import the Babel macro for [RxJS Tools](https://rxjs.tools).
|
|
10
|
+
|
|
11
|
+
This rule is deprecated because [`babel-plugin-rxjs-tools`](https://www.npmjs.com/package/babel-plugin-rxjs-tools) is unmaintained.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<!-- end auto-generated rule header -->
|
|
6
6
|
|
|
7
|
-
This rule prevents exposed (i.e. non-private) subjects. Developers should instead expose observables via the subjects' `
|
|
7
|
+
This rule prevents exposed (i.e. non-private) subjects. Developers should instead expose observables via the subjects' `asObservable` method.
|
|
8
8
|
|
|
9
9
|
## Rule details
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ import { Subject } from "rxjs";
|
|
|
24
24
|
class Answers {
|
|
25
25
|
private _answers: Subject<string>;
|
|
26
26
|
get answers() {
|
|
27
|
-
return this._answers.
|
|
27
|
+
return this._answers.asObservable();
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Disallow using `firstValueFrom`, `lastValueFrom`, `first`, and `last` without specifying a default value (`rxjs-x/no-ignored-default-value`)
|
|
2
|
+
|
|
3
|
+
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
4
|
+
|
|
5
|
+
<!-- end auto-generated rule header -->
|
|
6
|
+
|
|
7
|
+
This rule prevents `EmptyError` rejections if there were no emissions from `firstValueFrom`, `lastValueFrom`, `first`, or `last` by requiring `defaultValue`.
|
|
8
|
+
|
|
9
|
+
## Rule details
|
|
10
|
+
|
|
11
|
+
Examples of **incorrect** code for this rule:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { Subject, firstValueFrom } from "rxjs";
|
|
15
|
+
|
|
16
|
+
const sub = new Subject();
|
|
17
|
+
const result = firstValueFrom(sub);
|
|
18
|
+
sub.complete();
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Examples of **correct** code for this rule:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { Subject, firstValueFrom } from "rxjs";
|
|
25
|
+
|
|
26
|
+
const sub = new Subject();
|
|
27
|
+
const result = firstValueFrom(sub, { defaultValue: null });
|
|
28
|
+
sub.complete();
|
|
29
|
+
```
|
|
@@ -24,9 +24,9 @@ Examples of **correct** code for this rule:
|
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
26
|
import { of, timer } from "rxjs";
|
|
27
|
-
import {
|
|
27
|
+
import { map, mergeMap } from "rxjs/operators";
|
|
28
28
|
|
|
29
29
|
of(42, 54).pipe(
|
|
30
|
-
mergeMap((value) => timer(1e3).pipe(
|
|
30
|
+
mergeMap((value) => timer(1e3).pipe(map(() => value)))
|
|
31
31
|
).subscribe((value) => console.log(value));
|
|
32
32
|
```
|
|
@@ -1,49 +1,38 @@
|
|
|
1
|
-
# Enforce passing only `Error` values to
|
|
1
|
+
# Enforce passing only `Error` values to `throwError` (`rxjs-x/throw-error`)
|
|
2
2
|
|
|
3
3
|
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
4
4
|
|
|
5
5
|
<!-- end auto-generated rule header -->
|
|
6
6
|
|
|
7
|
-
This rule forbids
|
|
7
|
+
This rule forbids passing values that are not `Error` objects to `throwError`.
|
|
8
|
+
It's similar to the typescript-eslint [`only-throw-error`](https://typescript-eslint.io/rules/only-throw-error/) rule,
|
|
9
|
+
but is for the `throwError` Observable creation function - not `throw` statements.
|
|
8
10
|
|
|
9
11
|
## Rule details
|
|
10
12
|
|
|
11
13
|
Examples of **incorrect** code for this rule:
|
|
12
14
|
|
|
13
|
-
```ts
|
|
14
|
-
throw "Kaboom!";
|
|
15
|
-
```
|
|
16
|
-
|
|
17
15
|
```ts
|
|
18
16
|
import { throwError } from "rxjs";
|
|
19
|
-
throwError("Kaboom!");
|
|
20
|
-
```
|
|
21
17
|
|
|
22
|
-
```ts
|
|
23
|
-
import { throwError } from "rxjs";
|
|
24
18
|
throwError(() => "Kaboom!");
|
|
25
19
|
```
|
|
26
20
|
|
|
27
21
|
Examples of **correct** code for this rule:
|
|
28
22
|
|
|
29
23
|
```ts
|
|
30
|
-
|
|
31
|
-
```
|
|
24
|
+
import { throwError } from "rxjs";
|
|
32
25
|
|
|
33
|
-
|
|
34
|
-
throw new RangeError("Kaboom!");
|
|
26
|
+
throwError(() => new Error("Kaboom!"));
|
|
35
27
|
```
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
throw new DOMException("Kaboom!");
|
|
39
|
-
```
|
|
29
|
+
## Options
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
import { throwError } from "rxjs";
|
|
43
|
-
throwError(new Error("Kaboom!"));
|
|
44
|
-
```
|
|
31
|
+
<!-- begin auto-generated rule options list -->
|
|
45
32
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
33
|
+
| Name | Description | Type | Default |
|
|
34
|
+
| :--------------------- | :---------------------------------------------------------- | :------ | :------ |
|
|
35
|
+
| `allowThrowingAny` | Whether to always allow throwing values typed as `any`. | Boolean | `true` |
|
|
36
|
+
| `allowThrowingUnknown` | Whether to always allow throwing values typed as `unknown`. | Boolean | `true` |
|
|
37
|
+
|
|
38
|
+
<!-- end auto-generated rule options list -->
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-rxjs-x",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"packageManager": "yarn@4.5.1+sha512.341db9396b6e289fecc30cd7ab3af65060e05ebff4b3b47547b278b9e67b08f485ecd8c79006b405446262142c7a38154445ef7f17c1d5d1de7d90bf9ce7054d",
|
|
6
6
|
"description": "ESLint v9+ plugin for RxJS",
|
|
7
7
|
"author": "Jason Weinzierl <weinzierljason@gmail.com>",
|
|
@@ -75,25 +75,25 @@
|
|
|
75
75
|
"@stylistic/eslint-plugin": "^2.10.1",
|
|
76
76
|
"@types/common-tags": "^1.8.4",
|
|
77
77
|
"@types/node": "~18.18.0",
|
|
78
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
78
|
+
"@typescript-eslint/rule-tester": "^8.14.0",
|
|
79
79
|
"@typescript/vfs": "^1.6.0",
|
|
80
|
-
"@vitest/coverage-v8": "^2.1.
|
|
81
|
-
"@vitest/eslint-plugin": "^1.1.
|
|
82
|
-
"bumpp": "^9.8.
|
|
80
|
+
"@vitest/coverage-v8": "^2.1.5",
|
|
81
|
+
"@vitest/eslint-plugin": "^1.1.10",
|
|
82
|
+
"bumpp": "^9.8.1",
|
|
83
83
|
"eslint": "^9.14.0",
|
|
84
84
|
"eslint-config-flat-gitignore": "^0.3.0",
|
|
85
85
|
"eslint-doc-generator": "^1.7.1",
|
|
86
86
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
87
87
|
"eslint-plugin-eslint-plugin": "^6.3.1",
|
|
88
|
-
"eslint-plugin-import-x": "^4.4.
|
|
88
|
+
"eslint-plugin-import-x": "^4.4.2",
|
|
89
89
|
"eslint-plugin-n": "^17.13.1",
|
|
90
|
-
"markdownlint-cli2": "^0.
|
|
90
|
+
"markdownlint-cli2": "^0.15.0",
|
|
91
91
|
"rxjs": "^7.8.1",
|
|
92
92
|
"tsup": "^8.3.5",
|
|
93
93
|
"tsx": "^4.19.2",
|
|
94
94
|
"typescript": "~5.6.3",
|
|
95
|
-
"typescript-eslint": "^8.
|
|
96
|
-
"vitest": "^2.1.
|
|
95
|
+
"typescript-eslint": "^8.14.0",
|
|
96
|
+
"vitest": "^2.1.5"
|
|
97
97
|
},
|
|
98
98
|
"engines": {
|
|
99
99
|
"node": "^18.18.0 || ^20.9.0 || >= 21.1.0"
|