eslint-plugin-rxjs-x 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ The package includes the following rules.
|
|
|
70
70
|
| [ban-operators](docs/rules/ban-operators.md) | Disallow banned operators. | | | | | |
|
|
71
71
|
| [finnish](docs/rules/finnish.md) | Enforce Finnish notation. | | | | 💭 | |
|
|
72
72
|
| [just](docs/rules/just.md) | Require the use of `just` instead of `of`. | | 🔧 | | | |
|
|
73
|
-
| [macro](docs/rules/macro.md) | Require the use of the RxJS Tools Babel macro. | | 🔧 | | |
|
|
73
|
+
| [macro](docs/rules/macro.md) | Require the use of the RxJS Tools Babel macro. | | 🔧 | | | ❌ |
|
|
74
74
|
| [no-async-subscribe](docs/rules/no-async-subscribe.md) | Disallow passing `async` functions to `subscribe`. | ✅ | | | 💭 | |
|
|
75
75
|
| [no-compat](docs/rules/no-compat.md) | Disallow the `rxjs-compat` package. | | | | | |
|
|
76
76
|
| [no-connectable](docs/rules/no-connectable.md) | Disallow operators that return connectable observables. | | | | 💭 | |
|
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.2.
|
|
3
|
+
var version = "0.2.4";
|
|
4
4
|
|
|
5
5
|
// src/configs/recommended.ts
|
|
6
6
|
var createRecommendedConfig = (plugin2) => ({
|
|
@@ -723,6 +723,7 @@ var justRule = ruleCreator({
|
|
|
723
723
|
var macroRule = ruleCreator({
|
|
724
724
|
defaultOptions: [],
|
|
725
725
|
meta: {
|
|
726
|
+
deprecated: true,
|
|
726
727
|
docs: {
|
|
727
728
|
description: "Require the use of the RxJS Tools Babel macro."
|
|
728
729
|
},
|
|
@@ -1412,6 +1413,7 @@ var noIgnoredObservableRule = ruleCreator({
|
|
|
1412
1413
|
});
|
|
1413
1414
|
|
|
1414
1415
|
// src/rules/no-ignored-replay-buffer.ts
|
|
1416
|
+
|
|
1415
1417
|
var noIgnoredReplayBufferRule = ruleCreator({
|
|
1416
1418
|
defaultOptions: [],
|
|
1417
1419
|
meta: {
|
|
@@ -1427,6 +1429,14 @@ var noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1427
1429
|
},
|
|
1428
1430
|
name: "no-ignored-replay-buffer",
|
|
1429
1431
|
create: (context) => {
|
|
1432
|
+
function checkShareReplayConfig(node, shareReplayConfigArg) {
|
|
1433
|
+
if (!shareReplayConfigArg.properties.some((p) => p.type === _utils.AST_NODE_TYPES.Property && p.key.type === _utils.AST_NODE_TYPES.Identifier && p.key.name === "bufferSize")) {
|
|
1434
|
+
context.report({
|
|
1435
|
+
messageId: "forbidden",
|
|
1436
|
+
node
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1430
1440
|
function checkNode(node, { arguments: args }) {
|
|
1431
1441
|
if (!args || args.length === 0) {
|
|
1432
1442
|
context.report({
|
|
@@ -1434,6 +1444,12 @@ var noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1434
1444
|
node
|
|
1435
1445
|
});
|
|
1436
1446
|
}
|
|
1447
|
+
if (node.name === "shareReplay" && (args == null ? void 0 : args.length) === 1) {
|
|
1448
|
+
const arg = args[0];
|
|
1449
|
+
if (arg.type === _utils.AST_NODE_TYPES.ObjectExpression) {
|
|
1450
|
+
checkShareReplayConfig(node, arg);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1437
1453
|
}
|
|
1438
1454
|
return {
|
|
1439
1455
|
"NewExpression > Identifier[name='ReplaySubject']": (node) => {
|
|
@@ -1448,6 +1464,11 @@ var noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1448
1464
|
"CallExpression > Identifier[name=/^(publishReplay|shareReplay)$/]": (node) => {
|
|
1449
1465
|
const callExpression = node.parent;
|
|
1450
1466
|
checkNode(node, callExpression);
|
|
1467
|
+
},
|
|
1468
|
+
"CallExpression > MemberExpression > Identifier[name=/^(publishReplay|shareReplay)$/]": (node) => {
|
|
1469
|
+
const memberExpression = node.parent;
|
|
1470
|
+
const callExpression = memberExpression.parent;
|
|
1471
|
+
checkNode(node, callExpression);
|
|
1451
1472
|
}
|
|
1452
1473
|
};
|
|
1453
1474
|
}
|
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.2.
|
|
3
|
+
var version = "0.2.4";
|
|
4
4
|
|
|
5
5
|
// src/configs/recommended.ts
|
|
6
6
|
var createRecommendedConfig = (plugin2) => ({
|
|
@@ -723,6 +723,7 @@ var justRule = ruleCreator({
|
|
|
723
723
|
var macroRule = ruleCreator({
|
|
724
724
|
defaultOptions: [],
|
|
725
725
|
meta: {
|
|
726
|
+
deprecated: true,
|
|
726
727
|
docs: {
|
|
727
728
|
description: "Require the use of the RxJS Tools Babel macro."
|
|
728
729
|
},
|
|
@@ -1412,6 +1413,7 @@ var noIgnoredObservableRule = ruleCreator({
|
|
|
1412
1413
|
});
|
|
1413
1414
|
|
|
1414
1415
|
// src/rules/no-ignored-replay-buffer.ts
|
|
1416
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES6 } from "@typescript-eslint/utils";
|
|
1415
1417
|
var noIgnoredReplayBufferRule = ruleCreator({
|
|
1416
1418
|
defaultOptions: [],
|
|
1417
1419
|
meta: {
|
|
@@ -1427,6 +1429,14 @@ var noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1427
1429
|
},
|
|
1428
1430
|
name: "no-ignored-replay-buffer",
|
|
1429
1431
|
create: (context) => {
|
|
1432
|
+
function checkShareReplayConfig(node, shareReplayConfigArg) {
|
|
1433
|
+
if (!shareReplayConfigArg.properties.some((p) => p.type === AST_NODE_TYPES6.Property && p.key.type === AST_NODE_TYPES6.Identifier && p.key.name === "bufferSize")) {
|
|
1434
|
+
context.report({
|
|
1435
|
+
messageId: "forbidden",
|
|
1436
|
+
node
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1430
1440
|
function checkNode(node, { arguments: args }) {
|
|
1431
1441
|
if (!args || args.length === 0) {
|
|
1432
1442
|
context.report({
|
|
@@ -1434,6 +1444,12 @@ var noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1434
1444
|
node
|
|
1435
1445
|
});
|
|
1436
1446
|
}
|
|
1447
|
+
if (node.name === "shareReplay" && (args == null ? void 0 : args.length) === 1) {
|
|
1448
|
+
const arg = args[0];
|
|
1449
|
+
if (arg.type === AST_NODE_TYPES6.ObjectExpression) {
|
|
1450
|
+
checkShareReplayConfig(node, arg);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1437
1453
|
}
|
|
1438
1454
|
return {
|
|
1439
1455
|
"NewExpression > Identifier[name='ReplaySubject']": (node) => {
|
|
@@ -1448,6 +1464,11 @@ var noIgnoredReplayBufferRule = ruleCreator({
|
|
|
1448
1464
|
"CallExpression > Identifier[name=/^(publishReplay|shareReplay)$/]": (node) => {
|
|
1449
1465
|
const callExpression = node.parent;
|
|
1450
1466
|
checkNode(node, callExpression);
|
|
1467
|
+
},
|
|
1468
|
+
"CallExpression > MemberExpression > Identifier[name=/^(publishReplay|shareReplay)$/]": (node) => {
|
|
1469
|
+
const memberExpression = node.parent;
|
|
1470
|
+
const callExpression = memberExpression.parent;
|
|
1471
|
+
checkNode(node, callExpression);
|
|
1451
1472
|
}
|
|
1452
1473
|
};
|
|
1453
1474
|
}
|
|
@@ -1575,7 +1596,7 @@ var noIgnoredTakewhileValueRule = ruleCreator({
|
|
|
1575
1596
|
|
|
1576
1597
|
// src/rules/no-implicit-any-catch.ts
|
|
1577
1598
|
import {
|
|
1578
|
-
AST_NODE_TYPES as
|
|
1599
|
+
AST_NODE_TYPES as AST_NODE_TYPES7
|
|
1579
1600
|
} from "@typescript-eslint/utils";
|
|
1580
1601
|
function isParenthesised(sourceCode, node) {
|
|
1581
1602
|
const before = sourceCode.getTokenBefore(node);
|
|
@@ -1631,7 +1652,7 @@ var noImplicitAnyCatchRule = ruleCreator({
|
|
|
1631
1652
|
const {
|
|
1632
1653
|
typeAnnotation: { type }
|
|
1633
1654
|
} = typeAnnotation;
|
|
1634
|
-
if (type ===
|
|
1655
|
+
if (type === AST_NODE_TYPES7.TSAnyKeyword) {
|
|
1635
1656
|
let fix2 = function(fixer) {
|
|
1636
1657
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1637
1658
|
};
|
|
@@ -1650,7 +1671,7 @@ var noImplicitAnyCatchRule = ruleCreator({
|
|
|
1650
1671
|
}
|
|
1651
1672
|
]
|
|
1652
1673
|
});
|
|
1653
|
-
} else if (type !==
|
|
1674
|
+
} else if (type !== AST_NODE_TYPES7.TSUnknownKeyword) {
|
|
1654
1675
|
let fix2 = function(fixer) {
|
|
1655
1676
|
return fixer.replaceText(typeAnnotation, ": unknown");
|
|
1656
1677
|
};
|
|
@@ -1945,7 +1966,7 @@ function isExpressionObserver(expressionStatement, couldBeType2) {
|
|
|
1945
1966
|
}
|
|
1946
1967
|
|
|
1947
1968
|
// src/rules/no-sharereplay.ts
|
|
1948
|
-
import { AST_NODE_TYPES as
|
|
1969
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES8 } from "@typescript-eslint/utils";
|
|
1949
1970
|
var defaultOptions7 = [];
|
|
1950
1971
|
var noSharereplayRule = ruleCreator({
|
|
1951
1972
|
defaultOptions: defaultOptions7,
|
|
@@ -1976,7 +1997,7 @@ var noSharereplayRule = ruleCreator({
|
|
|
1976
1997
|
"CallExpression[callee.name='shareReplay']": (node) => {
|
|
1977
1998
|
let report = true;
|
|
1978
1999
|
if (allowConfig) {
|
|
1979
|
-
report = node.arguments.length !== 1 || node.arguments[0].type !==
|
|
2000
|
+
report = node.arguments.length !== 1 || node.arguments[0].type !== AST_NODE_TYPES8.ObjectExpression;
|
|
1980
2001
|
}
|
|
1981
2002
|
if (report) {
|
|
1982
2003
|
context.report({
|
|
@@ -2780,7 +2801,7 @@ function isValidArgText(argText) {
|
|
|
2780
2801
|
}
|
|
2781
2802
|
|
|
2782
2803
|
// src/rules/suffix-subjects.ts
|
|
2783
|
-
import { AST_NODE_TYPES as
|
|
2804
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as ESLintUtils5 } from "@typescript-eslint/utils";
|
|
2784
2805
|
var defaultOptions13 = [];
|
|
2785
2806
|
var suffixSubjectsRule = ruleCreator({
|
|
2786
2807
|
defaultOptions: defaultOptions13,
|
|
@@ -2864,7 +2885,7 @@ var suffixSubjectsRule = ruleCreator({
|
|
|
2864
2885
|
if (!found) {
|
|
2865
2886
|
return;
|
|
2866
2887
|
}
|
|
2867
|
-
if (!validate.variables && found.type ===
|
|
2888
|
+
if (!validate.variables && found.type === AST_NODE_TYPES9.VariableDeclarator) {
|
|
2868
2889
|
return;
|
|
2869
2890
|
}
|
|
2870
2891
|
if (!validate.parameters) {
|
|
@@ -2931,7 +2952,7 @@ var suffixSubjectsRule = ruleCreator({
|
|
|
2931
2952
|
if (!found) {
|
|
2932
2953
|
return;
|
|
2933
2954
|
}
|
|
2934
|
-
if (!validate.variables && found.type ===
|
|
2955
|
+
if (!validate.variables && found.type === AST_NODE_TYPES9.VariableDeclarator) {
|
|
2935
2956
|
return;
|
|
2936
2957
|
}
|
|
2937
2958
|
if (!validate.parameters) {
|
package/docs/rules/macro.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# Require the use of the RxJS Tools Babel macro (`rxjs-x/macro`)
|
|
2
2
|
|
|
3
|
+
❌ This rule is deprecated.
|
|
4
|
+
|
|
3
5
|
🔧 This rule is automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/latest/user-guide/command-line-interface#--fix).
|
|
4
6
|
|
|
5
7
|
<!-- end auto-generated rule header -->
|
|
6
8
|
|
|
7
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.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<!-- end auto-generated rule header -->
|
|
6
6
|
|
|
7
|
-
This rule prevents exposed (i.e. non-private) subjects. Developers should instead expose observables via the subjects' `
|
|
7
|
+
This rule prevents exposed (i.e. non-private) subjects. Developers should instead expose observables via the subjects' `asObservable` method.
|
|
8
8
|
|
|
9
9
|
## Rule details
|
|
10
10
|
|
|
@@ -24,7 +24,7 @@ import { Subject } from "rxjs";
|
|
|
24
24
|
class Answers {
|
|
25
25
|
private _answers: Subject<string>;
|
|
26
26
|
get answers() {
|
|
27
|
-
return this._answers.
|
|
27
|
+
return this._answers.asObservable();
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
```
|
|
@@ -15,6 +15,11 @@ import { ReplaySubject } from "rxjs";
|
|
|
15
15
|
const subject = new ReplaySubject<number>();
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
```ts
|
|
19
|
+
import { of, shareReplay } from "rxjs";
|
|
20
|
+
of(42).pipe(shareReplay({ refCount: true }));
|
|
21
|
+
```
|
|
22
|
+
|
|
18
23
|
Examples of **correct** code for this rule:
|
|
19
24
|
|
|
20
25
|
```ts
|
|
@@ -26,3 +31,8 @@ const subject = new ReplaySubject<number>(1);
|
|
|
26
31
|
import { ReplaySubject } from "rxjs";
|
|
27
32
|
const subject = new ReplaySubject<number>(Infinity);
|
|
28
33
|
```
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { of, shareReplay } from "rxjs";
|
|
37
|
+
of(42).pipe(shareReplay({ refCount: true, bufferSize: 1 }));
|
|
38
|
+
```
|
|
@@ -24,9 +24,9 @@ Examples of **correct** code for this rule:
|
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
26
|
import { of, timer } from "rxjs";
|
|
27
|
-
import {
|
|
27
|
+
import { map, mergeMap } from "rxjs/operators";
|
|
28
28
|
|
|
29
29
|
of(42, 54).pipe(
|
|
30
|
-
mergeMap((value) => timer(1e3).pipe(
|
|
30
|
+
mergeMap((value) => timer(1e3).pipe(map(() => value)))
|
|
31
31
|
).subscribe((value) => console.log(value));
|
|
32
32
|
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-rxjs-x",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"packageManager": "yarn@4.5.1+sha512.341db9396b6e289fecc30cd7ab3af65060e05ebff4b3b47547b278b9e67b08f485ecd8c79006b405446262142c7a38154445ef7f17c1d5d1de7d90bf9ce7054d",
|
|
6
6
|
"description": "ESLint v9+ plugin for RxJS",
|
|
7
7
|
"author": "Jason Weinzierl <weinzierljason@gmail.com>",
|
|
@@ -65,11 +65,16 @@
|
|
|
65
65
|
"rxjs": ">=7.0.0",
|
|
66
66
|
"typescript": ">=4.7.4"
|
|
67
67
|
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"rxjs": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
68
73
|
"devDependencies": {
|
|
69
74
|
"@eslint/js": "^9.14.0",
|
|
70
75
|
"@stylistic/eslint-plugin": "^2.10.1",
|
|
71
76
|
"@types/common-tags": "^1.8.4",
|
|
72
|
-
"@types/node": "
|
|
77
|
+
"@types/node": "~18.18.0",
|
|
73
78
|
"@typescript-eslint/rule-tester": "^8.13.0",
|
|
74
79
|
"@typescript/vfs": "^1.6.0",
|
|
75
80
|
"@vitest/coverage-v8": "^2.1.4",
|
|
@@ -83,7 +88,7 @@
|
|
|
83
88
|
"eslint-plugin-import-x": "^4.4.0",
|
|
84
89
|
"eslint-plugin-n": "^17.13.1",
|
|
85
90
|
"markdownlint-cli2": "^0.14.0",
|
|
86
|
-
"rxjs": "^7.
|
|
91
|
+
"rxjs": "^7.8.1",
|
|
87
92
|
"tsup": "^8.3.5",
|
|
88
93
|
"tsx": "^4.19.2",
|
|
89
94
|
"typescript": "~5.6.3",
|