eslint-plugin-rxjs-x 0.7.1 → 0.7.2
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/dist/index.js +11 -3
- package/dist/index.mjs +11 -3
- package/package.json +15 -16
- package/docs/rules/ban-observables.md +0 -42
- package/docs/rules/ban-operators.md +0 -44
- package/docs/rules/finnish.md +0 -91
- package/docs/rules/just.md +0 -20
- package/docs/rules/macro.md +0 -11
- package/docs/rules/no-async-subscribe.md +0 -54
- package/docs/rules/no-compat.md +0 -13
- package/docs/rules/no-connectable.md +0 -33
- package/docs/rules/no-create.md +0 -43
- package/docs/rules/no-cyclic-action.md +0 -88
- package/docs/rules/no-explicit-generics.md +0 -32
- package/docs/rules/no-exposed-subjects.md +0 -68
- package/docs/rules/no-finnish.md +0 -42
- package/docs/rules/no-floating-observables.md +0 -68
- package/docs/rules/no-ignored-default-value.md +0 -43
- package/docs/rules/no-ignored-error.md +0 -53
- package/docs/rules/no-ignored-notifier.md +0 -47
- package/docs/rules/no-ignored-replay-buffer.md +0 -47
- package/docs/rules/no-ignored-subscribe.md +0 -46
- package/docs/rules/no-ignored-subscription.md +0 -46
- package/docs/rules/no-ignored-takewhile-value.md +0 -35
- package/docs/rules/no-implicit-any-catch.md +0 -109
- package/docs/rules/no-index.md +0 -34
- package/docs/rules/no-internal.md +0 -38
- package/docs/rules/no-misused-observables.md +0 -101
- package/docs/rules/no-nested-subscribe.md +0 -46
- package/docs/rules/no-redundant-notify.md +0 -50
- package/docs/rules/no-sharereplay.md +0 -49
- package/docs/rules/no-subclass.md +0 -23
- package/docs/rules/no-subject-unsubscribe.md +0 -63
- package/docs/rules/no-subject-value.md +0 -19
- package/docs/rules/no-subscribe-handlers.md +0 -53
- package/docs/rules/no-subscribe-in-pipe.md +0 -55
- package/docs/rules/no-tap.md +0 -7
- package/docs/rules/no-topromise.md +0 -37
- package/docs/rules/no-unbound-methods.md +0 -61
- package/docs/rules/no-unsafe-catch.md +0 -74
- package/docs/rules/no-unsafe-first.md +0 -40
- package/docs/rules/no-unsafe-subject-next.md +0 -46
- package/docs/rules/no-unsafe-switchmap.md +0 -64
- package/docs/rules/no-unsafe-takeuntil.md +0 -72
- package/docs/rules/prefer-observer.md +0 -66
- package/docs/rules/prefer-root-operators.md +0 -45
- package/docs/rules/suffix-subjects.md +0 -81
- package/docs/rules/throw-error.md +0 -53
package/docs/rules/no-finnish.md
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# Disallow Finnish notation (`rxjs-x/no-finnish`)
|
|
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 the use of Finnish notation.
|
|
8
|
-
|
|
9
|
-
## Rule details
|
|
10
|
-
|
|
11
|
-
Examples of **incorrect** code for this rule:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
const answer$ = of(42, 54);
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Examples of **correct** code for this rule:
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
const answers = of(42, 54);
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## When Not To Use It
|
|
24
|
-
|
|
25
|
-
If you use Finnish notation in your project, you should avoid this rule.
|
|
26
|
-
Or if you don't care if Finnish notation is used in your project, then you don't need this rule.
|
|
27
|
-
However, keep in mind that inconsistent style can harm readability in a project.
|
|
28
|
-
|
|
29
|
-
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
|
|
30
|
-
|
|
31
|
-
## Further reading
|
|
32
|
-
|
|
33
|
-
- [Observables and Finnish Notation](https://medium.com/@benlesh/observables-and-finnish-notation-df8356ed1c9b)
|
|
34
|
-
|
|
35
|
-
## Related To
|
|
36
|
-
|
|
37
|
-
- [`finnish`](./finnish.md)
|
|
38
|
-
|
|
39
|
-
## Resources
|
|
40
|
-
|
|
41
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-finnish.ts)
|
|
42
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-finnish.test.ts)
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
# Require Observables to be handled appropriately (`rxjs-x/no-floating-observables`)
|
|
2
|
-
|
|
3
|
-
💼 This rule is enabled in the 🔒 `strict` config.
|
|
4
|
-
|
|
5
|
-
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
6
|
-
|
|
7
|
-
<!-- end auto-generated rule header -->
|
|
8
|
-
|
|
9
|
-
A "floating" observable is one that is created without any code set up to handle any errors it might emit.
|
|
10
|
-
Like a floating Promise, floating observables can cause several issues, such as ignored errors, unhandled cold observables, and more.
|
|
11
|
-
|
|
12
|
-
This rule is like [no-floating-promises](https://typescript-eslint.io/rules/no-floating-promises/) but for Observables.
|
|
13
|
-
This rule will report observable-valued statements that are not treated in one of the following ways:
|
|
14
|
-
|
|
15
|
-
- Calling its `.subscribe()`
|
|
16
|
-
- `return`ing it
|
|
17
|
-
- Wrapping it in `lastValueFrom` or `firstValueFrom` and `await`ing it
|
|
18
|
-
- [`void`ing it](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void)
|
|
19
|
-
|
|
20
|
-
> [!TIP]
|
|
21
|
-
> `no-floating-observables` only detects apparently unhandled observable _statements_.
|
|
22
|
-
> See [`no-misused-observables`](./no-misused-observables.md) for detecting code that provides observables to _logical_ locations.
|
|
23
|
-
|
|
24
|
-
## Rule details
|
|
25
|
-
|
|
26
|
-
Examples of **incorrect** code for this rule:
|
|
27
|
-
|
|
28
|
-
```ts
|
|
29
|
-
import { of } from "rxjs";
|
|
30
|
-
of(42, 54);
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Examples of **correct** code for this rule:
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import { of } from "rxjs";
|
|
37
|
-
const answers = of(42, 54);
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## Options
|
|
41
|
-
|
|
42
|
-
<!-- begin auto-generated rule options list -->
|
|
43
|
-
|
|
44
|
-
| Name | Description | Type | Default |
|
|
45
|
-
| :----------- | :------------------------------------ | :------ | :------ |
|
|
46
|
-
| `ignoreVoid` | Whether to ignore `void` expressions. | Boolean | `true` |
|
|
47
|
-
|
|
48
|
-
<!-- end auto-generated rule options list -->
|
|
49
|
-
|
|
50
|
-
## When Not To Use It
|
|
51
|
-
|
|
52
|
-
Like `@typescript-eslint/no-floating-promises`,
|
|
53
|
-
this rule can be difficult to enable on large existing projects that set up many floating observables.
|
|
54
|
-
Alternatively, if you're not worried about ignored errors or unhandled cold observables,
|
|
55
|
-
then in some cases it may be safe to not use this rule.
|
|
56
|
-
You might consider using `void`s and/or ESLint disable comments for those specific situations
|
|
57
|
-
instead of completely disabling this rule.
|
|
58
|
-
|
|
59
|
-
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
|
|
60
|
-
|
|
61
|
-
## Related To
|
|
62
|
-
|
|
63
|
-
- [`no-misused-observables`](./no-misused-observables.md)
|
|
64
|
-
|
|
65
|
-
## Resources
|
|
66
|
-
|
|
67
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-floating-observables.ts)
|
|
68
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-floating-observables.test.ts)
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# Disallow using `firstValueFrom`, `lastValueFrom`, `first`, and `last` without specifying a default value (`rxjs-x/no-ignored-default-value`)
|
|
2
|
-
|
|
3
|
-
💼 This rule is enabled in the 🔒 `strict` config.
|
|
4
|
-
|
|
5
|
-
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
6
|
-
|
|
7
|
-
<!-- end auto-generated rule header -->
|
|
8
|
-
|
|
9
|
-
This rule prevents `EmptyError` rejections if there were no emissions from `firstValueFrom`, `lastValueFrom`, `first`, or `last` by requiring `defaultValue`.
|
|
10
|
-
|
|
11
|
-
## Rule details
|
|
12
|
-
|
|
13
|
-
Examples of **incorrect** code for this rule:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { Subject, firstValueFrom } from "rxjs";
|
|
17
|
-
|
|
18
|
-
const sub = new Subject();
|
|
19
|
-
const result = firstValueFrom(sub);
|
|
20
|
-
sub.complete();
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Examples of **correct** code for this rule:
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
import { Subject, firstValueFrom } from "rxjs";
|
|
27
|
-
|
|
28
|
-
const sub = new Subject();
|
|
29
|
-
const result = firstValueFrom(sub, { defaultValue: null });
|
|
30
|
-
sub.complete();
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## When Not To Use It
|
|
34
|
-
|
|
35
|
-
If you intentionally want `EmptyError` rejections when the observable completes, then you may not need this rule.
|
|
36
|
-
You might consider using ESLint disable comments for specific situations instead of completely disabling this rule.
|
|
37
|
-
|
|
38
|
-
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
|
|
39
|
-
|
|
40
|
-
## Resources
|
|
41
|
-
|
|
42
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-ignored-default-value.ts)
|
|
43
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-ignored-default-value.test.ts)
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Disallow calling `subscribe` without specifying an error handler (`rxjs-x/no-ignored-error`)
|
|
2
|
-
|
|
3
|
-
💼 This rule is enabled in the 🔒 `strict` config.
|
|
4
|
-
|
|
5
|
-
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
6
|
-
|
|
7
|
-
<!-- end auto-generated rule header -->
|
|
8
|
-
|
|
9
|
-
This rule enforces the passing of an error handler to `subscribe` calls.
|
|
10
|
-
|
|
11
|
-
## Rule details
|
|
12
|
-
|
|
13
|
-
Examples of **incorrect** code for this rule:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
source.subscribe((value) => console.log(value));
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
source.subscribe({
|
|
21
|
-
next: (value) => console.log(value)
|
|
22
|
-
});
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Examples of **correct** code for this rule:
|
|
26
|
-
|
|
27
|
-
```ts
|
|
28
|
-
source.subscribe(
|
|
29
|
-
(value) => console.log(value),
|
|
30
|
-
(error) => console.error(error)
|
|
31
|
-
);
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
```ts
|
|
35
|
-
source.subscribe({
|
|
36
|
-
next: (value) => console.log(value),
|
|
37
|
-
error: (error) => console.error(error)
|
|
38
|
-
});
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## When Not To Use It
|
|
42
|
-
|
|
43
|
-
If you're not worried about ignored errors, then in some cases it may be safe to not use this rule.
|
|
44
|
-
Or if you use operators like `catchError` to handle all errors, then in some cases it may be safe to not use this rule.
|
|
45
|
-
You might consider using ESLint disable comments for those specific situations
|
|
46
|
-
instead of completely disabling this rule.
|
|
47
|
-
|
|
48
|
-
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
|
|
49
|
-
|
|
50
|
-
## Resources
|
|
51
|
-
|
|
52
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-ignored-error.ts)
|
|
53
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-ignored-error.test.ts)
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Disallow observables not composed from the `repeatWhen` or `retryWhen` notifier (`rxjs-x/no-ignored-notifier`)
|
|
2
|
-
|
|
3
|
-
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
|
|
4
|
-
|
|
5
|
-
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
6
|
-
|
|
7
|
-
<!-- end auto-generated rule header -->
|
|
8
|
-
|
|
9
|
-
This rule effects failures if the notifier passed to a `repeatWhen` or `retryWhen` callback is not used.
|
|
10
|
-
|
|
11
|
-
> [!NOTE]
|
|
12
|
-
> Both `repeatWhen` and `retryWhen` are deprecated by RxJS,
|
|
13
|
-
> so this rule may be removed in a future major version.
|
|
14
|
-
|
|
15
|
-
## Rule details
|
|
16
|
-
|
|
17
|
-
Examples of **incorrect** code for this rule:
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { range } from "rxjs";
|
|
21
|
-
import { repeatWhen, take } from "rxjs/operators";
|
|
22
|
-
|
|
23
|
-
const repeating = source.pipe(
|
|
24
|
-
repeatWhen(notifications => range(0, 3))
|
|
25
|
-
);
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Examples of **correct** code for this rule:
|
|
29
|
-
|
|
30
|
-
```ts
|
|
31
|
-
import { repeatWhen, take } from "rxjs/operators";
|
|
32
|
-
|
|
33
|
-
const repeating = source.pipe(
|
|
34
|
-
repeatWhen(notifications => notifications.pipe(take(3)))
|
|
35
|
-
);
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## When Not To Use It
|
|
39
|
-
|
|
40
|
-
If you don't use `repeatWhen` or `retryWhen` in your project, then you don't need this rule.
|
|
41
|
-
|
|
42
|
-
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
|
|
43
|
-
|
|
44
|
-
## Resources
|
|
45
|
-
|
|
46
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-ignored-notifier.ts)
|
|
47
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-ignored-notifier.test.ts)
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# Disallow using `ReplaySubject`, `publishReplay` or `shareReplay` without specifying the buffer size (`rxjs-x/no-ignored-replay-buffer`)
|
|
2
|
-
|
|
3
|
-
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
|
|
4
|
-
|
|
5
|
-
<!-- end auto-generated rule header -->
|
|
6
|
-
|
|
7
|
-
This rule effects failures if the buffer size of a replay buffer is not explicitly specified.
|
|
8
|
-
|
|
9
|
-
## Rule details
|
|
10
|
-
|
|
11
|
-
Examples of **incorrect** code for this rule:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { ReplaySubject } from "rxjs";
|
|
15
|
-
const subject = new ReplaySubject<number>();
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
```ts
|
|
19
|
-
import { of, shareReplay } from "rxjs";
|
|
20
|
-
of(42).pipe(shareReplay({ refCount: true }));
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Examples of **correct** code for this rule:
|
|
24
|
-
|
|
25
|
-
```ts
|
|
26
|
-
import { ReplaySubject } from "rxjs";
|
|
27
|
-
const subject = new ReplaySubject<number>(1);
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
```ts
|
|
31
|
-
import { ReplaySubject } from "rxjs";
|
|
32
|
-
const subject = new ReplaySubject<number>(Infinity);
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import { of, shareReplay } from "rxjs";
|
|
37
|
-
of(42).pipe(shareReplay({ refCount: true, bufferSize: 1 }));
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## When Not To Use It
|
|
41
|
-
|
|
42
|
-
If you don't care about implicitly defaulting to `Infinity` in your replay buffers, then you don't need this rule.
|
|
43
|
-
|
|
44
|
-
## Resources
|
|
45
|
-
|
|
46
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-ignored-replay-buffer.ts)
|
|
47
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-ignored-replay-buffer.test.ts)
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Disallow calling `subscribe` without specifying arguments (`rxjs-x/no-ignored-subscribe`)
|
|
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 effects failures whenever `subscribe` is called without handlers.
|
|
8
|
-
|
|
9
|
-
## Rule details
|
|
10
|
-
|
|
11
|
-
Examples of **incorrect** code for this rule:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { of } from "rxjs";
|
|
15
|
-
import { tap } from "rxjs/operators";
|
|
16
|
-
|
|
17
|
-
of(42, 54).pipe(
|
|
18
|
-
tap((value) => console.log(value))
|
|
19
|
-
).subscribe();
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
Examples of **correct** code for this rule:
|
|
23
|
-
|
|
24
|
-
```ts
|
|
25
|
-
import { of } from "rxjs";
|
|
26
|
-
|
|
27
|
-
of(42, 54).subscribe((value) => console.log(value));
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## When Not To Use It
|
|
31
|
-
|
|
32
|
-
If you don't care about errors or output of some observables in your project, you may not need this rule.
|
|
33
|
-
Alternatively, you may require all logic to go in the `pipe` section of your observables.
|
|
34
|
-
In that case, you should not use this rule and should enable [`no-subscribe-handlers`](./no-subscribe-handlers.md) instead,
|
|
35
|
-
which is the opposite of this rule.
|
|
36
|
-
|
|
37
|
-
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
|
|
38
|
-
|
|
39
|
-
## Related To
|
|
40
|
-
|
|
41
|
-
- [`no-subscribe-handlers`](./no-subscribe-handlers.md)
|
|
42
|
-
|
|
43
|
-
## Resources
|
|
44
|
-
|
|
45
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-ignored-subscribe.ts)
|
|
46
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-ignored-subscribe.test.ts)
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
# Disallow ignoring the subscription returned by `subscribe` (`rxjs-x/no-ignored-subscription`)
|
|
2
|
-
|
|
3
|
-
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
4
|
-
|
|
5
|
-
<!-- end auto-generated rule header -->
|
|
6
|
-
|
|
7
|
-
The effects failures if an subscription returned by call to `subscribe` is neither assigned to a variable or property or passed to a function.
|
|
8
|
-
|
|
9
|
-
## Rule details
|
|
10
|
-
|
|
11
|
-
Examples of **incorrect** code for this rule:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
interval(1e3).subscribe(
|
|
15
|
-
(value) => console.log(value)
|
|
16
|
-
);
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Examples of **correct** code for this rule:
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
const subscription = interval(1e3).subscribe(
|
|
23
|
-
(value) => console.log(value)
|
|
24
|
-
);
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
When subscribers are passed to `subscribe` they are chained, so the returned subscription can be ignored:
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
const numbers = new Observable<number>(subscriber => {
|
|
31
|
-
interval(1e3).subscribe(subscriber);
|
|
32
|
-
});
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## When Not To Use It
|
|
36
|
-
|
|
37
|
-
If you don't care about unsubscribing from all observables in your project, then you may not need this rule.
|
|
38
|
-
Alternatively, your project might use operators like `take`, `takeUntil`, `takeWhile`, etc.
|
|
39
|
-
or Angular's `takeUntilDestroyed` to automatically handle subscriptions.
|
|
40
|
-
|
|
41
|
-
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
|
|
42
|
-
|
|
43
|
-
## Resources
|
|
44
|
-
|
|
45
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-ignored-subscription.ts)
|
|
46
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-ignored-subscription.test.ts)
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# Disallow ignoring the value within `takeWhile` (`rxjs-x/no-ignored-takewhile-value`)
|
|
2
|
-
|
|
3
|
-
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
|
|
4
|
-
|
|
5
|
-
<!-- end auto-generated rule header -->
|
|
6
|
-
|
|
7
|
-
This rule effects failures if the value received by a `takeWhile` callback is not used in an expression.
|
|
8
|
-
|
|
9
|
-
## Rule details
|
|
10
|
-
|
|
11
|
-
Examples of **incorrect** code for this rule:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { takeWhile } from "rxjs/operators";
|
|
15
|
-
|
|
16
|
-
let flag = true;
|
|
17
|
-
const whilst = source.pipe(takeWhile(() => flag));
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Examples of **correct** code for this rule:
|
|
21
|
-
|
|
22
|
-
```ts
|
|
23
|
-
import { takeWhile } from "rxjs/operators";
|
|
24
|
-
|
|
25
|
-
const whilst = source.pipe(takeWhile(value => value));
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## When Not To Use It
|
|
29
|
-
|
|
30
|
-
If you don't care about using the given value in a `takeWhile` callback, then you don't need this rule.
|
|
31
|
-
|
|
32
|
-
## Resources
|
|
33
|
-
|
|
34
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-ignored-takewhile-value.ts)
|
|
35
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-ignored-takewhile-value.test.ts)
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# Disallow implicit `any` error parameters in `catchError` operators (`rxjs-x/no-implicit-any-catch`)
|
|
2
|
-
|
|
3
|
-
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
|
|
4
|
-
|
|
5
|
-
🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
|
|
6
|
-
|
|
7
|
-
💭 This rule requires [type information](https://typescript-eslint.io/linting/typed-linting).
|
|
8
|
-
|
|
9
|
-
<!-- end auto-generated rule header -->
|
|
10
|
-
|
|
11
|
-
This rule requires an explicit type annotation for error parameters in error handlers.
|
|
12
|
-
It's similar to the typescript-eslint [`use-unknown-in-catch-callback-variable`](https://typescript-eslint.io/rules/use-unknown-in-catch-callback-variable/) rule
|
|
13
|
-
or the TSConfig [`useUnknownInCatchVariables`](https://www.typescriptlang.org/tsconfig/#useUnknownInCatchVariables) option,
|
|
14
|
-
but is for observables - not `try`/`catch` statements.
|
|
15
|
-
|
|
16
|
-
## Rule details
|
|
17
|
-
|
|
18
|
-
Examples of **incorrect** code for this rule:
|
|
19
|
-
|
|
20
|
-
```ts
|
|
21
|
-
import { throwError } from "rxjs";
|
|
22
|
-
import { catchError } from "rxjs/operators";
|
|
23
|
-
|
|
24
|
-
throwError(() => new Error("Kaboom!")).pipe(
|
|
25
|
-
catchError((error) => console.error(error))
|
|
26
|
-
);
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
import { throwError } from "rxjs";
|
|
31
|
-
|
|
32
|
-
throwError(() => new Error("Kaboom!")).subscribe({
|
|
33
|
-
error: (error) => console.error(error)
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
import { throwError } from "rxjs";
|
|
39
|
-
import { tap } from "rxjs/operators";
|
|
40
|
-
|
|
41
|
-
throwError(() => new Error("Kaboom!")).pipe(
|
|
42
|
-
tap(undefined, (error) => console.error(error))
|
|
43
|
-
);
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
Examples of **correct** code for this rule:
|
|
47
|
-
|
|
48
|
-
```ts
|
|
49
|
-
import { throwError } from "rxjs";
|
|
50
|
-
import { catchError } from "rxjs/operators";
|
|
51
|
-
|
|
52
|
-
throwError(() => new Error("Kaboom!")).pipe(
|
|
53
|
-
catchError((error: unknown) => console.error(error))
|
|
54
|
-
);
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
```ts
|
|
58
|
-
import { throwError } from "rxjs";
|
|
59
|
-
|
|
60
|
-
throwError(() => new Error("Kaboom!")).subscribe({
|
|
61
|
-
error: (error: unknown) => console.error(error)
|
|
62
|
-
});
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
import { throwError } from "rxjs";
|
|
67
|
-
import { tap } from "rxjs/operators";
|
|
68
|
-
|
|
69
|
-
throwError(() => new Error("Kaboom!")).pipe(
|
|
70
|
-
tap(undefined, (error: unknown) => console.error(error))
|
|
71
|
-
);
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
## Options
|
|
75
|
-
|
|
76
|
-
<!-- begin auto-generated rule options list -->
|
|
77
|
-
|
|
78
|
-
| Name | Description | Type | Default |
|
|
79
|
-
| :----------------- | :---------------------------------------------------- | :------ | :------ |
|
|
80
|
-
| `allowExplicitAny` | Allow error variable to be explicitly typed as `any`. | Boolean | `true` |
|
|
81
|
-
|
|
82
|
-
<!-- end auto-generated rule options list -->
|
|
83
|
-
|
|
84
|
-
This rule accepts a single option which is an object with an `allowExplicitAny` property that determines whether or not the error variable can be explicitly typed as `any`. By default, the use of explicit `any` is allowed.
|
|
85
|
-
|
|
86
|
-
```json
|
|
87
|
-
{
|
|
88
|
-
"rxjs-x/no-implicit-any-catch": [
|
|
89
|
-
"error",
|
|
90
|
-
{ "allowExplicitAny": true }
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## When Not To Use It
|
|
96
|
-
|
|
97
|
-
If your codebase is not yet able to enable `useUnknownInCatchVariables`,
|
|
98
|
-
it likely would be similarly difficult to enable this rule.
|
|
99
|
-
|
|
100
|
-
Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
|
|
101
|
-
|
|
102
|
-
## Further reading
|
|
103
|
-
|
|
104
|
-
- [Catching Unknowns](https://ncjamieson.com/catching-unknowns/)
|
|
105
|
-
|
|
106
|
-
## Resources
|
|
107
|
-
|
|
108
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-implicit-any-catch.ts)
|
|
109
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-implicit-any-catch.test.ts)
|
package/docs/rules/no-index.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
# Disallow importing index modules (`rxjs-x/no-index`)
|
|
2
|
-
|
|
3
|
-
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
|
|
4
|
-
|
|
5
|
-
<!-- end auto-generated rule header -->
|
|
6
|
-
|
|
7
|
-
This rule effects failures if an index module is specified as the import location.
|
|
8
|
-
|
|
9
|
-
## Rule details
|
|
10
|
-
|
|
11
|
-
Examples of **incorrect** code for this rule:
|
|
12
|
-
|
|
13
|
-
```ts
|
|
14
|
-
import { of } from "rxjs/index";
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Examples of **correct** code for this rule:
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
import { of } from "rxjs";
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
## When Not To Use It
|
|
24
|
-
|
|
25
|
-
If you don't care about unnecessary import path segments, then you don't need this rule.
|
|
26
|
-
|
|
27
|
-
## Further reading
|
|
28
|
-
|
|
29
|
-
- [Importing instructions](https://rxjs.dev/guide/importing)
|
|
30
|
-
|
|
31
|
-
## Resources
|
|
32
|
-
|
|
33
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-index.ts)
|
|
34
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-index.test.ts)
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
# Disallow importing internal modules (`rxjs-x/no-internal`)
|
|
2
|
-
|
|
3
|
-
💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
|
|
4
|
-
|
|
5
|
-
🔧💡 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix) and manually fixable by [editor suggestions](https://eslint.org/docs/latest/use/core-concepts#rule-suggestions).
|
|
6
|
-
|
|
7
|
-
<!-- end auto-generated rule header -->
|
|
8
|
-
|
|
9
|
-
This rule effects failures if an internal module is specified as the import location.
|
|
10
|
-
|
|
11
|
-
## Rule details
|
|
12
|
-
|
|
13
|
-
Examples of **incorrect** code for this rule:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
import { of } from "rxjs/internal/observable/of";
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Examples of **correct** code for this rule:
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
import { of } from "rxjs";
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## When Not To Use It
|
|
26
|
-
|
|
27
|
-
If you need to import internal modules that are not covered by the public API,
|
|
28
|
-
then you don't need this rule.
|
|
29
|
-
However, keep in mind that internal modules may change without notice.
|
|
30
|
-
|
|
31
|
-
## Further reading
|
|
32
|
-
|
|
33
|
-
- [Importing instructions](https://rxjs.dev/guide/importing)
|
|
34
|
-
|
|
35
|
-
## Resources
|
|
36
|
-
|
|
37
|
-
- [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-internal.ts)
|
|
38
|
-
- [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-internal.test.ts)
|