eslint-plugin-rxjs-x 0.7.0 → 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 (50) hide show
  1. package/dist/index.d.mts +1 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +18 -5
  4. package/dist/index.mjs +18 -5
  5. package/package.json +15 -16
  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 -32
  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,40 +0,0 @@
1
- # Disallow unsafe `first`/`take` usage in effects and epics (`rxjs-x/no-unsafe-first`)
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 `first` is used in an effect or epic in a manner that will complete the outermost observable.
8
-
9
- ## Options
10
-
11
- <!-- begin auto-generated rule options list -->
12
-
13
- | Name | Description | Type | Default |
14
- | :----------- | :------------------------------------------------------------ | :----- | :----------------------- |
15
- | `observable` | A RegExp that matches an effect or epic's actions observable. | String | `[Aa]ction(s\|s\$\|\$)$` |
16
-
17
- <!-- end auto-generated rule options list -->
18
-
19
- 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.
20
-
21
- ```json
22
- {
23
- "rxjs-x/no-unsafe-first": [
24
- "error",
25
- { "observable": "[Aa]ction(s|s\\$|\\$)$" }
26
- ]
27
- }
28
- ```
29
-
30
- ## When Not To Use It
31
-
32
- If you don't use a library with effects and epics (e.g. NgRx or redux-observable),
33
- then you don't need this rule.
34
-
35
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
36
-
37
- ## Resources
38
-
39
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-unsafe-first.ts)
40
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-unsafe-first.test.ts)
@@ -1,46 +0,0 @@
1
- # Disallow unsafe optional `next` calls (`rxjs-x/no-unsafe-subject-next`)
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 `next` is called without an argument and the subject's value type is not `void`.
10
-
11
- In RxJS version 6, the `next` method's `value` parameter was optional, but a value should always be specified for subjects with non-`void` element types.
12
- RxJS version 7 changed the `value` parameter to mandatory.
13
-
14
- ## Rule details
15
-
16
- Examples of **incorrect** code for this rule:
17
-
18
- ```ts
19
- const subject = new Subject<number>();
20
- subject.next();
21
- ```
22
-
23
- Examples of **correct** code for this rule:
24
-
25
- ```ts
26
- const subject = new Subject<void>();
27
- subject.next();
28
- ```
29
-
30
- ```ts
31
- const subject = new Subject<number>();
32
- subject.next(0);
33
- ```
34
-
35
- ## When Not To Use It
36
-
37
- If you don't care about sending `undefined` to subjects, then you don't need this rule.
38
- Alternatively, you may rely on TypeScript to enforce the `value` parameter,
39
- which was made mandatory in RxJS version 7.
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-unsafe-subject-next.ts)
46
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-unsafe-subject-next.test.ts)
@@ -1,64 +0,0 @@
1
- # Disallow unsafe `switchMap` usage in effects and epics (`rxjs-x/no-unsafe-switchmap`)
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 `switchMap` is used in effects or epics that perform actions other than reads. For a detailed explanation, see the blog post linked below.
8
-
9
- ## Options
10
-
11
- <!-- begin auto-generated rule options list -->
12
-
13
- | Name | Description | Type | Default |
14
- | :----------- | :------------------------------------------------------------------------------------------- | :----- | :----------------------- |
15
- | `allow` | Action types that are allowed to be used with switchMap. Mutually exclusive with `disallow`. | | |
16
- | `disallow` | Action types that are disallowed to be used with switchMap. Mutually exclusive with `allow`. | | |
17
- | `observable` | A RegExp that matches an effect or epic's actions observable. | String | `[Aa]ction(s\|s\$\|\$)$` |
18
-
19
- <!-- end auto-generated rule options list -->
20
-
21
- This rule accepts a single option which is an object with `allow`, `disallow` and `observable` properties.
22
-
23
- The `observable` property 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.
24
-
25
- The `allow` or `disallow` properties are mutually exclusive. Whether or not `switchMap` is allowed will depend upon the matching of action types with `allow` or `disallow`. The properties can be specified as regular expression strings or as arrays of words.
26
-
27
- ```json
28
- {
29
- "rxjs-x/no-unsafe-switchmap": [
30
- "error",
31
- {
32
- "disallow": [
33
- "add",
34
- "create",
35
- "delete",
36
- "post",
37
- "put",
38
- "remove",
39
- "set",
40
- "update"
41
- ],
42
- "observable": "[Aa]ction(s|s\\$|\\$)$"
43
- }
44
- ]
45
- }
46
- ```
47
-
48
- The properties in the options object are themselves optional; they do not all have to be specified.
49
-
50
- ## When Not To Use It
51
-
52
- If you don't use a library with effects and epics (e.g. NgRx or redux-observable),
53
- then you don't need this rule.
54
-
55
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
56
-
57
- ## Further reading
58
-
59
- - [Avoiding switchMap-related bugs](https://ncjamieson.com/avoiding-switchmap-related-bugs/)
60
-
61
- ## Resources
62
-
63
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-unsafe-switchmap.ts)
64
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-unsafe-switchmap.test.ts)
@@ -1,72 +0,0 @@
1
- # Disallow applying operators after `takeUntil` (`rxjs-x/no-unsafe-takeuntil`)
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 whenever `takeUntil` is used in observable compositions that can leak subscriptions.
10
-
11
- Although it's recommended that `takeUntil` be placed last - to ensure unsubscription from any inner observables - there are a number of operators that might _need_ to be placed after it - like `toArray` or any other operator that depends upon a `complete` notification. The rule is aware of these operators (see the rule's options, below) and will not effect failures if they are placed after `takeUntil`.
12
-
13
- ## Rule details
14
-
15
- Examples of **incorrect** code for this rule:
16
-
17
- ```ts
18
- const combined = source
19
- .pipe(takeUntil(notifier), combineLatest(b))
20
- .subscribe((value) => console.log(value));
21
- ```
22
-
23
- Examples of **correct** code for this rule:
24
-
25
- ```ts
26
- const combined = source
27
- .pipe(combineLatest(b), takeUntil(notifier))
28
- .subscribe((value) => console.log(value));
29
- ```
30
-
31
- ## Options
32
-
33
- <!-- begin auto-generated rule options list -->
34
-
35
- | Name | Description | Type | Default |
36
- | :------ | :-------------------------------------------------------------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37
- | `alias` | An array of operator names that should be treated similarly to `takeUntil`. | String[] | |
38
- | `allow` | An array of operator names that are allowed to follow `takeUntil`. | String[] | [`count`, `defaultIfEmpty`, `endWith`, `every`, `finalize`, `finally`, `isEmpty`, `last`, `max`, `min`, `publish`, `publishBehavior`, `publishLast`, `publishReplay`, `reduce`, `share`, `shareReplay`, `skipLast`, `takeLast`, `throwIfEmpty`, `toArray`] |
39
-
40
- <!-- end auto-generated rule options list -->
41
-
42
- This rule accepts a single option which is an object with `alias` and `allow` properties. The `alias` property is an array of names of operators that should be treated similarly to `takeUntil` and the `allow` property is an array of names of operators that are safe to use after `takeUntil`.
43
-
44
- By default, the `allow` property contains all of the built-in operators that are safe to use after `takeUntil`.
45
-
46
- ```json
47
- {
48
- "rxjs-x/no-unsafe-takeuntil": [
49
- "error",
50
- {
51
- "alias": ["untilDestroyed"]
52
- }
53
- ]
54
- }
55
- ```
56
-
57
- The properties in the options object are themselves optional; they do not all have to be specified.
58
-
59
- ## When Not To Use It
60
-
61
- If you are confident your project uses `takeUntil` correctly, then you may not need this rule.
62
-
63
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
64
-
65
- ## Further reading
66
-
67
- - [Avoiding takeUntil leaks](https://ncjamieson.com/avoiding-takeuntil-leaks/)
68
-
69
- ## Resources
70
-
71
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-unsafe-takeuntil.ts)
72
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-unsafe-takeuntil.test.ts)
@@ -1,66 +0,0 @@
1
- # Disallow passing separate handlers to `subscribe` and `tap` (`rxjs-x/prefer-observer`)
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 effects failures if `subscribe` - or `tap` - is called with separate handlers instead of an observer.
12
-
13
- ## Rule details
14
-
15
- Examples of **incorrect** code for this rule:
16
-
17
- ```ts
18
- import { of } from "rxjs";
19
- of(42, 54).subscribe((value) => console.log(value));
20
- ```
21
-
22
- Examples of **correct** code for this rule:
23
-
24
- ```ts
25
- import { of } from "rxjs";
26
- of(42, 54).subscribe({
27
- next: (value) => console.log(value)
28
- });
29
- ```
30
-
31
- ## Options
32
-
33
- <!-- begin auto-generated rule options list -->
34
-
35
- | Name | Description | Type | Default |
36
- | :---------- | :------------------------------- | :------ | :------ |
37
- | `allowNext` | Allows a single `next` callback. | Boolean | `true` |
38
-
39
- <!-- end auto-generated rule options list -->
40
-
41
- This rule accepts a single option which is an object with an `allowNext` property that determines whether a single `next` callback is allowed. By default, `allowNext` is `true`.
42
-
43
- ```json
44
- {
45
- "rxjs-x/prefer-observer": [
46
- "error",
47
- { "allowNext": false }
48
- ]
49
- }
50
- ```
51
-
52
- ## When Not To Use It
53
-
54
- If you rely on RxJS's deprecation of separate handlers and don't need to double-flag usage,
55
- then you don't need this rule.
56
-
57
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
58
-
59
- ## Further reading
60
-
61
- - [Subscribe Arguments](https://rxjs.dev/deprecations/subscribe-arguments)
62
-
63
- ## Resources
64
-
65
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/prefer-observer.ts)
66
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/prefer-observer.test.ts)
@@ -1,45 +0,0 @@
1
- # Disallow importing operators from `rxjs/operators` (`rxjs-x/prefer-root-operators`)
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 prevents importing from the `rxjs/operators` export site.
10
- Most operators were moved to the `rxjs` export site in RxJS v7.2.0
11
- (excepting a few old and deprecated operators).
12
- The `rxjs/operators` export site has since been deprecated and will be removed in a future major version.
13
-
14
- Note that because a few operators were renamed or not migrated to the `rxjs` export site,
15
- this rule may not provide an automatic fixer if renaming the import path is not guaranteed to be safe.
16
- See the documentation linked below.
17
-
18
- ## Rule details
19
-
20
- Examples of **incorrect** code for this rule:
21
-
22
- ```ts
23
- import { map } from 'rxjs/operators';
24
- ```
25
-
26
- Examples of **correct** code for this rule:
27
-
28
- ```ts
29
- import { map } from 'rxjs';
30
- ```
31
-
32
- ## When Not To Use It
33
-
34
- If you don't care about importing from the deprecated site, then you don't need this rule.
35
-
36
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
37
-
38
- ## Further reading
39
-
40
- - [Importing instructions](https://rxjs.dev/guide/importing)
41
-
42
- ## Resources
43
-
44
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/prefer-root-operators.ts)
45
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/prefer-root-operators.test.ts)
@@ -1,81 +0,0 @@
1
- # Enforce the use of a suffix in subject identifiers (`rxjs-x/suffix-subjects`)
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 subject variables, properties and parameters don't conform to a naming scheme that identifies them as subjects.
8
-
9
- > [!NOTE]
10
- > This rule is designed to be optionally compatible with [`finnish`](./finnish.md).
11
- > Using Finnish notation (adding a `$` suffix) your subject names will _not_ cause a failure of this rule.
12
-
13
- ## Rule details
14
-
15
- Examples of **incorrect** code for this rule:
16
-
17
- ```ts
18
- const answers = new Subject<number>();
19
- ```
20
-
21
- Examples of **correct** code for this rule:
22
-
23
- ```ts
24
- const answersSubject = new Subject<number>();
25
- const answersSubject$ = new Subject<number>();
26
- ```
27
-
28
- ## Options
29
-
30
- <!-- begin auto-generated rule options list -->
31
-
32
- | Name | Description | Type |
33
- | :----------- | :------------------------------------------------------------------- | :------ |
34
- | `parameters` | Require for parameters. | Boolean |
35
- | `properties` | Require for properties. | Boolean |
36
- | `suffix` | The suffix to enforce. | String |
37
- | `types` | Enforce for specific types. Keys are a RegExp, values are a boolean. | Object |
38
- | `variables` | Require for variables. | Boolean |
39
-
40
- <!-- end auto-generated rule options list -->
41
-
42
- This rule accepts a single option which is an object with properties that determine whether subject suffixes are enforced for `parameters`, `properties` and `variables`.
43
- It also contains a `types` property that determine whether or not the naming convention is to be enforced for specific types
44
- and a `suffix` property.
45
-
46
- The default (Angular-friendly) configuration looks like this:
47
-
48
- ```json
49
- {
50
- "rxjs-x/suffix-subjects": [
51
- "error",
52
- {
53
- "parameters": true,
54
- "properties": true,
55
- "suffix": "Subject",
56
- "types": {
57
- "^EventEmitter$": false
58
- },
59
- "variables": true,
60
- }
61
- ]
62
- }
63
- ```
64
-
65
- The properties in the options object are themselves optional; they do not all have to be specified.
66
-
67
- ## When Not To Use It
68
-
69
- If you don't use suffixes on your project's subjects, then you don't need this rule.
70
- However, keep in mind that inconsistent style can harm readability in a project.
71
-
72
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
73
-
74
- ## Related To
75
-
76
- - [`finnish`](./finnish.md)
77
-
78
- ## Resources
79
-
80
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/suffix-subjects.ts)
81
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/suffix-subjects.test.ts)
@@ -1,53 +0,0 @@
1
- # Enforce passing only `Error` values to `throwError` (`rxjs-x/throw-error`)
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 forbids passing values that are not `Error` objects to `throwError`.
10
- It's similar to the typescript-eslint [`only-throw-error`](https://typescript-eslint.io/rules/only-throw-error/) rule,
11
- but is for the `throwError` Observable creation function - not `throw` statements.
12
-
13
- ## Rule details
14
-
15
- Examples of **incorrect** code for this rule:
16
-
17
- ```ts
18
- import { throwError } from "rxjs";
19
-
20
- throwError(() => "Kaboom!");
21
- ```
22
-
23
- Examples of **correct** code for this rule:
24
-
25
- ```ts
26
- import { throwError } from "rxjs";
27
-
28
- throwError(() => new Error("Kaboom!"));
29
- ```
30
-
31
- ## Options
32
-
33
- <!-- begin auto-generated rule options list -->
34
-
35
- | Name | Description | Type | Default |
36
- | :--------------------- | :---------------------------------------------------------- | :------ | :------ |
37
- | `allowThrowingAny` | Whether to always allow throwing values typed as `any`. | Boolean | `true` |
38
- | `allowThrowingUnknown` | Whether to always allow throwing values typed as `unknown`. | Boolean | `true` |
39
-
40
- <!-- end auto-generated rule options list -->
41
-
42
- ## When Not To Use It
43
-
44
- If you don't care about throwing values that are not `Error` objects, then you don't need this rule.
45
- However, keep in mind that, while JavaScript _allows_ throwing any value,
46
- most developer may find this behavior surprising or inconvenient to handle.
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/throw-error.ts)
53
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/throw-error.test.ts)