eslint-plugin-rxjs-x 0.7.1 → 0.7.3

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 (50) hide show
  1. package/dist/index.d.mts +4 -1
  2. package/dist/index.d.ts +4 -1
  3. package/dist/index.js +216 -153
  4. package/dist/index.mjs +252 -189
  5. package/package.json +19 -20
  6. package/docs/rules/ban-observables.md +0 -42
  7. package/docs/rules/ban-operators.md +0 -44
  8. package/docs/rules/finnish.md +0 -91
  9. package/docs/rules/just.md +0 -20
  10. package/docs/rules/macro.md +0 -11
  11. package/docs/rules/no-async-subscribe.md +0 -54
  12. package/docs/rules/no-compat.md +0 -13
  13. package/docs/rules/no-connectable.md +0 -33
  14. package/docs/rules/no-create.md +0 -43
  15. package/docs/rules/no-cyclic-action.md +0 -88
  16. package/docs/rules/no-explicit-generics.md +0 -32
  17. package/docs/rules/no-exposed-subjects.md +0 -68
  18. package/docs/rules/no-finnish.md +0 -42
  19. package/docs/rules/no-floating-observables.md +0 -68
  20. package/docs/rules/no-ignored-default-value.md +0 -43
  21. package/docs/rules/no-ignored-error.md +0 -53
  22. package/docs/rules/no-ignored-notifier.md +0 -47
  23. package/docs/rules/no-ignored-replay-buffer.md +0 -47
  24. package/docs/rules/no-ignored-subscribe.md +0 -46
  25. package/docs/rules/no-ignored-subscription.md +0 -46
  26. package/docs/rules/no-ignored-takewhile-value.md +0 -35
  27. package/docs/rules/no-implicit-any-catch.md +0 -109
  28. package/docs/rules/no-index.md +0 -34
  29. package/docs/rules/no-internal.md +0 -38
  30. package/docs/rules/no-misused-observables.md +0 -101
  31. package/docs/rules/no-nested-subscribe.md +0 -46
  32. package/docs/rules/no-redundant-notify.md +0 -50
  33. package/docs/rules/no-sharereplay.md +0 -49
  34. package/docs/rules/no-subclass.md +0 -23
  35. package/docs/rules/no-subject-unsubscribe.md +0 -63
  36. package/docs/rules/no-subject-value.md +0 -19
  37. package/docs/rules/no-subscribe-handlers.md +0 -53
  38. package/docs/rules/no-subscribe-in-pipe.md +0 -55
  39. package/docs/rules/no-tap.md +0 -7
  40. package/docs/rules/no-topromise.md +0 -37
  41. package/docs/rules/no-unbound-methods.md +0 -61
  42. package/docs/rules/no-unsafe-catch.md +0 -74
  43. package/docs/rules/no-unsafe-first.md +0 -40
  44. package/docs/rules/no-unsafe-subject-next.md +0 -46
  45. package/docs/rules/no-unsafe-switchmap.md +0 -64
  46. package/docs/rules/no-unsafe-takeuntil.md +0 -72
  47. package/docs/rules/prefer-observer.md +0 -66
  48. package/docs/rules/prefer-root-operators.md +0 -45
  49. package/docs/rules/suffix-subjects.md +0 -81
  50. package/docs/rules/throw-error.md +0 -53
@@ -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)
@@ -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)
@@ -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)