eslint-plugin-rxjs-x 0.8.4 → 0.8.5
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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +35 -20
- package/dist/index.mjs +53 -38
- package/package.json +8 -8
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
3
|
Copyright (c) 2019 Nicholas Jamieson and contributors
|
|
4
|
-
Copyright (c) 2024-
|
|
4
|
+
Copyright (c) 2024-2026 Jason Weinzierl and contributors
|
|
5
5
|
|
|
6
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
7
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -120,7 +120,7 @@ The package includes the following rules.
|
|
|
120
120
|
| [no-connectable](docs/rules/no-connectable.md) | Disallow operators that return connectable observables. | | | | 💭 | |
|
|
121
121
|
| [no-create](docs/rules/no-create.md) | Disallow the static `Observable.create` function. | ✅ 🔒 | | | 💭 | |
|
|
122
122
|
| [no-cyclic-action](docs/rules/no-cyclic-action.md) | Disallow cyclic actions in effects and epics. | | | | 💭 | |
|
|
123
|
-
| [no-explicit-generics](docs/rules/no-explicit-generics.md) | Disallow unnecessary explicit generic type arguments. | | | |
|
|
123
|
+
| [no-explicit-generics](docs/rules/no-explicit-generics.md) | Disallow unnecessary explicit generic type arguments. | | | | 💭 | |
|
|
124
124
|
| [no-exposed-subjects](docs/rules/no-exposed-subjects.md) | Disallow public and protected subjects. | 🔒 | | | 💭 | |
|
|
125
125
|
| [no-finnish](docs/rules/no-finnish.md) | Disallow Finnish notation. | | | | 💭 | |
|
|
126
126
|
| [no-floating-observables](docs/rules/no-floating-observables.md) | Require Observables to be handled appropriately. | 🔒 | | | 💭 | |
|
package/dist/index.d.mts
CHANGED
|
@@ -62,6 +62,7 @@ declare const allRules: {
|
|
|
62
62
|
}, TSESLint.RuleListener>;
|
|
63
63
|
'no-explicit-generics': TSESLint.RuleModule<"forbidden", [], {
|
|
64
64
|
description: "Disallow unnecessary explicit generic type arguments.";
|
|
65
|
+
requiresTypeChecking: true;
|
|
65
66
|
}, TSESLint.RuleListener>;
|
|
66
67
|
'no-exposed-subjects': TSESLint.RuleModule<"forbidden" | "forbiddenAllowProtected", readonly {
|
|
67
68
|
allowProtected?: boolean;
|
|
@@ -241,7 +242,7 @@ declare const allRules: {
|
|
|
241
242
|
recommended: "recommended";
|
|
242
243
|
requiresTypeChecking: true;
|
|
243
244
|
}, TSESLint.RuleListener>;
|
|
244
|
-
'prefer-observer': TSESLint.RuleModule<"forbidden", readonly {
|
|
245
|
+
'prefer-observer': TSESLint.RuleModule<"forbidden" | "suggest", readonly {
|
|
245
246
|
allowNext?: boolean;
|
|
246
247
|
}[], {
|
|
247
248
|
description: "Disallow passing separate handlers to `subscribe` and `tap`.";
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ declare const allRules: {
|
|
|
62
62
|
}, TSESLint.RuleListener>;
|
|
63
63
|
'no-explicit-generics': TSESLint.RuleModule<"forbidden", [], {
|
|
64
64
|
description: "Disallow unnecessary explicit generic type arguments.";
|
|
65
|
+
requiresTypeChecking: true;
|
|
65
66
|
}, TSESLint.RuleListener>;
|
|
66
67
|
'no-exposed-subjects': TSESLint.RuleModule<"forbidden" | "forbiddenAllowProtected", readonly {
|
|
67
68
|
allowProtected?: boolean;
|
|
@@ -241,7 +242,7 @@ declare const allRules: {
|
|
|
241
242
|
recommended: "recommended";
|
|
242
243
|
requiresTypeChecking: true;
|
|
243
244
|
}, TSESLint.RuleListener>;
|
|
244
|
-
'prefer-observer': TSESLint.RuleModule<"forbidden", readonly {
|
|
245
|
+
'prefer-observer': TSESLint.RuleModule<"forbidden" | "suggest", readonly {
|
|
245
246
|
allowNext?: boolean;
|
|
246
247
|
}[], {
|
|
247
248
|
description: "Disallow passing separate handlers to `subscribe` and `tap`.";
|
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.8.
|
|
3
|
+
var version = "0.8.5";
|
|
4
4
|
|
|
5
5
|
// src/configs/recommended.ts
|
|
6
6
|
var createRecommendedConfig = (plugin2) => ({
|
|
@@ -104,7 +104,7 @@ function escapeRegExp(text) {
|
|
|
104
104
|
var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);
|
|
105
105
|
|
|
106
106
|
// src/etc/could-be-type.ts
|
|
107
|
-
var _tsapiutils = require('ts-api-utils'); var tsutils = _interopRequireWildcard(_tsapiutils); var tsutils2 = _interopRequireWildcard(_tsapiutils); var tsutils3 = _interopRequireWildcard(_tsapiutils); var tsutils4 = _interopRequireWildcard(_tsapiutils);
|
|
107
|
+
var _tsapiutils = require('ts-api-utils'); var tsutils = _interopRequireWildcard(_tsapiutils); var tsutils2 = _interopRequireWildcard(_tsapiutils); var tsutils3 = _interopRequireWildcard(_tsapiutils); var tsutils4 = _interopRequireWildcard(_tsapiutils); var tsutils5 = _interopRequireWildcard(_tsapiutils);
|
|
108
108
|
|
|
109
109
|
function couldBeType(type, name2, qualified) {
|
|
110
110
|
if (tsutils.isTypeReference(type)) {
|
|
@@ -1203,11 +1203,14 @@ var noCyclicActionRule = ruleCreator({
|
|
|
1203
1203
|
});
|
|
1204
1204
|
|
|
1205
1205
|
// src/rules/no-explicit-generics.ts
|
|
1206
|
+
|
|
1207
|
+
|
|
1206
1208
|
var noExplicitGenericsRule = ruleCreator({
|
|
1207
1209
|
defaultOptions: [],
|
|
1208
1210
|
meta: {
|
|
1209
1211
|
docs: {
|
|
1210
|
-
description: "Disallow unnecessary explicit generic type arguments."
|
|
1212
|
+
description: "Disallow unnecessary explicit generic type arguments.",
|
|
1213
|
+
requiresTypeChecking: true
|
|
1211
1214
|
},
|
|
1212
1215
|
messages: {
|
|
1213
1216
|
forbidden: "Explicit generic type arguments are forbidden."
|
|
@@ -1223,6 +1226,17 @@ var noExplicitGenericsRule = ruleCreator({
|
|
|
1223
1226
|
node
|
|
1224
1227
|
});
|
|
1225
1228
|
}
|
|
1229
|
+
function isUnion(node) {
|
|
1230
|
+
if (!node) {
|
|
1231
|
+
return false;
|
|
1232
|
+
}
|
|
1233
|
+
if (isUnionType(node)) {
|
|
1234
|
+
return true;
|
|
1235
|
+
}
|
|
1236
|
+
const { getTypeAtLocation } = _utils.ESLintUtils.getParserServices(context);
|
|
1237
|
+
const type = getTypeAtLocation(node);
|
|
1238
|
+
return tsutils2.isUnionOrIntersectionType(type);
|
|
1239
|
+
}
|
|
1226
1240
|
function checkBehaviorSubjects(node) {
|
|
1227
1241
|
var _a;
|
|
1228
1242
|
const parent = node.parent;
|
|
@@ -1230,7 +1244,7 @@ var noExplicitGenericsRule = ruleCreator({
|
|
|
1230
1244
|
arguments: [value]
|
|
1231
1245
|
} = parent;
|
|
1232
1246
|
const typeArgs = (_a = parent.typeArguments) == null ? void 0 : _a.params[0];
|
|
1233
|
-
if (isArrayExpression(value) || isObjectExpression(value) ||
|
|
1247
|
+
if (isArrayExpression(value) || isObjectExpression(value) || isUnion(typeArgs)) {
|
|
1234
1248
|
return;
|
|
1235
1249
|
}
|
|
1236
1250
|
report(node);
|
|
@@ -1242,7 +1256,7 @@ var noExplicitGenericsRule = ruleCreator({
|
|
|
1242
1256
|
arguments: [, value]
|
|
1243
1257
|
} = parent;
|
|
1244
1258
|
const typeArgs = (_a = parent.typeArguments) == null ? void 0 : _a.params[0];
|
|
1245
|
-
if (isArrayExpression(value) || isObjectExpression(value) ||
|
|
1259
|
+
if (isArrayExpression(value) || isObjectExpression(value) || isUnion(typeArgs)) {
|
|
1246
1260
|
return;
|
|
1247
1261
|
}
|
|
1248
1262
|
report(node);
|
|
@@ -2552,7 +2566,7 @@ function voidFunctionArguments(checker, tsNode) {
|
|
|
2552
2566
|
}
|
|
2553
2567
|
const voidReturnIndices = /* @__PURE__ */ new Set();
|
|
2554
2568
|
const type = checker.getTypeAtLocation(tsNode.expression);
|
|
2555
|
-
for (const subType of
|
|
2569
|
+
for (const subType of tsutils3.unionTypeParts(type)) {
|
|
2556
2570
|
const signatures = _typescript2.default.isCallExpression(tsNode) ? subType.getCallSignatures() : subType.getConstructSignatures();
|
|
2557
2571
|
for (const signature of signatures) {
|
|
2558
2572
|
for (const [index, parameter] of signature.parameters.entries()) {
|
|
@@ -2567,13 +2581,13 @@ function voidFunctionArguments(checker, tsNode) {
|
|
|
2567
2581
|
}
|
|
2568
2582
|
function isVoidReturningFunctionType(type) {
|
|
2569
2583
|
let hasVoidReturn = false;
|
|
2570
|
-
for (const subType of
|
|
2584
|
+
for (const subType of tsutils3.unionTypeParts(type)) {
|
|
2571
2585
|
for (const signature of subType.getCallSignatures()) {
|
|
2572
2586
|
const returnType = signature.getReturnType();
|
|
2573
2587
|
if (couldBeType(returnType, "Observable")) {
|
|
2574
2588
|
return false;
|
|
2575
2589
|
}
|
|
2576
|
-
hasVoidReturn || (hasVoidReturn =
|
|
2590
|
+
hasVoidReturn || (hasVoidReturn = tsutils3.isTypeFlagSet(returnType, _typescript2.default.TypeFlags.Void));
|
|
2577
2591
|
}
|
|
2578
2592
|
}
|
|
2579
2593
|
return hasVoidReturn;
|
|
@@ -2586,7 +2600,7 @@ function getMemberIfExists(type, memberName) {
|
|
|
2586
2600
|
var _a, _b;
|
|
2587
2601
|
const escapedMemberName = _typescript2.default.escapeLeadingUnderscores(memberName);
|
|
2588
2602
|
const symbolMemberMatch = (_b = (_a = type.getSymbol()) == null ? void 0 : _a.members) == null ? void 0 : _b.get(escapedMemberName);
|
|
2589
|
-
return symbolMemberMatch != null ? symbolMemberMatch :
|
|
2603
|
+
return symbolMemberMatch != null ? symbolMemberMatch : tsutils3.getPropertyOfType(type, escapedMemberName);
|
|
2590
2604
|
}
|
|
2591
2605
|
function isStaticMember(node) {
|
|
2592
2606
|
return (isMethodDefinition(node) || isPropertyDefinition(node) || isAccessorProperty(node)) && node.static;
|
|
@@ -3564,19 +3578,19 @@ var noUnsafeSubjectNext = ruleCreator({
|
|
|
3564
3578
|
[`CallExpression[callee.property.name='next']`]: (node) => {
|
|
3565
3579
|
if (node.arguments.length === 0 && isMemberExpression(node.callee)) {
|
|
3566
3580
|
const type = getTypeAtLocation(node.callee.object);
|
|
3567
|
-
if (
|
|
3581
|
+
if (tsutils4.isTypeReference(type) && couldBeType(type, "Subject")) {
|
|
3568
3582
|
const [typeArg] = typeChecker.getTypeArguments(type);
|
|
3569
|
-
if (
|
|
3583
|
+
if (tsutils4.isTypeFlagSet(typeArg, _typescript2.default.TypeFlags.Any)) {
|
|
3570
3584
|
return;
|
|
3571
3585
|
}
|
|
3572
|
-
if (
|
|
3586
|
+
if (tsutils4.isTypeFlagSet(typeArg, _typescript2.default.TypeFlags.Unknown)) {
|
|
3573
3587
|
return;
|
|
3574
3588
|
}
|
|
3575
|
-
if (
|
|
3589
|
+
if (tsutils4.isTypeFlagSet(typeArg, _typescript2.default.TypeFlags.Void)) {
|
|
3576
3590
|
return;
|
|
3577
3591
|
}
|
|
3578
|
-
if (
|
|
3579
|
-
(t) =>
|
|
3592
|
+
if (tsutils4.isUnionType(typeArg) && typeArg.types.some(
|
|
3593
|
+
(t) => tsutils4.isTypeFlagSet(t, _typescript2.default.TypeFlags.Void)
|
|
3580
3594
|
)) {
|
|
3581
3595
|
return;
|
|
3582
3596
|
}
|
|
@@ -3794,7 +3808,8 @@ var preferObserverRule = ruleCreator({
|
|
|
3794
3808
|
fixable: "code",
|
|
3795
3809
|
hasSuggestions: true,
|
|
3796
3810
|
messages: {
|
|
3797
|
-
forbidden: "Passing separate handlers is forbidden; pass an observer instead."
|
|
3811
|
+
forbidden: "Passing separate handlers is forbidden; pass an observer instead.",
|
|
3812
|
+
suggest: "Replace with observer object."
|
|
3798
3813
|
},
|
|
3799
3814
|
schema: [
|
|
3800
3815
|
{
|
|
@@ -3845,7 +3860,7 @@ var preferObserverRule = ruleCreator({
|
|
|
3845
3860
|
fix,
|
|
3846
3861
|
suggest: [
|
|
3847
3862
|
{
|
|
3848
|
-
messageId: "
|
|
3863
|
+
messageId: "suggest",
|
|
3849
3864
|
fix
|
|
3850
3865
|
}
|
|
3851
3866
|
]
|
|
@@ -3859,7 +3874,7 @@ var preferObserverRule = ruleCreator({
|
|
|
3859
3874
|
fix,
|
|
3860
3875
|
suggest: [
|
|
3861
3876
|
{
|
|
3862
|
-
messageId: "
|
|
3877
|
+
messageId: "suggest",
|
|
3863
3878
|
fix
|
|
3864
3879
|
}
|
|
3865
3880
|
]
|
|
@@ -4262,10 +4277,10 @@ var throwErrorRule = ruleCreator({
|
|
|
4262
4277
|
const body = tsNode.body;
|
|
4263
4278
|
type = program.getTypeChecker().getTypeAtLocation(annotation != null ? annotation : body);
|
|
4264
4279
|
}
|
|
4265
|
-
if (allowThrowingAny &&
|
|
4280
|
+
if (allowThrowingAny && tsutils5.isIntrinsicAnyType(type)) {
|
|
4266
4281
|
return;
|
|
4267
4282
|
}
|
|
4268
|
-
if (allowThrowingUnknown &&
|
|
4283
|
+
if (allowThrowingUnknown && tsutils5.isIntrinsicUnknownType(type)) {
|
|
4269
4284
|
return;
|
|
4270
4285
|
}
|
|
4271
4286
|
if (couldBeType(type, /^Error$/)) {
|
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.8.
|
|
3
|
+
var version = "0.8.5";
|
|
4
4
|
|
|
5
5
|
// src/configs/recommended.ts
|
|
6
6
|
var createRecommendedConfig = (plugin2) => ({
|
|
@@ -1203,11 +1203,14 @@ var noCyclicActionRule = ruleCreator({
|
|
|
1203
1203
|
});
|
|
1204
1204
|
|
|
1205
1205
|
// src/rules/no-explicit-generics.ts
|
|
1206
|
+
import { ESLintUtils as ESLintUtils5 } from "@typescript-eslint/utils";
|
|
1207
|
+
import * as tsutils2 from "ts-api-utils";
|
|
1206
1208
|
var noExplicitGenericsRule = ruleCreator({
|
|
1207
1209
|
defaultOptions: [],
|
|
1208
1210
|
meta: {
|
|
1209
1211
|
docs: {
|
|
1210
|
-
description: "Disallow unnecessary explicit generic type arguments."
|
|
1212
|
+
description: "Disallow unnecessary explicit generic type arguments.",
|
|
1213
|
+
requiresTypeChecking: true
|
|
1211
1214
|
},
|
|
1212
1215
|
messages: {
|
|
1213
1216
|
forbidden: "Explicit generic type arguments are forbidden."
|
|
@@ -1223,6 +1226,17 @@ var noExplicitGenericsRule = ruleCreator({
|
|
|
1223
1226
|
node
|
|
1224
1227
|
});
|
|
1225
1228
|
}
|
|
1229
|
+
function isUnion(node) {
|
|
1230
|
+
if (!node) {
|
|
1231
|
+
return false;
|
|
1232
|
+
}
|
|
1233
|
+
if (isUnionType(node)) {
|
|
1234
|
+
return true;
|
|
1235
|
+
}
|
|
1236
|
+
const { getTypeAtLocation } = ESLintUtils5.getParserServices(context);
|
|
1237
|
+
const type = getTypeAtLocation(node);
|
|
1238
|
+
return tsutils2.isUnionOrIntersectionType(type);
|
|
1239
|
+
}
|
|
1226
1240
|
function checkBehaviorSubjects(node) {
|
|
1227
1241
|
var _a;
|
|
1228
1242
|
const parent = node.parent;
|
|
@@ -1230,7 +1244,7 @@ var noExplicitGenericsRule = ruleCreator({
|
|
|
1230
1244
|
arguments: [value]
|
|
1231
1245
|
} = parent;
|
|
1232
1246
|
const typeArgs = (_a = parent.typeArguments) == null ? void 0 : _a.params[0];
|
|
1233
|
-
if (isArrayExpression(value) || isObjectExpression(value) ||
|
|
1247
|
+
if (isArrayExpression(value) || isObjectExpression(value) || isUnion(typeArgs)) {
|
|
1234
1248
|
return;
|
|
1235
1249
|
}
|
|
1236
1250
|
report(node);
|
|
@@ -1242,7 +1256,7 @@ var noExplicitGenericsRule = ruleCreator({
|
|
|
1242
1256
|
arguments: [, value]
|
|
1243
1257
|
} = parent;
|
|
1244
1258
|
const typeArgs = (_a = parent.typeArguments) == null ? void 0 : _a.params[0];
|
|
1245
|
-
if (isArrayExpression(value) || isObjectExpression(value) ||
|
|
1259
|
+
if (isArrayExpression(value) || isObjectExpression(value) || isUnion(typeArgs)) {
|
|
1246
1260
|
return;
|
|
1247
1261
|
}
|
|
1248
1262
|
report(node);
|
|
@@ -1362,7 +1376,7 @@ var noExposedSubjectsRule = ruleCreator({
|
|
|
1362
1376
|
});
|
|
1363
1377
|
|
|
1364
1378
|
// src/rules/no-finnish.ts
|
|
1365
|
-
import { ESLintUtils as
|
|
1379
|
+
import { ESLintUtils as ESLintUtils6 } from "@typescript-eslint/utils";
|
|
1366
1380
|
var noFinnishRule = ruleCreator({
|
|
1367
1381
|
defaultOptions: [],
|
|
1368
1382
|
meta: {
|
|
@@ -1378,7 +1392,7 @@ var noFinnishRule = ruleCreator({
|
|
|
1378
1392
|
},
|
|
1379
1393
|
name: "no-finnish",
|
|
1380
1394
|
create: (context) => {
|
|
1381
|
-
const { esTreeNodeToTSNodeMap } =
|
|
1395
|
+
const { esTreeNodeToTSNodeMap } = ESLintUtils6.getParserServices(context);
|
|
1382
1396
|
const { couldBeObservable, couldReturnObservable } = getTypeServices(context);
|
|
1383
1397
|
function checkNode(nameNode, typeNode) {
|
|
1384
1398
|
if (couldBeObservable(typeNode != null ? typeNode : nameNode) || couldReturnObservable(typeNode != null ? typeNode : nameNode)) {
|
|
@@ -1539,7 +1553,7 @@ var noFloatingObservablesRule = ruleCreator({
|
|
|
1539
1553
|
});
|
|
1540
1554
|
|
|
1541
1555
|
// src/rules/no-ignored-default-value.ts
|
|
1542
|
-
import { ESLintUtils as
|
|
1556
|
+
import { ESLintUtils as ESLintUtils7 } from "@typescript-eslint/utils";
|
|
1543
1557
|
var noIgnoredDefaultValueRule = ruleCreator({
|
|
1544
1558
|
defaultOptions: [],
|
|
1545
1559
|
meta: {
|
|
@@ -1556,7 +1570,7 @@ var noIgnoredDefaultValueRule = ruleCreator({
|
|
|
1556
1570
|
},
|
|
1557
1571
|
name: "no-ignored-default-value",
|
|
1558
1572
|
create: (context) => {
|
|
1559
|
-
const { getTypeAtLocation } =
|
|
1573
|
+
const { getTypeAtLocation } = ESLintUtils7.getParserServices(context);
|
|
1560
1574
|
const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
|
|
1561
1575
|
function checkConfigObj(configArg) {
|
|
1562
1576
|
if (!configArg.properties.some((p) => isProperty(p) && isIdentifier(p.key) && p.key.name === "defaultValue")) {
|
|
@@ -1642,7 +1656,7 @@ var noIgnoredDefaultValueRule = ruleCreator({
|
|
|
1642
1656
|
});
|
|
1643
1657
|
|
|
1644
1658
|
// src/rules/no-ignored-error.ts
|
|
1645
|
-
import { ESLintUtils as
|
|
1659
|
+
import { ESLintUtils as ESLintUtils8 } from "@typescript-eslint/utils";
|
|
1646
1660
|
var noIgnoredErrorRule = ruleCreator({
|
|
1647
1661
|
defaultOptions: [],
|
|
1648
1662
|
meta: {
|
|
@@ -1659,7 +1673,7 @@ var noIgnoredErrorRule = ruleCreator({
|
|
|
1659
1673
|
},
|
|
1660
1674
|
name: "no-ignored-error",
|
|
1661
1675
|
create: (context) => {
|
|
1662
|
-
const { getTypeAtLocation } =
|
|
1676
|
+
const { getTypeAtLocation } = ESLintUtils8.getParserServices(context);
|
|
1663
1677
|
const { couldBeObservable, couldBeFunction: couldBeFunction2 } = getTypeServices(context);
|
|
1664
1678
|
function isMissingErrorCallback(callExpression) {
|
|
1665
1679
|
if (callExpression.arguments.length >= 2) {
|
|
@@ -2253,9 +2267,9 @@ var noInternalRule = ruleCreator({
|
|
|
2253
2267
|
});
|
|
2254
2268
|
|
|
2255
2269
|
// src/rules/no-misused-observables.ts
|
|
2256
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES6, ESLintUtils as
|
|
2270
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES6, ESLintUtils as ESLintUtils9 } from "@typescript-eslint/utils";
|
|
2257
2271
|
import { getFunctionHeadLocation, isFunction } from "@typescript-eslint/utils/ast-utils";
|
|
2258
|
-
import * as
|
|
2272
|
+
import * as tsutils3 from "ts-api-utils";
|
|
2259
2273
|
import ts6 from "typescript";
|
|
2260
2274
|
function parseChecksVoidReturn(checksVoidReturn) {
|
|
2261
2275
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -2337,7 +2351,7 @@ var noMisusedObservablesRule = ruleCreator({
|
|
|
2337
2351
|
},
|
|
2338
2352
|
name: "no-misused-observables",
|
|
2339
2353
|
create: (context) => {
|
|
2340
|
-
const { program, esTreeNodeToTSNodeMap, getTypeAtLocation } =
|
|
2354
|
+
const { program, esTreeNodeToTSNodeMap, getTypeAtLocation } = ESLintUtils9.getParserServices(context);
|
|
2341
2355
|
const checker = program.getTypeChecker();
|
|
2342
2356
|
const { couldBeObservable, couldReturnObservable } = getTypeServices(context);
|
|
2343
2357
|
const [config = {}] = context.options;
|
|
@@ -2552,7 +2566,7 @@ function voidFunctionArguments(checker, tsNode) {
|
|
|
2552
2566
|
}
|
|
2553
2567
|
const voidReturnIndices = /* @__PURE__ */ new Set();
|
|
2554
2568
|
const type = checker.getTypeAtLocation(tsNode.expression);
|
|
2555
|
-
for (const subType of
|
|
2569
|
+
for (const subType of tsutils3.unionTypeParts(type)) {
|
|
2556
2570
|
const signatures = ts6.isCallExpression(tsNode) ? subType.getCallSignatures() : subType.getConstructSignatures();
|
|
2557
2571
|
for (const signature of signatures) {
|
|
2558
2572
|
for (const [index, parameter] of signature.parameters.entries()) {
|
|
@@ -2567,13 +2581,13 @@ function voidFunctionArguments(checker, tsNode) {
|
|
|
2567
2581
|
}
|
|
2568
2582
|
function isVoidReturningFunctionType(type) {
|
|
2569
2583
|
let hasVoidReturn = false;
|
|
2570
|
-
for (const subType of
|
|
2584
|
+
for (const subType of tsutils3.unionTypeParts(type)) {
|
|
2571
2585
|
for (const signature of subType.getCallSignatures()) {
|
|
2572
2586
|
const returnType = signature.getReturnType();
|
|
2573
2587
|
if (couldBeType(returnType, "Observable")) {
|
|
2574
2588
|
return false;
|
|
2575
2589
|
}
|
|
2576
|
-
hasVoidReturn || (hasVoidReturn =
|
|
2590
|
+
hasVoidReturn || (hasVoidReturn = tsutils3.isTypeFlagSet(returnType, ts6.TypeFlags.Void));
|
|
2577
2591
|
}
|
|
2578
2592
|
}
|
|
2579
2593
|
return hasVoidReturn;
|
|
@@ -2586,7 +2600,7 @@ function getMemberIfExists(type, memberName) {
|
|
|
2586
2600
|
var _a, _b;
|
|
2587
2601
|
const escapedMemberName = ts6.escapeLeadingUnderscores(memberName);
|
|
2588
2602
|
const symbolMemberMatch = (_b = (_a = type.getSymbol()) == null ? void 0 : _a.members) == null ? void 0 : _b.get(escapedMemberName);
|
|
2589
|
-
return symbolMemberMatch != null ? symbolMemberMatch :
|
|
2603
|
+
return symbolMemberMatch != null ? symbolMemberMatch : tsutils3.getPropertyOfType(type, escapedMemberName);
|
|
2590
2604
|
}
|
|
2591
2605
|
function isStaticMember(node) {
|
|
2592
2606
|
return (isMethodDefinition(node) || isPropertyDefinition(node) || isAccessorProperty(node)) && node.static;
|
|
@@ -3243,7 +3257,7 @@ import { ${functionName} } from ${quote}rxjs${quote};`
|
|
|
3243
3257
|
});
|
|
3244
3258
|
|
|
3245
3259
|
// src/rules/no-unbound-methods.ts
|
|
3246
|
-
import { ESLintUtils as
|
|
3260
|
+
import { ESLintUtils as ESLintUtils10 } from "@typescript-eslint/utils";
|
|
3247
3261
|
var defaultOptions12 = [];
|
|
3248
3262
|
var noUnboundMethodsRule = ruleCreator({
|
|
3249
3263
|
defaultOptions: defaultOptions12,
|
|
@@ -3268,7 +3282,7 @@ var noUnboundMethodsRule = ruleCreator({
|
|
|
3268
3282
|
},
|
|
3269
3283
|
name: "no-unbound-methods",
|
|
3270
3284
|
create: (context) => {
|
|
3271
|
-
const { getTypeAtLocation } =
|
|
3285
|
+
const { getTypeAtLocation } = ESLintUtils10.getParserServices(context);
|
|
3272
3286
|
const { couldBeObservable, couldBeSubscription } = getTypeServices(context);
|
|
3273
3287
|
const nodeMap = /* @__PURE__ */ new WeakMap();
|
|
3274
3288
|
const [config = {}] = context.options;
|
|
@@ -3539,8 +3553,8 @@ var noUnsafeFirstRule = ruleCreator({
|
|
|
3539
3553
|
});
|
|
3540
3554
|
|
|
3541
3555
|
// src/rules/no-unsafe-subject-next.ts
|
|
3542
|
-
import { ESLintUtils as
|
|
3543
|
-
import * as
|
|
3556
|
+
import { ESLintUtils as ESLintUtils11 } from "@typescript-eslint/utils";
|
|
3557
|
+
import * as tsutils4 from "ts-api-utils";
|
|
3544
3558
|
import ts7 from "typescript";
|
|
3545
3559
|
var noUnsafeSubjectNext = ruleCreator({
|
|
3546
3560
|
defaultOptions: [],
|
|
@@ -3558,25 +3572,25 @@ var noUnsafeSubjectNext = ruleCreator({
|
|
|
3558
3572
|
},
|
|
3559
3573
|
name: "no-unsafe-subject-next",
|
|
3560
3574
|
create: (context) => {
|
|
3561
|
-
const { getTypeAtLocation, program } =
|
|
3575
|
+
const { getTypeAtLocation, program } = ESLintUtils11.getParserServices(context);
|
|
3562
3576
|
const typeChecker = program.getTypeChecker();
|
|
3563
3577
|
return {
|
|
3564
3578
|
[`CallExpression[callee.property.name='next']`]: (node) => {
|
|
3565
3579
|
if (node.arguments.length === 0 && isMemberExpression(node.callee)) {
|
|
3566
3580
|
const type = getTypeAtLocation(node.callee.object);
|
|
3567
|
-
if (
|
|
3581
|
+
if (tsutils4.isTypeReference(type) && couldBeType(type, "Subject")) {
|
|
3568
3582
|
const [typeArg] = typeChecker.getTypeArguments(type);
|
|
3569
|
-
if (
|
|
3583
|
+
if (tsutils4.isTypeFlagSet(typeArg, ts7.TypeFlags.Any)) {
|
|
3570
3584
|
return;
|
|
3571
3585
|
}
|
|
3572
|
-
if (
|
|
3586
|
+
if (tsutils4.isTypeFlagSet(typeArg, ts7.TypeFlags.Unknown)) {
|
|
3573
3587
|
return;
|
|
3574
3588
|
}
|
|
3575
|
-
if (
|
|
3589
|
+
if (tsutils4.isTypeFlagSet(typeArg, ts7.TypeFlags.Void)) {
|
|
3576
3590
|
return;
|
|
3577
3591
|
}
|
|
3578
|
-
if (
|
|
3579
|
-
(t) =>
|
|
3592
|
+
if (tsutils4.isUnionType(typeArg) && typeArg.types.some(
|
|
3593
|
+
(t) => tsutils4.isTypeFlagSet(t, ts7.TypeFlags.Void)
|
|
3580
3594
|
)) {
|
|
3581
3595
|
return;
|
|
3582
3596
|
}
|
|
@@ -3794,7 +3808,8 @@ var preferObserverRule = ruleCreator({
|
|
|
3794
3808
|
fixable: "code",
|
|
3795
3809
|
hasSuggestions: true,
|
|
3796
3810
|
messages: {
|
|
3797
|
-
forbidden: "Passing separate handlers is forbidden; pass an observer instead."
|
|
3811
|
+
forbidden: "Passing separate handlers is forbidden; pass an observer instead.",
|
|
3812
|
+
suggest: "Replace with observer object."
|
|
3798
3813
|
},
|
|
3799
3814
|
schema: [
|
|
3800
3815
|
{
|
|
@@ -3845,7 +3860,7 @@ var preferObserverRule = ruleCreator({
|
|
|
3845
3860
|
fix,
|
|
3846
3861
|
suggest: [
|
|
3847
3862
|
{
|
|
3848
|
-
messageId: "
|
|
3863
|
+
messageId: "suggest",
|
|
3849
3864
|
fix
|
|
3850
3865
|
}
|
|
3851
3866
|
]
|
|
@@ -3859,7 +3874,7 @@ var preferObserverRule = ruleCreator({
|
|
|
3859
3874
|
fix,
|
|
3860
3875
|
suggest: [
|
|
3861
3876
|
{
|
|
3862
|
-
messageId: "
|
|
3877
|
+
messageId: "suggest",
|
|
3863
3878
|
fix
|
|
3864
3879
|
}
|
|
3865
3880
|
]
|
|
@@ -4019,7 +4034,7 @@ var preferRootOperatorsRule = ruleCreator({
|
|
|
4019
4034
|
});
|
|
4020
4035
|
|
|
4021
4036
|
// src/rules/suffix-subjects.ts
|
|
4022
|
-
import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as
|
|
4037
|
+
import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as ESLintUtils12 } from "@typescript-eslint/utils";
|
|
4023
4038
|
var defaultOptions18 = [];
|
|
4024
4039
|
var suffixSubjectsRule = ruleCreator({
|
|
4025
4040
|
defaultOptions: defaultOptions18,
|
|
@@ -4047,7 +4062,7 @@ var suffixSubjectsRule = ruleCreator({
|
|
|
4047
4062
|
},
|
|
4048
4063
|
name: "suffix-subjects",
|
|
4049
4064
|
create: (context) => {
|
|
4050
|
-
const { esTreeNodeToTSNodeMap } =
|
|
4065
|
+
const { esTreeNodeToTSNodeMap } = ESLintUtils12.getParserServices(context);
|
|
4051
4066
|
const { couldBeType: couldBeType2 } = getTypeServices(context);
|
|
4052
4067
|
const [config = {}] = context.options;
|
|
4053
4068
|
const validate = {
|
|
@@ -4217,8 +4232,8 @@ var suffixSubjectsRule = ruleCreator({
|
|
|
4217
4232
|
});
|
|
4218
4233
|
|
|
4219
4234
|
// src/rules/throw-error.ts
|
|
4220
|
-
import { ESLintUtils as
|
|
4221
|
-
import * as
|
|
4235
|
+
import { ESLintUtils as ESLintUtils13 } from "@typescript-eslint/utils";
|
|
4236
|
+
import * as tsutils5 from "ts-api-utils";
|
|
4222
4237
|
var defaultOptions19 = [];
|
|
4223
4238
|
var throwErrorRule = ruleCreator({
|
|
4224
4239
|
defaultOptions: defaultOptions19,
|
|
@@ -4247,7 +4262,7 @@ var throwErrorRule = ruleCreator({
|
|
|
4247
4262
|
},
|
|
4248
4263
|
name: "throw-error",
|
|
4249
4264
|
create: (context) => {
|
|
4250
|
-
const { esTreeNodeToTSNodeMap, program, getTypeAtLocation } =
|
|
4265
|
+
const { esTreeNodeToTSNodeMap, program, getTypeAtLocation } = ESLintUtils13.getParserServices(context);
|
|
4251
4266
|
const { couldBeObservable, couldBeSubject } = getTypeServices(context);
|
|
4252
4267
|
const [config = {}] = context.options;
|
|
4253
4268
|
const { allowThrowingAny = true, allowThrowingUnknown = true } = config;
|
|
@@ -4262,10 +4277,10 @@ var throwErrorRule = ruleCreator({
|
|
|
4262
4277
|
const body = tsNode.body;
|
|
4263
4278
|
type = program.getTypeChecker().getTypeAtLocation(annotation != null ? annotation : body);
|
|
4264
4279
|
}
|
|
4265
|
-
if (allowThrowingAny &&
|
|
4280
|
+
if (allowThrowingAny && tsutils5.isIntrinsicAnyType(type)) {
|
|
4266
4281
|
return;
|
|
4267
4282
|
}
|
|
4268
|
-
if (allowThrowingUnknown &&
|
|
4283
|
+
if (allowThrowingUnknown && tsutils5.isIntrinsicUnknownType(type)) {
|
|
4269
4284
|
return;
|
|
4270
4285
|
}
|
|
4271
4286
|
if (couldBeType(type, /^Error$/)) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-plugin-rxjs-x",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.5",
|
|
5
5
|
"packageManager": "yarn@4.12.0+sha512.f45ab632439a67f8bc759bf32ead036a1f413287b9042726b7cc4818b7b49e14e9423ba49b18f9e06ea4941c1ad062385b1d8760a8d5091a1a31e5f6219afca8",
|
|
6
6
|
"description": "Modern ESLint plugin for RxJS",
|
|
7
7
|
"author": "Jason Weinzierl <weinzierljason@gmail.com>",
|
|
@@ -77,26 +77,26 @@
|
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@eslint/js": "^9.39.2",
|
|
80
|
-
"@stylistic/eslint-plugin": "^5.
|
|
80
|
+
"@stylistic/eslint-plugin": "^5.7.1",
|
|
81
81
|
"@types/common-tags": "^1.8.4",
|
|
82
82
|
"@types/node": "~18.18.0",
|
|
83
|
-
"@typescript-eslint/rule-tester": "^8.
|
|
83
|
+
"@typescript-eslint/rule-tester": "^8.53.1",
|
|
84
84
|
"@typescript/vfs": "^1.6.2",
|
|
85
85
|
"@vitest/coverage-v8": "^3.2.4",
|
|
86
86
|
"@vitest/eslint-plugin": "^1.4.0",
|
|
87
|
-
"bumpp": "^10.
|
|
87
|
+
"bumpp": "^10.4.0",
|
|
88
88
|
"eslint": "^9.39.2",
|
|
89
89
|
"eslint-config-flat-gitignore": "^2.1.0",
|
|
90
90
|
"eslint-doc-generator": "^2.4.0",
|
|
91
91
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
92
|
-
"eslint-plugin-eslint-plugin": "^7.
|
|
92
|
+
"eslint-plugin-eslint-plugin": "^7.3.0",
|
|
93
93
|
"eslint-plugin-import-x": "^4.16.1",
|
|
94
|
-
"eslint-plugin-n": "^17.23.
|
|
94
|
+
"eslint-plugin-n": "^17.23.2",
|
|
95
95
|
"markdownlint-cli2": "~0.19.0",
|
|
96
96
|
"rxjs": "^7.8.2",
|
|
97
97
|
"tsup": "8.5.0",
|
|
98
|
-
"typescript": "~5.
|
|
99
|
-
"typescript-eslint": "^8.
|
|
98
|
+
"typescript": "~5.9.3",
|
|
99
|
+
"typescript-eslint": "^8.53.1",
|
|
100
100
|
"vite": "^6.4.1",
|
|
101
101
|
"vitest": "^3.2.4"
|
|
102
102
|
},
|