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
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// package.json
2
2
  var name = "eslint-plugin-rxjs-x";
3
- var version = "0.7.1";
3
+ var version = "0.7.2";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -370,11 +370,19 @@ function getTypeServices(context) {
370
370
  );
371
371
  };
372
372
  const couldReturnType = (node, name2, qualified) => {
373
- var _a;
374
373
  let tsTypeNode;
375
374
  const tsNode = esTreeNodeToTSNodeMap.get(node);
376
375
  if (_typescript2.default.isArrowFunction(tsNode) || _typescript2.default.isFunctionDeclaration(tsNode) || _typescript2.default.isMethodDeclaration(tsNode) || _typescript2.default.isFunctionExpression(tsNode)) {
377
- tsTypeNode = (_a = tsNode.type) != null ? _a : tsNode.body;
376
+ if (tsNode.type) {
377
+ tsTypeNode = tsNode.type;
378
+ } else if (tsNode.body && _typescript2.default.isBlock(tsNode.body)) {
379
+ const returnStatement = tsNode.body.statements.find(_typescript2.default.isReturnStatement);
380
+ if (returnStatement == null ? void 0 : returnStatement.expression) {
381
+ tsTypeNode = returnStatement.expression;
382
+ }
383
+ } else {
384
+ tsTypeNode = tsNode.body;
385
+ }
378
386
  } else if (_typescript2.default.isCallSignatureDeclaration(tsNode) || _typescript2.default.isMethodSignature(tsNode)) {
379
387
  tsTypeNode = tsNode.type;
380
388
  } else if (_typescript2.default.isPropertySignature(tsNode)) {
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "eslint-plugin-rxjs-x";
3
- var version = "0.7.1";
3
+ var version = "0.7.2";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -370,11 +370,19 @@ function getTypeServices(context) {
370
370
  );
371
371
  };
372
372
  const couldReturnType = (node, name2, qualified) => {
373
- var _a;
374
373
  let tsTypeNode;
375
374
  const tsNode = esTreeNodeToTSNodeMap.get(node);
376
375
  if (ts4.isArrowFunction(tsNode) || ts4.isFunctionDeclaration(tsNode) || ts4.isMethodDeclaration(tsNode) || ts4.isFunctionExpression(tsNode)) {
377
- tsTypeNode = (_a = tsNode.type) != null ? _a : tsNode.body;
376
+ if (tsNode.type) {
377
+ tsTypeNode = tsNode.type;
378
+ } else if (tsNode.body && ts4.isBlock(tsNode.body)) {
379
+ const returnStatement = tsNode.body.statements.find(ts4.isReturnStatement);
380
+ if (returnStatement == null ? void 0 : returnStatement.expression) {
381
+ tsTypeNode = returnStatement.expression;
382
+ }
383
+ } else {
384
+ tsTypeNode = tsNode.body;
385
+ }
378
386
  } else if (ts4.isCallSignatureDeclaration(tsNode) || ts4.isMethodSignature(tsNode)) {
379
387
  tsTypeNode = tsNode.type;
380
388
  } else if (ts4.isPropertySignature(tsNode)) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "eslint-plugin-rxjs-x",
3
3
  "type": "commonjs",
4
- "version": "0.7.1",
5
- "packageManager": "yarn@4.7.0+sha512.5a0afa1d4c1d844b3447ee3319633797bcd6385d9a44be07993ae52ff4facabccafb4af5dcd1c2f9a94ac113e5e9ff56f6130431905884414229e284e37bb7c9",
4
+ "version": "0.7.2",
5
+ "packageManager": "yarn@4.9.1+sha512.f95ce356460e05be48d66401c1ae64ef84d163dd689964962c6888a9810865e39097a5e9de748876c2e0bf89b232d583c33982773e9903ae7a76257270986538",
6
6
  "description": "ESLint v9+ plugin for RxJS",
7
7
  "author": "Jason Weinzierl <weinzierljason@gmail.com>",
8
8
  "license": "MIT",
@@ -39,8 +39,7 @@
39
39
  "module": "./dist/index.mjs",
40
40
  "types": "./dist/index.d.ts",
41
41
  "files": [
42
- "dist",
43
- "docs"
42
+ "dist"
44
43
  ],
45
44
  "scripts": {
46
45
  "build": "tsup",
@@ -73,28 +72,28 @@
73
72
  }
74
73
  },
75
74
  "devDependencies": {
76
- "@eslint/js": "^9.22.0",
75
+ "@eslint/js": "^9.24.0",
77
76
  "@stylistic/eslint-plugin": "^4.2.0",
78
77
  "@types/common-tags": "^1.8.4",
79
78
  "@types/node": "~18.18.0",
80
- "@typescript-eslint/rule-tester": "^8.26.1",
79
+ "@typescript-eslint/rule-tester": "^8.30.1",
81
80
  "@typescript/vfs": "^1.6.1",
82
- "@vitest/coverage-v8": "^3.0.8",
83
- "@vitest/eslint-plugin": "^1.1.37",
81
+ "@vitest/coverage-v8": "^3.1.1",
82
+ "@vitest/eslint-plugin": "^1.1.42",
84
83
  "bumpp": "^10.1.0",
85
- "eslint": "^9.22.0",
84
+ "eslint": "^9.24.0",
86
85
  "eslint-config-flat-gitignore": "^2.1.0",
87
- "eslint-doc-generator": "^2.1.1",
88
- "eslint-import-resolver-typescript": "^3.8.5",
86
+ "eslint-doc-generator": "^2.1.2",
87
+ "eslint-import-resolver-typescript": "^4.3.2",
89
88
  "eslint-plugin-eslint-plugin": "^6.4.0",
90
- "eslint-plugin-import-x": "^4.6.1",
91
- "eslint-plugin-n": "^17.16.2",
89
+ "eslint-plugin-import-x": "^4.10.5",
90
+ "eslint-plugin-n": "^17.17.0",
92
91
  "markdownlint-cli2": "^0.17.2",
93
92
  "rxjs": "^7.8.2",
94
93
  "tsup": "^8.4.0",
95
- "typescript": "~5.7.3",
96
- "typescript-eslint": "^8.26.1",
97
- "vitest": "^3.0.8"
94
+ "typescript": "~5.8.3",
95
+ "typescript-eslint": "^8.30.1",
96
+ "vitest": "^3.1.1"
98
97
  },
99
98
  "engines": {
100
99
  "node": "^18.18.0 || ^20.9.0 || >= 21.1.0"
@@ -1,42 +0,0 @@
1
- # Disallow banned observable creators (`rxjs-x/ban-observables`)
2
-
3
- <!-- end auto-generated rule header -->
4
-
5
- It can sometimes be useful to ban specific `rxjs` imports.
6
- This rule can be configured to ban a list of specific `rxjs` imports developers want to avoid in their project.
7
-
8
- > [!TIP]
9
- > `ban-observables` only bans at the _import_ site. (In fact, it can ban anything imported from `rxjs`.)
10
- > See [`ban-operators`](./ban-operators.md) for banning operators at their _usage_.
11
-
12
- ## Options
13
-
14
- This rule accepts a single option which is an object the keys of which are the names of anything in `rxjs` and the values are either booleans or strings containing the explanation for the ban.
15
-
16
- The following configuration bans `partition` and `onErrorResumeNext`:
17
-
18
- ```json
19
- {
20
- "rxjs-x/ban-observables": [
21
- "error",
22
- {
23
- "partition": true,
24
- "of": false,
25
- "onErrorResumeNext": "What is this? Visual Basic?"
26
- }
27
- ]
28
- }
29
- ```
30
-
31
- ## When Not To Use It
32
-
33
- If you have no need to ban importing anything from `rxjs`, you don't need this rule.
34
-
35
- ## Related To
36
-
37
- - [`ban-operators`](./ban-operators.md)
38
-
39
- ## Resources
40
-
41
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/ban-observables.ts)
42
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/ban-observables.test.ts)
@@ -1,44 +0,0 @@
1
- # Disallow banned operators (`rxjs-x/ban-operators`)
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 can be configured so that developers can ban `rxjs` operators they want to avoid in their project.
8
-
9
- > [!NOTE]
10
- > Operators outside of a `pipe` or not directly exported by `rxjs` are ignored.
11
-
12
- ## Options
13
-
14
- This rule accepts a single option which is an object the keys of which are the names of operators and the values are either booleans or strings containing the explanation for the ban.
15
-
16
- The following configuration bans `partition` and `onErrorResumeNext`:
17
-
18
- ```json
19
- {
20
- "rxjs-x/ban-operators": [
21
- "error",
22
- {
23
- "partition": true,
24
- "map": false,
25
- "onErrorResumeNext": "What is this? Visual Basic?"
26
- }
27
- ]
28
- }
29
- ```
30
-
31
- ## When Not To Use It
32
-
33
- If you have no need to ban `rxjs` operators, 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
- ## Related To
38
-
39
- - [`ban-observables`](./ban-observables.md)
40
-
41
- ## Resources
42
-
43
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/ban-operators.ts)
44
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/ban-operators.test.ts)
@@ -1,91 +0,0 @@
1
- # Enforce Finnish notation (`rxjs-x/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 enforces the use of Finnish notation - i.e. the `$` suffix.
8
-
9
- ## Rule details
10
-
11
- Examples of **incorrect** code for this rule:
12
-
13
- ```ts
14
- const answers = of(42, 54);
15
- ```
16
-
17
- Examples of **correct** code for this rule:
18
-
19
- ```ts
20
- const answer$ = of(42, 54);
21
- ```
22
-
23
- ## Options
24
-
25
- <!-- begin auto-generated rule options list -->
26
-
27
- | Name | Description | Type |
28
- | :----------- | :------------------------------------------------------------------- | :------ |
29
- | `functions` | Require for functions. | Boolean |
30
- | `methods` | Require for methods. | Boolean |
31
- | `names` | Enforce for specific names. Keys are a RegExp, values are a boolean. | Object |
32
- | `parameters` | Require for parameters. | Boolean |
33
- | `properties` | Require for properties. | Boolean |
34
- | `strict` | Disallow Finnish notation for non-Observables. | Boolean |
35
- | `types` | Enforce for specific types. Keys are a RegExp, values are a boolean. | Object |
36
- | `variables` | Require for variables. | Boolean |
37
-
38
- <!-- end auto-generated rule options list -->
39
-
40
- This rule accepts a single option which is an object with properties that determine whether Finnish notation is enforced for `functions`, `methods`, `parameters`, `properties` and `variables`. It also contains:
41
-
42
- - `names` and `types` properties that determine whether or not Finnish notation is to be enforced for specific names or types.
43
- - a `strict` property that, if `true`, allows the `$` suffix to be used _only_ with identifiers that have an `Observable` type.
44
-
45
- The default (Angular-friendly) configuration looks like this:
46
-
47
- ```json
48
- {
49
- "rxjs-x/finnish": [
50
- "error",
51
- {
52
- "functions": true,
53
- "methods": true,
54
- "names": {
55
- "^(canActivate|canActivateChild|canDeactivate|canLoad|intercept|resolve|validate)$": false
56
- },
57
- "parameters": true,
58
- "properties": true,
59
- "strict": false,
60
- "types": {
61
- "^EventEmitter$": false
62
- },
63
- "variables": true
64
- }
65
- ]
66
- }
67
- ```
68
-
69
- The properties in the options object are themselves optional; they do not all have to be specified.
70
-
71
- ## When Not To Use It
72
-
73
- If you don't use Finnish notation in your project or don't care about enforcing Finnish notation in your project, you don't need this rule.
74
- However, keep in mind that inconsistent style can harm readability in a project;
75
- consider using [`no-finnish`](./no-finnish.md) to ban Finnish notation if you don't use it in your project.
76
-
77
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
78
-
79
- ## Further reading
80
-
81
- - [Observables and Finnish Notation](https://medium.com/@benlesh/observables-and-finnish-notation-df8356ed1c9b)
82
-
83
- ## Related To
84
-
85
- - [`no-finnish`](./no-finnish.md)
86
- - [`suffix-subjects`](./suffix-subjects.md)
87
-
88
- ## Resources
89
-
90
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/finnish.ts)
91
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/finnish.test.ts)
@@ -1,20 +0,0 @@
1
- # Require the use of `just` instead of `of` (`rxjs-x/just`)
2
-
3
- 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
4
-
5
- <!-- end auto-generated rule header -->
6
-
7
- This rule enforces the use of `just` instead of `of`. Some other languages with Rx implementations use the former and this rule is for developers who have that preference.
8
-
9
- ## When Not To Use It
10
-
11
- If you prefer `of` in your project, you will want to avoid this rule.
12
-
13
- ## Further reading
14
-
15
- - [Rename `of` to `just`](https://github.com/ReactiveX/rxjs/issues/3747)
16
-
17
- ## Resources
18
-
19
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/just.ts)
20
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/just.test.ts)
@@ -1,11 +0,0 @@
1
- # Require the use of the RxJS Tools Babel macro (`rxjs-x/macro`)
2
-
3
- ❌ This rule is deprecated.
4
-
5
- 🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
6
-
7
- <!-- end auto-generated rule header -->
8
-
9
- This rule ensures that modules that import `rxjs` also import the Babel macro for [RxJS Tools](https://rxjs.tools).
10
-
11
- This rule is deprecated because [`babel-plugin-rxjs-tools`](https://www.npmjs.com/package/babel-plugin-rxjs-tools) is unmaintained.
@@ -1,54 +0,0 @@
1
- # Disallow passing `async` functions to `subscribe` (`rxjs-x/no-async-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 async functions are passed to `subscribe`.
10
- Developers are encouraged to avoid race conditions
11
- by instead using RxJS operators which can handle both Promises and Observables
12
- (e.g. `concatMap`, `switchMap`, `mergeMap`, `exhaustMap`).
13
-
14
- ## Rule details
15
-
16
- Examples of **incorrect** code for this rule:
17
-
18
- ```ts
19
- import { of } from "rxjs";
20
-
21
- of(42).subscribe(async value => {
22
- const data1 = await fetch(`https://api.some.com/things/${value}`);
23
- const data2 = await fetch(`https://api.some.com/things/${data1.id}`);
24
- console.log(data2);
25
- });
26
- ```
27
-
28
- Examples of **correct** code for this rule:
29
-
30
- ```ts
31
- import { of } from "rxjs";
32
-
33
- of(42).pipe(
34
- switchMap(value => fetch(`http://api.some.com/things/${value}`)),
35
- switchMap(data1 => fetch(`http://api.some.com/things/${data1.id}`)),
36
- ).subscribe(data2 => console.log(data2));
37
- ```
38
-
39
- ## When Not To Use It
40
-
41
- If you don't care about avoiding `.subscribe(async...`, then you will not need this rule.
42
- However, keep in mind that features of observables like cancellation or retrying will not work, and race conditions may occur.
43
-
44
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
45
-
46
- ## Further reading
47
-
48
- - [Why does this rule exist?](https://stackoverflow.com/q/71559135)
49
- - [Higher-order Observables](https://rxjs.dev/guide/higher-order-observables)
50
-
51
- ## Resources
52
-
53
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-async-subscribe.ts)
54
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-async-subscribe.test.ts)
@@ -1,13 +0,0 @@
1
- # Disallow the `rxjs-compat` package (`rxjs-x/no-compat`)
2
-
3
- ❌ This rule is deprecated.
4
-
5
- <!-- end auto-generated rule header -->
6
-
7
- This rule prevents importing from locations that depend upon the `rxjs-compat` package.
8
-
9
- This rule is deprecated because RxJS v7+ no longer includes `rxjs-compat`.
10
-
11
- ## Further reading
12
-
13
- - [Backwards compatibility](https://github.com/ReactiveX/rxjs/blob/a6590e971969c736a15b77154dabbc22275aa0d5/docs_app/content/guide/v6/migration.md#backwards-compatibility)
@@ -1,33 +0,0 @@
1
- # Disallow operators that return connectable observables (`rxjs-x/no-connectable`)
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 operators that return connectable observables.
8
-
9
- > [!NOTE]
10
- > All operators banned by this rule are also deprecated by RxJS,
11
- > so this rule may be removed in a future major version.
12
-
13
- ## Rule details
14
-
15
- Examples of **incorrect** code for this rule:
16
-
17
- ```ts
18
- import { of, publish } from "rxjs";
19
-
20
- const result = of(42).pipe(publish());
21
- ```
22
-
23
- ## When Not To Use It
24
-
25
- If you use operators that return connectable observables in your project, you may not need this rule.
26
- Or you may rely on RxJS's deprecation of those operators and don't need to double-flag the operators as banned.
27
-
28
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
29
-
30
- ## Resources
31
-
32
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-connectable.ts)
33
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-connectable.test.ts)
@@ -1,43 +0,0 @@
1
- # Disallow the static `Observable.create` function (`rxjs-x/no-create`)
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 prevents the use of the static `create` function in `Observable`. Developers should use `new` and the constructor instead.
10
-
11
- ## Rule details
12
-
13
- Examples of **incorrect** code for this rule:
14
-
15
- ```ts
16
- const answers = Observable.create(subscriber => {
17
- subscriber.next(42);
18
- subscriber.next(54);
19
- subscriber.complete();
20
- });
21
- ```
22
-
23
- Examples of **correct** code for this rule:
24
-
25
- ```ts
26
- const answers = new Observable<number>(subscriber => {
27
- subscriber.next(42);
28
- subscriber.next(54);
29
- subscriber.complete();
30
- });
31
- ```
32
-
33
- ## When Not To Use It
34
-
35
- If you rely on RxJS's deprecation of `Observable.create` and don't need to double-flag usage,
36
- then you don't need 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-create.ts)
43
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-create.test.ts)
@@ -1,88 +0,0 @@
1
- # Disallow cyclic actions in effects and epics (`rxjs-x/no-cyclic-action`)
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 for effects and epics that emit actions that would pass their `ofType` filter. Such actions are cyclic and, upon emission, immediately re-trigger the effect or epic.
8
-
9
- ## Rule details
10
-
11
- Examples of **incorrect** code for this rule:
12
-
13
- ```ts
14
- actions.pipe(
15
- ofType("SOMETHING"),
16
- map(() => ({ type: "SOMETHING" }))
17
- );
18
- ```
19
-
20
- Examples of **correct** code for this rule:
21
-
22
- ```ts
23
- actions.pipe(
24
- ofType("SOMETHING"),
25
- map(() => ({ type: "SOMETHING_ELSE" }))
26
- );
27
- ```
28
-
29
- This rule can be used with effects _and epics_, so it makes **no attempt** to discern whether or not dispatching is disabled for an NgRx effect. That is, code like this will effect (🙈) a failure:
30
-
31
- ```ts
32
- someEffect = createEffect(() =>
33
- this.actions$.pipe(
34
- ofType("SOMETHING"),
35
- tap(() => console.log("do something")),
36
- ),
37
- { dispatch: false }
38
- );
39
- ```
40
-
41
- Instead, you can use the the RxJS [`ignoreElements`](https://rxjs.dev/api/operators/ignoreElements) operator:
42
-
43
- ```ts
44
- someEffect = createEffect(() =>
45
- this.actions$.pipe(
46
- ofType("SOMETHING"),
47
- tap(() => console.log("do something")),
48
- ignoreElements()
49
- )
50
- );
51
- ```
52
-
53
- Or you can use an ESLint [inline comment](https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments) to disable the rule for a specific effect.
54
-
55
- ## Options
56
-
57
- <!-- begin auto-generated rule options list -->
58
-
59
- | Name | Description | Type | Default |
60
- | :----------- | :------------------------------------------------------------ | :----- | :----------------------- |
61
- | `observable` | A RegExp that matches an effect or epic's actions observable. | String | `[Aa]ction(s\|s\$\|\$)$` |
62
-
63
- <!-- end auto-generated rule options list -->
64
-
65
- 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.
66
-
67
- ```json
68
- {
69
- "rxjs-x/no-cyclic-action": [
70
- "error",
71
- { "observable": "[Aa]ction(s|s\\$|\\$)$" }
72
- ]
73
- }
74
- ```
75
-
76
- ## When Not To Use It
77
-
78
- If you don't use a library with effects and epics (e.g. NgRx or redux-observable),
79
- then you don't need this rule.
80
- Alternatively, if you use NgRx's own [`avoid-cyclic-effects`](https://ngrx.io/guide/eslint-plugin/rules/avoid-cyclic-effects) rule,
81
- then you don't need this rule.
82
-
83
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
84
-
85
- ## Resources
86
-
87
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-cyclic-action.ts)
88
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-cyclic-action.test.ts)
@@ -1,32 +0,0 @@
1
- # Disallow unnecessary explicit generic type arguments (`rxjs-x/no-explicit-generics`)
2
-
3
- <!-- end auto-generated rule header -->
4
-
5
- This rule prevents the use of explicit type arguments when the type arguments can be inferred.
6
-
7
- ## Rule details
8
-
9
- Examples of **incorrect** code for this rule:
10
-
11
- ```ts
12
- import { BehaviorSubject } from "rxjs";
13
- const subject = new BehaviorSubject<number>(42);
14
- ```
15
-
16
- Examples of **correct** code for this rule:
17
-
18
- ```ts
19
- import { BehaviorSubject } from "rxjs";
20
- const subject = new BehaviorSubject(42);
21
- ```
22
-
23
- ## When Not To Use It
24
-
25
- This rule has known problems in the latest release:
26
-
27
- - ([#77](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/issues/77)) Type unions cause false positives e.g. `new BehaviorSubject<number | null>(null)` will be incorrectly caught by this rule.
28
-
29
- ## Resources
30
-
31
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-explicit-generics.ts)
32
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-explicit-generics.test.ts)
@@ -1,68 +0,0 @@
1
- # Disallow public and protected subjects (`rxjs-x/no-exposed-subjects`)
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 exposed (i.e. non-private) subjects. Developers should instead expose observables via the subjects' `asObservable` method.
10
-
11
- ## Rule details
12
-
13
- Examples of **incorrect** code for this rule:
14
-
15
- ```ts
16
- import { Subject } from "rxjs";
17
- class Answers {
18
- public answers: Subject<number>;
19
- }
20
- ```
21
-
22
- Examples of **correct** code for this rule:
23
-
24
- ```ts
25
- import { Subject } from "rxjs";
26
-
27
- class Answers {
28
- private answersSubject$ = new Subject<string>();
29
- public answers$ = this.answersSubject$.asObservable();
30
-
31
- public nextAnswer(a: string) {
32
- this.answersSubject$.next(a);
33
- }
34
- }
35
- ```
36
-
37
- ## Options
38
-
39
- <!-- begin auto-generated rule options list -->
40
-
41
- | Name | Description | Type | Default |
42
- | :--------------- | :------------------------ | :------ | :------ |
43
- | `allowProtected` | Allow protected subjects. | Boolean | `false` |
44
-
45
- <!-- end auto-generated rule options list -->
46
-
47
- This rule accepts a single option which is an object with an `allowProtected` property that determines whether or not protected subjects are allowed. By default, they are not.
48
-
49
- ```json
50
- {
51
- "rxjs-x/no-exposed-subjects": [
52
- "error",
53
- { "allowProtected": true }
54
- ]
55
- }
56
- ```
57
-
58
- ## When Not To Use It
59
-
60
- If you don't care about encapsulating subjects in your project, then you don't need this rule.
61
- However, be aware that anyone can call `next()` or `complete()` on the exposed subject, which may cause bugs or less readable code.
62
-
63
- Type checked lint rules are more powerful than traditional lint rules, but also require configuring type checked linting.
64
-
65
- ## Resources
66
-
67
- - [Rule source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/src/rules/no-exposed-subjects.ts)
68
- - [Test source](https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x/blob/main/tests/rules/no-exposed-subjects.test.ts)