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.
Files changed (48) hide show
  1. package/dist/index.js +11 -3
  2. package/dist/index.mjs +11 -3
  3. package/package.json +15 -16
  4. package/docs/rules/ban-observables.md +0 -42
  5. package/docs/rules/ban-operators.md +0 -44
  6. package/docs/rules/finnish.md +0 -91
  7. package/docs/rules/just.md +0 -20
  8. package/docs/rules/macro.md +0 -11
  9. package/docs/rules/no-async-subscribe.md +0 -54
  10. package/docs/rules/no-compat.md +0 -13
  11. package/docs/rules/no-connectable.md +0 -33
  12. package/docs/rules/no-create.md +0 -43
  13. package/docs/rules/no-cyclic-action.md +0 -88
  14. package/docs/rules/no-explicit-generics.md +0 -32
  15. package/docs/rules/no-exposed-subjects.md +0 -68
  16. package/docs/rules/no-finnish.md +0 -42
  17. package/docs/rules/no-floating-observables.md +0 -68
  18. package/docs/rules/no-ignored-default-value.md +0 -43
  19. package/docs/rules/no-ignored-error.md +0 -53
  20. package/docs/rules/no-ignored-notifier.md +0 -47
  21. package/docs/rules/no-ignored-replay-buffer.md +0 -47
  22. package/docs/rules/no-ignored-subscribe.md +0 -46
  23. package/docs/rules/no-ignored-subscription.md +0 -46
  24. package/docs/rules/no-ignored-takewhile-value.md +0 -35
  25. package/docs/rules/no-implicit-any-catch.md +0 -109
  26. package/docs/rules/no-index.md +0 -34
  27. package/docs/rules/no-internal.md +0 -38
  28. package/docs/rules/no-misused-observables.md +0 -101
  29. package/docs/rules/no-nested-subscribe.md +0 -46
  30. package/docs/rules/no-redundant-notify.md +0 -50
  31. package/docs/rules/no-sharereplay.md +0 -49
  32. package/docs/rules/no-subclass.md +0 -23
  33. package/docs/rules/no-subject-unsubscribe.md +0 -63
  34. package/docs/rules/no-subject-value.md +0 -19
  35. package/docs/rules/no-subscribe-handlers.md +0 -53
  36. package/docs/rules/no-subscribe-in-pipe.md +0 -55
  37. package/docs/rules/no-tap.md +0 -7
  38. package/docs/rules/no-topromise.md +0 -37
  39. package/docs/rules/no-unbound-methods.md +0 -61
  40. package/docs/rules/no-unsafe-catch.md +0 -74
  41. package/docs/rules/no-unsafe-first.md +0 -40
  42. package/docs/rules/no-unsafe-subject-next.md +0 -46
  43. package/docs/rules/no-unsafe-switchmap.md +0 -64
  44. package/docs/rules/no-unsafe-takeuntil.md +0 -72
  45. package/docs/rules/prefer-observer.md +0 -66
  46. package/docs/rules/prefer-root-operators.md +0 -45
  47. package/docs/rules/suffix-subjects.md +0 -81
  48. package/docs/rules/throw-error.md +0 -53
@@ -1,101 +0,0 @@
1
- # Disallow Observables in places not designed to handle them (`rxjs-x/no-misused-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
- This rule forbids providing observables to logical locations where the TypeScript compiler allows them but they are not handled properly.
10
- These situations can often arise due to a misunderstanding of the way observables are handled.
11
-
12
- > [!TIP]
13
- > `no-misused-observables` only detects code that provides observables to incorrect _logical_ locations.
14
- > See [`no-floating-observables`](./no-floating-observables.md) for detecting unhandled observable _statements_.
15
-
16
- This rule is like [no-misused-promises](https://typescript-eslint.io/rules/no-misused-promises) but for Observables.
17
-
18
- > [!NOTE]
19
- > Unlike `@typescript-eslint/no-misused-promises`, this rule does not check conditionals like `if` statements.
20
- > Use `@typescript-eslint/no-unnecessary-condition` for linting those situations.
21
-
22
- ## Rule details
23
-
24
- Examples of **incorrect** code for this rule:
25
-
26
- ```ts
27
- import { of } from "rxjs";
28
-
29
- [1, 2, 3].forEach(i => of(i));
30
-
31
- interface MySyncInterface {
32
- foo(): void;
33
- }
34
- class MyRxClass implements MySyncInterface {
35
- foo(): Observable<number> {
36
- return of(42);
37
- }
38
- }
39
-
40
- const a = of(42);
41
- const b = { ...b };
42
- ```
43
-
44
- Examples of **correct** code for this rule:
45
-
46
- ```ts
47
- import { of } from "rxjs";
48
-
49
- [1, 2, 3].map(i => of(i));
50
-
51
- interface MyRxInterface {
52
- foo(): Observable<number>;
53
- }
54
- class MyRxClass implements MyRxInterface {
55
- foo(): Observable<number> {
56
- return of(42);
57
- }
58
- }
59
- ```
60
-
61
- ## Options
62
-
63
- <!-- WARNING: not auto-generated! -->
64
-
65
- | Name | Description | Type | Default |
66
- | :----------------- | :-------------------------------------------------------------------------- | :------ | :------ |
67
- | `checksSpreads` | Disallow `...` spreading an Observable. | Boolean | `true` |
68
- | `checksVoidReturn` | Disallow returning an Observable from a function typed as returning `void`. | Object | `true` |
69
-
70
- ### `checksVoidReturn`
71
-
72
- You can disable selective parts of the `checksVoidReturn` option. The following sub-options are supported:
73
-
74
- | Name | Description | Type | Default |
75
- | :----------------- | :--------------------------------------------------------------------------------------------------------------------------------------- | :------ | :------ |
76
- | `arguments` | Disallow passing an Observable-returning function as an argument where the parameter type expects a function that returns `void`. | Boolean | `true` |
77
- | `attributes` | Disallow passing an Observable-returning function as a JSX attribute expected to be a function that returns `void`. | Boolean | `true` |
78
- | `inheritedMethods` | Disallow providing an Observable-returning function where a function that returns `void` is expected by an extended or implemented type. | Boolean | `true` |
79
- | `properties` | Disallow providing an Observable-returning function where a function that returns `void` is expected by a property. | Boolean | `true` |
80
- | `returns` | Disallow returning an Observable-returning function where a function that returns `void` is expected. | Boolean | `true` |
81
- | `variables` | Disallow assigning or declaring an Observable-returning function where a function that returns `void` is expected. | Boolean | `true` |
82
-
83
- ## When Not To Use It
84
-
85
- Like `@typescript-eslint/no-misused-promises`,
86
- this rule can be difficult to enable on large existing projects that set up many misused observables.
87
-
88
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
89
-
90
- ## Further reading
91
-
92
- - [TypeScript void function assignability](https://github.com/Microsoft/TypeScript/wiki/FAQ#why-are-functions-returning-non-void-assignable-to-function-returning-void)
93
-
94
- ## Related To
95
-
96
- - [`no-floating-observables`](./no-floating-observables.md)
97
-
98
- ## Resources
99
-
100
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-misused-observables.ts)
101
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-misused-observables.test.ts)
@@ -1,46 +0,0 @@
1
- # Disallow calling `subscribe` within a `subscribe` callback (`rxjs-x/no-nested-subscribe`)
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 `subscribe` is called within a `subscribe` handler.
10
-
11
- ## Rule details
12
-
13
- Examples of **incorrect** code for this rule:
14
-
15
- ```ts
16
- import { of, timer } from "rxjs";
17
-
18
- of(42, 54).subscribe((value) => {
19
- timer(1e3).subscribe(() => console.log(value));
20
- });
21
- ```
22
-
23
- Examples of **correct** code for this rule:
24
-
25
- ```ts
26
- import { of, timer } from "rxjs";
27
- import { map, mergeMap } from "rxjs/operators";
28
-
29
- of(42, 54).pipe(
30
- mergeMap((value) => timer(1e3).pipe(map(() => value)))
31
- ).subscribe((value) => console.log(value));
32
- ```
33
-
34
- ## When Not To Use It
35
-
36
- If you need nested subscriptions and are aware of the potential issues,
37
- then you might not need this rule.
38
- However, you should typically prefer to use higher-order mapping operators
39
- like `mergeMap`, `switchMap`, or `concatMap` to handle nested observables.
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-nested-subscribe.ts)
46
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-nested-subscribe.test.ts)
@@ -1,50 +0,0 @@
1
- # Disallow sending redundant notifications from completed or errored observables (`rxjs-x/no-redundant-notify`)
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 an attempt is made to send a notification to an observer after a `complete` or `error` notification has already been sent,
10
- or if `unsubscribe` has been called.
11
-
12
- Note that the rule _does not perform extensive analysis_. It uses a straightforward and limited approach to catch obviously redundant notifications.
13
-
14
- ## Rule details
15
-
16
- Examples of **incorrect** code for this rule:
17
-
18
- ```ts
19
- import { Subject } from "rxjs";
20
-
21
- const subject = new Subject<number>();
22
- subject.next(42);
23
- subject.error(new Error("Kaboom!"));
24
- subject.complete();
25
- ```
26
-
27
- Examples of **correct** code for this rule:
28
-
29
- ```ts
30
- import { Subject } from "rxjs";
31
-
32
- const subject = new Subject<number>();
33
- subject.next(42);
34
- subject.error(new Error("Kaboom!"));
35
- ```
36
-
37
- ## When Not To Use It
38
-
39
- If you don't care about redundant notifications, then you don't need this rule.
40
-
41
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
42
-
43
- ## Related To
44
-
45
- - [`no-subject-unsubscribe`](./no-subject-unsubscribe.md)
46
-
47
- ## Resources
48
-
49
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-redundant-notify.ts)
50
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-redundant-notify.test.ts)
@@ -1,49 +0,0 @@
1
- # Disallow unsafe `shareReplay` usage (`rxjs-x/no-sharereplay`)
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 `shareReplay` operator is used - or if it is used without specifying a `config` argument.
8
-
9
- The behavior of `shareReplay` has changed several times - see the blog post linked below.
10
-
11
- ## Options
12
-
13
- <!-- begin auto-generated rule options list -->
14
-
15
- | Name | Description | Type | Default |
16
- | :------------ | :--------------------------------------------------- | :------ | :------ |
17
- | `allowConfig` | Allow shareReplay if a config argument is specified. | Boolean | `true` |
18
-
19
- <!-- end auto-generated rule options list -->
20
-
21
- This rule accepts a single option which is an object with an `allowConfig` property that that determines whether `shareReplay` is allow if a config argument is specified. By default, `allowConfig` is `true`.
22
-
23
- ```json
24
- {
25
- "rxjs-x/no-sharereplay": [
26
- "error",
27
- { "allowConfig": true }
28
- ]
29
- }
30
- ```
31
-
32
- ## When Not To Use It
33
-
34
- If you are confident that `shareReplay` is used properly your project,
35
- then you may not need this rule.
36
- However, keep in mind that it's recommended to always provide a config object
37
- that explicitly specifies `refCount` (see linked blog post);
38
- by default, `shareReplay` without any config defaults to `refCount: false`,
39
- which means the source observable will never be unsubscribed from,
40
- potentially leading to unexpected behavior and memory leaks.
41
-
42
- ## Further reading
43
-
44
- - [What's changed with shareReplay](https://ncjamieson.com/whats-changed-with-sharereplay/)
45
-
46
- ## Resources
47
-
48
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-sharereplay.ts)
49
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-sharereplay.test.ts)
@@ -1,23 +0,0 @@
1
- # Disallow subclassing RxJS classes (`rxjs-x/no-subclass`)
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 effects failures if an RxJS class is subclassed. Developers are encouraged to avoid subclassing RxJS classes, as some public and protected implementation details might change in the future.
10
-
11
- ## When Not To Use It
12
-
13
- If you need to subclass RxJS classes in your project, then don't use this rule.
14
- However, keep in mind that implementation details may change in the future;
15
- You might consider using ESLint disable comments for specific situations
16
- instead of completely disabling this rule.
17
-
18
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
19
-
20
- ## Resources
21
-
22
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-subclass.ts)
23
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-subclass.test.ts)
@@ -1,63 +0,0 @@
1
- # Disallow calling the `unsubscribe` method of subjects (`rxjs-x/no-subject-unsubscribe`)
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 `unsubscribe` method is called on subjects.
10
- The method behaves differently to the `unsubscribe` method on subscriptions and is often an error.
11
-
12
- This rule also effects failures if a subject is passed to a subscription's `add` method.
13
- Adding a subject to a subscription will cause the subject's `unsubscribe` method to get called
14
- when the subscription is unsubscribed.
15
-
16
- ## Rule details
17
-
18
- Examples of **incorrect** code for this rule:
19
-
20
- ```ts
21
- import { Subject } from "rxjs";
22
-
23
- const subject = new Subject<number>();
24
- subject.unsubscribe();
25
- ```
26
-
27
- ```ts
28
- import { Subject, Subscription } from "rxjs";
29
-
30
- const subject = new Subject<number>();
31
- const subscription = new Subscription();
32
- subscription.add(subject);
33
- ```
34
-
35
- Examples of **correct** code for this rule:
36
-
37
- ```ts
38
- import { Subject } from "rxjs";
39
-
40
- const subject = new Subject<number>();
41
- subject.complete();
42
- ```
43
-
44
- ## When Not To Use It
45
-
46
- If you intentionally use `unsubscribe` to cause errors when subjects are `next`-ed after closing,
47
- then you don't need this rule.
48
-
49
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
50
-
51
- ## Further reading
52
-
53
- - [Closed Subjects](https://ncjamieson.com/closed-subjects/)
54
- - [Composing Subscription](https://ncjamieson.com/composing-subscriptions/)
55
-
56
- ## Related To
57
-
58
- - [`no-redundant-notify`](./no-redundant-notify.md)
59
-
60
- ## Resources
61
-
62
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-subject-unsubscribe.ts)
63
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-subject-unsubscribe.test.ts)
@@ -1,19 +0,0 @@
1
- # Disallow accessing the `value` property of a `BehaviorSubject` instance (`rxjs-x/no-subject-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 effects an error if the `value` property - or `getValue` method - of a `BehaviorSubject` is used.
8
-
9
- ## When Not To Use It
10
-
11
- If your code uses the `value` property or the `getValue` method of `BehaviorSubject`,
12
- then don't enable this rule.
13
-
14
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
15
-
16
- ## Resources
17
-
18
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-subject-value.ts)
19
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-subject-value.test.ts)
@@ -1,53 +0,0 @@
1
- # Disallow passing handlers to `subscribe` (`rxjs-x/no-subscribe-handlers`)
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 with 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).subscribe((value) => console.log(value));
18
- ```
19
-
20
- ```ts
21
- import { of } from "rxjs";
22
- import { tap } from "rxjs/operators";
23
-
24
- of(42, 54).subscribe({
25
- next: (value) => console.log(value),
26
- });
27
- ```
28
-
29
- Examples of **correct** code for this rule:
30
-
31
- ```ts
32
- import { of } from "rxjs";
33
-
34
- of(42, 54)
35
- .pipe(tap((value) => console.log(value)))
36
- .subscribe();
37
- ```
38
-
39
- ## When Not To Use It
40
-
41
- If you don't require all logic to go in the `pipe` section of your observables, then you don't need this rule.
42
- Also, if your project uses `no-ignored-subscribe`, which is the opposite of this rule, then you should not use this rule.
43
-
44
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
45
-
46
- ## Related To
47
-
48
- - [`no-ignored-subscribe`](./no-ignored-subscribe.md)
49
-
50
- ## Resources
51
-
52
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-subscribe-handlers.ts)
53
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-subscribe-handlers.test.ts)
@@ -1,55 +0,0 @@
1
- # Disallow calling of `subscribe` within any RxJS operator inside a `pipe` (`rxjs-x/no-subscribe-in-pipe`)
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 `subscribe` is called within any operator inside a `pipe` operation.
10
-
11
- ## Rule details
12
-
13
- Examples of **incorrect** code for this rule:
14
-
15
- ```ts
16
- import { of } from "rxjs";
17
- import { map } from "rxjs/operators";
18
-
19
- of(42, 54).pipe(
20
- map(value => {
21
- of(value).subscribe(console.log);
22
- return value * 2;
23
- })
24
- ).subscribe(result => console.log(result));
25
- ```
26
-
27
- Examples of **correct** code for this rule:
28
-
29
- ```ts
30
- import { of } from "rxjs";
31
- import { map, tap } from "rxjs/operators";
32
-
33
- of(42, 54).pipe(
34
- tap(value => console.log(value)),
35
- map(value => value * 2)
36
- ).subscribe(result => console.log(result));
37
- ```
38
-
39
- ## When Not To Use It
40
-
41
- If you need to subscribe within `pipe` and are aware of the potential issues,
42
- then you might not need this rule.
43
- However, you should typically prefer to use higher-order mapping operators
44
- like `mergeMap`, `switchMap`, or `concatMap` to handle nested observables.
45
-
46
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
47
-
48
- ## Related To
49
-
50
- - [`no-nested-subscribe`](./no-nested-subscribe.md)
51
-
52
- ## Resources
53
-
54
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-subscribe-in-pipe.ts)
55
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-subscribe-in-pipe.test.ts)
@@ -1,7 +0,0 @@
1
- # Disallow the `tap` operator (`rxjs-x/no-tap`)
2
-
3
- ❌ This rule is deprecated. It was replaced by [`rxjs-x/ban-operators`](ban-operators.md).
4
-
5
- <!-- end auto-generated rule header -->
6
-
7
- This rule effects failures if the `tap` operator is used.
@@ -1,37 +0,0 @@
1
- # Disallow use of the `toPromise` method (`rxjs-x/no-topromise`)
2
-
3
- 💼 This rule is enabled in the following configs: ✅ `recommended`, 🔒 `strict`.
4
-
5
- 💡 This rule is 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 effects failures if the `toPromise` method is used.
12
-
13
- This rule provides three editor suggestions which replace `toPromise` with either:
14
-
15
- - `lastValueFrom(..., { defaultValue: undefined })`, which imitates the behavior of `toPromise`,
16
- - or `lastValueFrom(...)`, which throws `EmptyError` instead of defaulting to `undefined`,
17
- - or `firstValueFrom(...)`.
18
-
19
- ## When Not To Use It
20
-
21
- If you rely on RxJS's deprecation of `toPromise` and don't need to double-flag usage,
22
- then you don't need this rule.
23
-
24
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
25
-
26
- ## Further reading
27
-
28
- - [Conversion to Promises](https://rxjs.dev/deprecations/to-promise)
29
-
30
- ## Related To
31
-
32
- - [`no-ignored-default-value`](./no-ignored-default-value.md)
33
-
34
- ## Resources
35
-
36
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-topromise.ts)
37
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-topromise.test.ts)
@@ -1,61 +0,0 @@
1
- # Disallow passing unbound methods (`rxjs-x/no-unbound-methods`)
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 unbound methods are passed as callbacks.
10
-
11
- ## Rule details
12
-
13
- Examples of **incorrect** code for this rule:
14
-
15
- ```ts
16
- return this.http
17
- .get<Something>("https://api.some.com/things/1")
18
- .pipe(
19
- map(this.extractSomeProperty),
20
- catchError(this.handleError)
21
- );
22
- ```
23
-
24
- Examples of **correct** code for this rule:
25
-
26
- ```ts
27
- return this.http
28
- .get<Something>("https://api.some.com/things/1")
29
- .pipe(
30
- map((s) => this.extractSomeProperty(s)),
31
- catchError((e) => this.handleError(e))
32
- );
33
- ```
34
-
35
- ```ts
36
- return this.http
37
- .get<Something>("https://api.some.com/things/1")
38
- .pipe(
39
- map(this.extractSomeProperty.bind(this)),
40
- catchError(this.handleError.bind(this))
41
- );
42
- ```
43
-
44
- ## When Not To Use It
45
-
46
- If every handler in your project does not depend on the `this` context in their implementations,
47
- then in some cases it may be safe to not use this rule.
48
- However, keep in mind that future changes may introduce bugs
49
- by changing their implementations to depend on the `this` context;
50
- see the linked blog post for best practice explanation.
51
-
52
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
53
-
54
- ## Further reading
55
-
56
- - [Avoiding unbound methods](https://ncjamieson.com/avoiding-unbound-methods/)
57
-
58
- ## Resources
59
-
60
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-unbound-methods.ts)
61
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-unbound-methods.test.ts)
@@ -1,74 +0,0 @@
1
- # Disallow unsafe `catchError` usage in effects and epics (`rxjs-x/no-unsafe-catch`)
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 if `catchError` is used in an effect or epic in a manner that will complete the outermost observable.
8
-
9
- ## Rule details
10
-
11
- Examples of **incorrect** code for this rule:
12
-
13
- ```ts
14
- actions.pipe(
15
- ofType("SOMETHING"),
16
- switchMap((action) => something(action)),
17
- catchError(handleError)
18
- );
19
- ```
20
-
21
- Examples of **correct** code for this rule:
22
-
23
- ```ts
24
- actions.pipe(
25
- ofType("SOMETHING"),
26
- switchMap((action) => something(action).pipe(
27
- catchError(handleError)
28
- ))
29
- );
30
- ```
31
-
32
- ```ts
33
- actions.pipe(
34
- ofType("SOMETHING"),
35
- switchMap((action) => something(action)),
36
- catchError((error, caught) => {
37
- handleError(error);
38
- return caught;
39
- })
40
- );
41
- ```
42
-
43
- ## Options
44
-
45
- <!-- begin auto-generated rule options list -->
46
-
47
- | Name | Description | Type | Default |
48
- | :----------- | :------------------------------------------------------------ | :----- | :----------------------- |
49
- | `observable` | A RegExp that matches an effect or epic's actions observable. | String | `[Aa]ction(s\|s\$\|\$)$` |
50
-
51
- <!-- end auto-generated rule options list -->
52
-
53
- This rule accepts a single option which is an object with an `observable` property that is a regular expression used to match an effect or epic's actions observable. The default `observable` regular expression should match most effect and epic action sources.
54
-
55
- ```json
56
- {
57
- "rxjs-x/no-unsafe-catch": [
58
- "error",
59
- { "observable": "[Aa]ction(s|s\\$|\\$)$" }
60
- ]
61
- }
62
- ```
63
-
64
- ## When Not To Use It
65
-
66
- If you don't use a library with effects and epics (e.g. NgRx or redux-observable),
67
- then you don't need this rule.
68
-
69
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
70
-
71
- ## Resources
72
-
73
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-unsafe-catch.ts)
74
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-unsafe-catch.test.ts)