eslint-plugin-rxjs-x 0.5.0 → 0.6.0

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/dist/index.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  // package.json
2
2
  var name = "eslint-plugin-rxjs-x";
3
- var version = "0.5.0";
3
+ var version = "0.6.0";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
7
+ name: "rxjs-x/recommended",
7
8
  plugins: {
8
9
  "rxjs-x": plugin2
9
10
  },
@@ -20,6 +21,7 @@ var createRecommendedConfig = (plugin2) => ({
20
21
  "rxjs-x/no-redundant-notify": "error",
21
22
  "rxjs-x/no-sharereplay": "error",
22
23
  "rxjs-x/no-subject-unsubscribe": "error",
24
+ "rxjs-x/no-subscribe-in-pipe": "error",
23
25
  "rxjs-x/no-topromise": "error",
24
26
  "rxjs-x/no-unbound-methods": "error",
25
27
  "rxjs-x/no-unsafe-subject-next": "error",
@@ -32,6 +34,7 @@ var createRecommendedConfig = (plugin2) => ({
32
34
 
33
35
  // src/configs/strict.ts
34
36
  var createStrictConfig = (plugin2) => ({
37
+ name: "rxjs-x/strict",
35
38
  plugins: {
36
39
  "rxjs-x": plugin2
37
40
  },
@@ -51,11 +54,13 @@ var createStrictConfig = (plugin2) => ({
51
54
  }],
52
55
  "rxjs-x/no-index": "error",
53
56
  "rxjs-x/no-internal": "error",
57
+ "rxjs-x/no-misused-observables": "error",
54
58
  "rxjs-x/no-nested-subscribe": "error",
55
59
  "rxjs-x/no-redundant-notify": "error",
56
60
  "rxjs-x/no-sharereplay": "error",
57
61
  "rxjs-x/no-subclass": "error",
58
62
  "rxjs-x/no-subject-unsubscribe": "error",
63
+ "rxjs-x/no-subscribe-in-pipe": "error",
59
64
  "rxjs-x/no-topromise": "error",
60
65
  "rxjs-x/no-unbound-methods": "error",
61
66
  "rxjs-x/no-unsafe-subject-next": "error",
@@ -320,12 +325,18 @@ function isImportNamespaceSpecifier(node) {
320
325
  function isImportSpecifier(node) {
321
326
  return node.type === AST_NODE_TYPES2.ImportSpecifier;
322
327
  }
328
+ function isJSXExpressionContainer(node) {
329
+ return node.type === AST_NODE_TYPES2.JSXExpressionContainer;
330
+ }
323
331
  function isLiteral(node) {
324
332
  return node.type === AST_NODE_TYPES2.Literal;
325
333
  }
326
334
  function isMemberExpression(node) {
327
335
  return node.type === AST_NODE_TYPES2.MemberExpression;
328
336
  }
337
+ function isMethodDefinition(node) {
338
+ return node.type === AST_NODE_TYPES2.MethodDefinition;
339
+ }
329
340
  function isObjectExpression(node) {
330
341
  return node.type === AST_NODE_TYPES2.ObjectExpression;
331
342
  }
@@ -338,6 +349,9 @@ function isProgram(node) {
338
349
  function isProperty(node) {
339
350
  return node.type === AST_NODE_TYPES2.Property;
340
351
  }
352
+ function isPropertyDefinition(node) {
353
+ return node.type === AST_NODE_TYPES2.PropertyDefinition;
354
+ }
341
355
  function isUnaryExpression(node) {
342
356
  return node.type === AST_NODE_TYPES2.UnaryExpression;
343
357
  }
@@ -363,6 +377,7 @@ function getTypeServices(context) {
363
377
  tsTypeNode = (_a = tsNode.type) != null ? _a : tsNode.body;
364
378
  } else if (ts4.isCallSignatureDeclaration(tsNode) || ts4.isMethodSignature(tsNode)) {
365
379
  tsTypeNode = tsNode.type;
380
+ } else if (ts4.isPropertySignature(tsNode)) {
366
381
  }
367
382
  return Boolean(
368
383
  tsTypeNode && couldBeType(
@@ -2086,6 +2101,403 @@ var noInternalRule = ruleCreator({
2086
2101
  }
2087
2102
  });
2088
2103
 
2104
+ // src/rules/no-misused-observables.ts
2105
+ import { AST_NODE_TYPES as AST_NODE_TYPES6, ESLintUtils as ESLintUtils8 } from "@typescript-eslint/utils";
2106
+ import * as tsutils2 from "ts-api-utils";
2107
+ import ts6 from "typescript";
2108
+ function parseChecksVoidReturn(checksVoidReturn) {
2109
+ var _a, _b, _c, _d, _e, _f;
2110
+ switch (checksVoidReturn) {
2111
+ case false:
2112
+ return false;
2113
+ case true:
2114
+ case void 0:
2115
+ return {
2116
+ arguments: true,
2117
+ attributes: true,
2118
+ inheritedMethods: true,
2119
+ properties: true,
2120
+ returns: true,
2121
+ variables: true
2122
+ };
2123
+ default:
2124
+ return {
2125
+ arguments: (_a = checksVoidReturn.arguments) != null ? _a : true,
2126
+ attributes: (_b = checksVoidReturn.attributes) != null ? _b : true,
2127
+ inheritedMethods: (_c = checksVoidReturn.inheritedMethods) != null ? _c : true,
2128
+ properties: (_d = checksVoidReturn.properties) != null ? _d : true,
2129
+ returns: (_e = checksVoidReturn.returns) != null ? _e : true,
2130
+ variables: (_f = checksVoidReturn.variables) != null ? _f : true
2131
+ };
2132
+ }
2133
+ }
2134
+ var defaultOptions8 = [];
2135
+ var noMisusedObservablesRule = ruleCreator({
2136
+ defaultOptions: defaultOptions8,
2137
+ meta: {
2138
+ docs: {
2139
+ description: "Disallow Observables in places not designed to handle them.",
2140
+ recommended: "strict",
2141
+ requiresTypeChecking: true
2142
+ },
2143
+ messages: {
2144
+ forbiddenVoidReturnArgument: "Observable returned in function argument where a void return was expected.",
2145
+ forbiddenVoidReturnAttribute: "Observable-returning function provided to attribute where a void return was expected.",
2146
+ forbiddenVoidReturnInheritedMethod: "Observable-returning method provided where a void return was expected by extended/implemented type '{{heritageTypeName}}'.",
2147
+ forbiddenVoidReturnProperty: "Observable-returning function provided to property where a void return was expected.",
2148
+ forbiddenVoidReturnReturnValue: "Observable-returning function provided to return value where a void return was expected.",
2149
+ forbiddenVoidReturnVariable: "Observable-returning function provided to variable where a void return was expected.",
2150
+ forbiddenSpread: "Expected a non-Observable value to be spread into an object."
2151
+ },
2152
+ schema: [
2153
+ {
2154
+ properties: {
2155
+ checksVoidReturn: {
2156
+ default: true,
2157
+ description: "Disallow returning an Observable from a function typed as returning `void`.",
2158
+ oneOf: [
2159
+ {
2160
+ default: true,
2161
+ type: "boolean",
2162
+ description: "Disallow returning an Observable from all types of functions typed as returning `void`."
2163
+ },
2164
+ {
2165
+ type: "object",
2166
+ additionalProperties: false,
2167
+ description: "Which forms of functions may have checking disabled.",
2168
+ properties: {
2169
+ arguments: { type: "boolean", description: "Disallow passing an Observable-returning function as an argument where the parameter type expects a function that returns `void`." },
2170
+ attributes: { type: "boolean", description: "Disallow passing an Observable-returning function as a JSX attribute expected to be a function that returns `void`." },
2171
+ inheritedMethods: { type: "boolean", description: "Disallow providing an Observable-returning function where a function that returns `void` is expected by an extended or implemented type." },
2172
+ properties: { type: "boolean", description: "Disallow providing an Observable-returning function where a function that returns `void` is expected by a property." },
2173
+ returns: { type: "boolean", description: "Disallow returning an Observable-returning function where a function that returns `void` is expected." },
2174
+ variables: { type: "boolean", description: "Disallow assigning or declaring an Observable-returning function where a function that returns `void` is expected." }
2175
+ }
2176
+ }
2177
+ ]
2178
+ },
2179
+ checksSpreads: { type: "boolean", default: true, description: "Disallow `...` spreading an Observable." }
2180
+ },
2181
+ type: "object"
2182
+ }
2183
+ ],
2184
+ type: "problem"
2185
+ },
2186
+ name: "no-misused-observables",
2187
+ create: (context) => {
2188
+ const { program, esTreeNodeToTSNodeMap, getTypeAtLocation } = ESLintUtils8.getParserServices(context);
2189
+ const checker = program.getTypeChecker();
2190
+ const { couldBeObservable, couldReturnObservable } = getTypeServices(context);
2191
+ const [config = {}] = context.options;
2192
+ const { checksVoidReturn = true, checksSpreads = true } = config;
2193
+ const parsedChecksVoidReturn = parseChecksVoidReturn(checksVoidReturn);
2194
+ const voidReturnChecks = parsedChecksVoidReturn ? {
2195
+ ...parsedChecksVoidReturn.arguments && {
2196
+ CallExpression: checkArguments,
2197
+ NewExpression: checkArguments
2198
+ },
2199
+ ...parsedChecksVoidReturn.attributes && {
2200
+ JSXAttribute: checkJSXAttribute
2201
+ },
2202
+ ...parsedChecksVoidReturn.inheritedMethods && {
2203
+ ClassDeclaration: checkClassLikeOrInterfaceNode,
2204
+ ClassExpression: checkClassLikeOrInterfaceNode,
2205
+ TSInterfaceDeclaration: checkClassLikeOrInterfaceNode
2206
+ },
2207
+ ...parsedChecksVoidReturn.properties && {
2208
+ Property: checkProperty
2209
+ },
2210
+ ...parsedChecksVoidReturn.returns && {
2211
+ ReturnStatement: checkReturnStatement
2212
+ },
2213
+ ...parsedChecksVoidReturn.variables && {
2214
+ AssignmentExpression: checkAssignment,
2215
+ VariableDeclarator: checkVariableDeclaration
2216
+ }
2217
+ } : {};
2218
+ const spreadChecks = {
2219
+ SpreadElement: (node) => {
2220
+ if (couldBeObservable(node.argument)) {
2221
+ context.report({
2222
+ messageId: "forbiddenSpread",
2223
+ node: node.argument
2224
+ });
2225
+ }
2226
+ }
2227
+ };
2228
+ function checkArguments(node) {
2229
+ const tsNode = esTreeNodeToTSNodeMap.get(node);
2230
+ const voidArgs = voidFunctionArguments(checker, tsNode);
2231
+ if (!voidArgs.size) {
2232
+ return;
2233
+ }
2234
+ for (const [index, argument] of node.arguments.entries()) {
2235
+ if (!voidArgs.has(index)) {
2236
+ continue;
2237
+ }
2238
+ if (couldReturnObservable(argument)) {
2239
+ context.report({
2240
+ messageId: "forbiddenVoidReturnArgument",
2241
+ node: argument
2242
+ });
2243
+ }
2244
+ }
2245
+ }
2246
+ function checkJSXAttribute(node) {
2247
+ if (!node.value || !isJSXExpressionContainer(node.value)) {
2248
+ return;
2249
+ }
2250
+ if (couldReturnObservable(node.value.expression)) {
2251
+ context.report({
2252
+ messageId: "forbiddenVoidReturnAttribute",
2253
+ node: node.value
2254
+ });
2255
+ }
2256
+ }
2257
+ function checkClassLikeOrInterfaceNode(node) {
2258
+ var _a;
2259
+ const tsNode = esTreeNodeToTSNodeMap.get(node);
2260
+ const heritageTypes = getHeritageTypes(checker, tsNode);
2261
+ if (!(heritageTypes == null ? void 0 : heritageTypes.length)) {
2262
+ return;
2263
+ }
2264
+ for (const element of node.body.body) {
2265
+ const tsElement = esTreeNodeToTSNodeMap.get(element);
2266
+ const memberName = (_a = tsElement == null ? void 0 : tsElement.name) == null ? void 0 : _a.getText();
2267
+ if (memberName === void 0) {
2268
+ continue;
2269
+ }
2270
+ if (!couldReturnObservable(element)) {
2271
+ continue;
2272
+ }
2273
+ if (isStaticMember(element)) {
2274
+ continue;
2275
+ }
2276
+ for (const heritageType of heritageTypes) {
2277
+ const heritageMember = getMemberIfExists(heritageType, memberName);
2278
+ if (heritageMember === void 0) {
2279
+ continue;
2280
+ }
2281
+ const memberType = checker.getTypeOfSymbolAtLocation(heritageMember, tsElement);
2282
+ if (!isVoidReturningFunctionType(memberType)) {
2283
+ continue;
2284
+ }
2285
+ context.report({
2286
+ messageId: "forbiddenVoidReturnInheritedMethod",
2287
+ node: element,
2288
+ data: { heritageTypeName: checker.typeToString(heritageType) }
2289
+ });
2290
+ }
2291
+ }
2292
+ }
2293
+ function checkProperty(node) {
2294
+ const tsNode = esTreeNodeToTSNodeMap.get(node);
2295
+ const contextualType = getPropertyContextualType(checker, tsNode);
2296
+ if (contextualType === void 0) {
2297
+ return;
2298
+ }
2299
+ if (!isVoidReturningFunctionType(contextualType)) {
2300
+ return;
2301
+ }
2302
+ if (!couldReturnObservable(node.value)) {
2303
+ return;
2304
+ }
2305
+ context.report({
2306
+ messageId: "forbiddenVoidReturnProperty",
2307
+ node: node.value
2308
+ });
2309
+ }
2310
+ function checkReturnStatement(node) {
2311
+ const tsNode = esTreeNodeToTSNodeMap.get(node);
2312
+ if (tsNode.expression === void 0 || !node.argument) {
2313
+ return;
2314
+ }
2315
+ function getFunctionNode() {
2316
+ let current = node.parent;
2317
+ while (current && !isArrowFunctionExpression(current) && !isFunctionExpression(current) && !isFunctionDeclaration(current)) {
2318
+ current = current.parent;
2319
+ }
2320
+ return current;
2321
+ }
2322
+ const functionNode = getFunctionNode();
2323
+ if ((functionNode == null ? void 0 : functionNode.returnType) && !isPossiblyFunctionType(functionNode.returnType)) {
2324
+ return;
2325
+ }
2326
+ const contextualType = checker.getContextualType(tsNode.expression);
2327
+ if (contextualType === void 0) {
2328
+ return;
2329
+ }
2330
+ if (!isVoidReturningFunctionType(contextualType)) {
2331
+ return;
2332
+ }
2333
+ if (!couldReturnObservable(node.argument)) {
2334
+ return;
2335
+ }
2336
+ context.report({
2337
+ node: node.argument,
2338
+ messageId: "forbiddenVoidReturnReturnValue"
2339
+ });
2340
+ }
2341
+ function checkAssignment(node) {
2342
+ const varType = getTypeAtLocation(node.left);
2343
+ if (!isVoidReturningFunctionType(varType)) {
2344
+ return;
2345
+ }
2346
+ if (couldReturnObservable(node.right)) {
2347
+ context.report({
2348
+ messageId: "forbiddenVoidReturnVariable",
2349
+ node: node.right
2350
+ });
2351
+ }
2352
+ }
2353
+ function checkVariableDeclaration(node) {
2354
+ const tsNode = esTreeNodeToTSNodeMap.get(node);
2355
+ if (tsNode.initializer === void 0 || !node.init || !node.id.typeAnnotation) {
2356
+ return;
2357
+ }
2358
+ if (!isPossiblyFunctionType(node.id.typeAnnotation)) {
2359
+ return;
2360
+ }
2361
+ const varType = getTypeAtLocation(node.id);
2362
+ if (!isVoidReturningFunctionType(varType)) {
2363
+ return;
2364
+ }
2365
+ if (couldReturnObservable(node.init)) {
2366
+ context.report({
2367
+ messageId: "forbiddenVoidReturnVariable",
2368
+ node: node.init
2369
+ });
2370
+ }
2371
+ }
2372
+ return {
2373
+ ...checksVoidReturn ? voidReturnChecks : {},
2374
+ ...checksSpreads ? spreadChecks : {}
2375
+ };
2376
+ }
2377
+ });
2378
+ function voidFunctionArguments(checker, tsNode) {
2379
+ if (!tsNode.arguments) {
2380
+ return /* @__PURE__ */ new Set();
2381
+ }
2382
+ const voidReturnIndices = /* @__PURE__ */ new Set();
2383
+ const type = checker.getTypeAtLocation(tsNode.expression);
2384
+ for (const subType of tsutils2.unionTypeParts(type)) {
2385
+ const signatures = ts6.isCallExpression(tsNode) ? subType.getCallSignatures() : subType.getConstructSignatures();
2386
+ for (const signature of signatures) {
2387
+ for (const [index, parameter] of signature.parameters.entries()) {
2388
+ const type2 = checker.getTypeOfSymbolAtLocation(parameter, tsNode.expression);
2389
+ if (isVoidReturningFunctionType(type2)) {
2390
+ voidReturnIndices.add(index);
2391
+ }
2392
+ }
2393
+ }
2394
+ }
2395
+ return voidReturnIndices;
2396
+ }
2397
+ function isVoidReturningFunctionType(type) {
2398
+ let hasVoidReturn = false;
2399
+ for (const subType of tsutils2.unionTypeParts(type)) {
2400
+ for (const signature of subType.getCallSignatures()) {
2401
+ const returnType = signature.getReturnType();
2402
+ hasVoidReturn || (hasVoidReturn = tsutils2.isTypeFlagSet(returnType, ts6.TypeFlags.Void));
2403
+ }
2404
+ }
2405
+ return hasVoidReturn;
2406
+ }
2407
+ function getHeritageTypes(checker, tsNode) {
2408
+ var _a;
2409
+ return (_a = tsNode.heritageClauses) == null ? void 0 : _a.flatMap((clause) => clause.types).map((typeExpressions) => checker.getTypeAtLocation(typeExpressions));
2410
+ }
2411
+ function getMemberIfExists(type, memberName) {
2412
+ var _a, _b;
2413
+ const escapedMemberName = ts6.escapeLeadingUnderscores(memberName);
2414
+ const symbolMemberMatch = (_b = (_a = type.getSymbol()) == null ? void 0 : _a.members) == null ? void 0 : _b.get(escapedMemberName);
2415
+ return symbolMemberMatch != null ? symbolMemberMatch : tsutils2.getPropertyOfType(type, escapedMemberName);
2416
+ }
2417
+ function isStaticMember(node) {
2418
+ return (isMethodDefinition(node) || isPropertyDefinition(node)) && node.static;
2419
+ }
2420
+ function getPropertyContextualType(checker, tsNode) {
2421
+ if (ts6.isPropertyAssignment(tsNode)) {
2422
+ return checker.getContextualType(tsNode.initializer);
2423
+ } else if (ts6.isShorthandPropertyAssignment(tsNode)) {
2424
+ return checker.getContextualType(tsNode.name);
2425
+ } else if (ts6.isMethodDeclaration(tsNode)) {
2426
+ if (ts6.isComputedPropertyName(tsNode.name)) {
2427
+ return;
2428
+ }
2429
+ const obj = tsNode.parent;
2430
+ if (!ts6.isObjectLiteralExpression(obj)) {
2431
+ return;
2432
+ }
2433
+ const objType = checker.getContextualType(obj);
2434
+ if (objType === void 0) {
2435
+ return;
2436
+ }
2437
+ const propertySymbol = checker.getPropertyOfType(objType, tsNode.name.text);
2438
+ if (propertySymbol === void 0) {
2439
+ return;
2440
+ }
2441
+ return checker.getTypeOfSymbolAtLocation(propertySymbol, tsNode.name);
2442
+ } else {
2443
+ return void 0;
2444
+ }
2445
+ }
2446
+ function isPossiblyFunctionType(node) {
2447
+ switch (node.typeAnnotation.type) {
2448
+ case AST_NODE_TYPES6.TSConditionalType:
2449
+ case AST_NODE_TYPES6.TSConstructorType:
2450
+ case AST_NODE_TYPES6.TSFunctionType:
2451
+ case AST_NODE_TYPES6.TSImportType:
2452
+ case AST_NODE_TYPES6.TSIndexedAccessType:
2453
+ case AST_NODE_TYPES6.TSInferType:
2454
+ case AST_NODE_TYPES6.TSIntersectionType:
2455
+ case AST_NODE_TYPES6.TSQualifiedName:
2456
+ case AST_NODE_TYPES6.TSThisType:
2457
+ case AST_NODE_TYPES6.TSTypeOperator:
2458
+ case AST_NODE_TYPES6.TSTypeQuery:
2459
+ case AST_NODE_TYPES6.TSTypeReference:
2460
+ case AST_NODE_TYPES6.TSUnionType:
2461
+ return true;
2462
+ case AST_NODE_TYPES6.TSTypeLiteral:
2463
+ return node.typeAnnotation.members.some(
2464
+ (member) => member.type === AST_NODE_TYPES6.TSCallSignatureDeclaration || member.type === AST_NODE_TYPES6.TSConstructSignatureDeclaration
2465
+ );
2466
+ case AST_NODE_TYPES6.TSAbstractKeyword:
2467
+ case AST_NODE_TYPES6.TSAnyKeyword:
2468
+ case AST_NODE_TYPES6.TSArrayType:
2469
+ case AST_NODE_TYPES6.TSAsyncKeyword:
2470
+ case AST_NODE_TYPES6.TSBigIntKeyword:
2471
+ case AST_NODE_TYPES6.TSBooleanKeyword:
2472
+ case AST_NODE_TYPES6.TSDeclareKeyword:
2473
+ case AST_NODE_TYPES6.TSExportKeyword:
2474
+ case AST_NODE_TYPES6.TSIntrinsicKeyword:
2475
+ case AST_NODE_TYPES6.TSLiteralType:
2476
+ case AST_NODE_TYPES6.TSMappedType:
2477
+ case AST_NODE_TYPES6.TSNamedTupleMember:
2478
+ case AST_NODE_TYPES6.TSNeverKeyword:
2479
+ case AST_NODE_TYPES6.TSNullKeyword:
2480
+ case AST_NODE_TYPES6.TSNumberKeyword:
2481
+ case AST_NODE_TYPES6.TSObjectKeyword:
2482
+ case AST_NODE_TYPES6.TSOptionalType:
2483
+ case AST_NODE_TYPES6.TSPrivateKeyword:
2484
+ case AST_NODE_TYPES6.TSProtectedKeyword:
2485
+ case AST_NODE_TYPES6.TSPublicKeyword:
2486
+ case AST_NODE_TYPES6.TSReadonlyKeyword:
2487
+ case AST_NODE_TYPES6.TSRestType:
2488
+ case AST_NODE_TYPES6.TSStaticKeyword:
2489
+ case AST_NODE_TYPES6.TSStringKeyword:
2490
+ case AST_NODE_TYPES6.TSSymbolKeyword:
2491
+ case AST_NODE_TYPES6.TSTemplateLiteralType:
2492
+ case AST_NODE_TYPES6.TSTupleType:
2493
+ case AST_NODE_TYPES6.TSTypePredicate:
2494
+ case AST_NODE_TYPES6.TSUndefinedKeyword:
2495
+ case AST_NODE_TYPES6.TSUnknownKeyword:
2496
+ case AST_NODE_TYPES6.TSVoidKeyword:
2497
+ return false;
2498
+ }
2499
+ }
2500
+
2089
2501
  // src/rules/no-nested-subscribe.ts
2090
2502
  var noNestedSubscribeRule = ruleCreator({
2091
2503
  defaultOptions: [],
@@ -2208,10 +2620,10 @@ function isExpressionObserver(expressionStatement, couldBeType2) {
2208
2620
  }
2209
2621
 
2210
2622
  // src/rules/no-sharereplay.ts
2211
- import { AST_NODE_TYPES as AST_NODE_TYPES6 } from "@typescript-eslint/utils";
2212
- var defaultOptions8 = [];
2623
+ import { AST_NODE_TYPES as AST_NODE_TYPES7 } from "@typescript-eslint/utils";
2624
+ var defaultOptions9 = [];
2213
2625
  var noSharereplayRule = ruleCreator({
2214
- defaultOptions: defaultOptions8,
2626
+ defaultOptions: defaultOptions9,
2215
2627
  meta: {
2216
2628
  docs: {
2217
2629
  description: "Disallow unsafe `shareReplay` usage.",
@@ -2239,7 +2651,7 @@ var noSharereplayRule = ruleCreator({
2239
2651
  "CallExpression[callee.name='shareReplay']": (node) => {
2240
2652
  let report = true;
2241
2653
  if (allowConfig) {
2242
- report = node.arguments.length !== 1 || node.arguments[0].type !== AST_NODE_TYPES6.ObjectExpression;
2654
+ report = node.arguments.length !== 1 || node.arguments[0].type !== AST_NODE_TYPES7.ObjectExpression;
2243
2655
  }
2244
2656
  if (report) {
2245
2657
  context.report({
@@ -2404,6 +2816,53 @@ var noSubscribeHandlersRule = ruleCreator({
2404
2816
  }
2405
2817
  });
2406
2818
 
2819
+ // src/rules/no-subscribe-in-pipe.ts
2820
+ import { AST_NODE_TYPES as AST_NODE_TYPES8 } from "@typescript-eslint/utils";
2821
+ var noSubscribeInPipeRule = ruleCreator({
2822
+ defaultOptions: [],
2823
+ meta: {
2824
+ docs: {
2825
+ description: "Disallow calling of `subscribe` within any RxJS operator inside a `pipe`.",
2826
+ recommended: "recommended",
2827
+ requiresTypeChecking: true
2828
+ },
2829
+ fixable: void 0,
2830
+ hasSuggestions: false,
2831
+ messages: {
2832
+ forbidden: "Subscribe calls within pipe operators are forbidden."
2833
+ },
2834
+ schema: [],
2835
+ type: "problem"
2836
+ },
2837
+ name: "no-subscribe-in-pipe",
2838
+ create: (context) => {
2839
+ const { couldBeObservable, couldBeType: couldBeType2 } = getTypeServices(context);
2840
+ function isWithinPipe(node) {
2841
+ let parent = node.parent;
2842
+ while (parent) {
2843
+ if (parent.type === AST_NODE_TYPES8.CallExpression && parent.callee.type === AST_NODE_TYPES8.MemberExpression && parent.callee.property.type === AST_NODE_TYPES8.Identifier && parent.callee.property.name === "pipe") {
2844
+ return true;
2845
+ }
2846
+ parent = parent.parent;
2847
+ }
2848
+ return false;
2849
+ }
2850
+ return {
2851
+ "CallExpression > MemberExpression[property.name='subscribe']": (node) => {
2852
+ if (!couldBeObservable(node.object) && !couldBeType2(node.object, "Subscribable")) {
2853
+ return;
2854
+ }
2855
+ if (isWithinPipe(node)) {
2856
+ context.report({
2857
+ messageId: "forbidden",
2858
+ node: node.property
2859
+ });
2860
+ }
2861
+ }
2862
+ };
2863
+ }
2864
+ });
2865
+
2407
2866
  // src/rules/no-tap.ts
2408
2867
  var noTapRule = ruleCreator({
2409
2868
  defaultOptions: [],
@@ -2534,7 +2993,7 @@ import { ${functionName} } from ${quote}rxjs${quote};`
2534
2993
  });
2535
2994
 
2536
2995
  // src/rules/no-unbound-methods.ts
2537
- import { ESLintUtils as ESLintUtils8 } from "@typescript-eslint/utils";
2996
+ import { ESLintUtils as ESLintUtils9 } from "@typescript-eslint/utils";
2538
2997
  var noUnboundMethodsRule = ruleCreator({
2539
2998
  defaultOptions: [],
2540
2999
  meta: {
@@ -2551,7 +3010,7 @@ var noUnboundMethodsRule = ruleCreator({
2551
3010
  },
2552
3011
  name: "no-unbound-methods",
2553
3012
  create: (context) => {
2554
- const { getTypeAtLocation } = ESLintUtils8.getParserServices(context);
3013
+ const { getTypeAtLocation } = ESLintUtils9.getParserServices(context);
2555
3014
  const { couldBeObservable, couldBeSubscription } = getTypeServices(context);
2556
3015
  const nodeMap = /* @__PURE__ */ new WeakMap();
2557
3016
  function mapArguments(node) {
@@ -2599,9 +3058,9 @@ var noUnboundMethodsRule = ruleCreator({
2599
3058
 
2600
3059
  // src/rules/no-unsafe-catch.ts
2601
3060
  import { stripIndent as stripIndent4 } from "common-tags";
2602
- var defaultOptions9 = [];
3061
+ var defaultOptions10 = [];
2603
3062
  var noUnsafeCatchRule = ruleCreator({
2604
- defaultOptions: defaultOptions9,
3063
+ defaultOptions: defaultOptions10,
2605
3064
  meta: {
2606
3065
  docs: {
2607
3066
  description: "Disallow unsafe `catchError` usage in effects and epics.",
@@ -2660,9 +3119,9 @@ var noUnsafeCatchRule = ruleCreator({
2660
3119
 
2661
3120
  // src/rules/no-unsafe-first.ts
2662
3121
  import { stripIndent as stripIndent5 } from "common-tags";
2663
- var defaultOptions10 = [];
3122
+ var defaultOptions11 = [];
2664
3123
  var noUnsafeFirstRule = ruleCreator({
2665
- defaultOptions: defaultOptions10,
3124
+ defaultOptions: defaultOptions11,
2666
3125
  meta: {
2667
3126
  docs: {
2668
3127
  description: "Disallow unsafe `first`/`take` usage in effects and epics.",
@@ -2729,9 +3188,9 @@ var noUnsafeFirstRule = ruleCreator({
2729
3188
  });
2730
3189
 
2731
3190
  // src/rules/no-unsafe-subject-next.ts
2732
- import { ESLintUtils as ESLintUtils9 } from "@typescript-eslint/utils";
2733
- import * as tsutils2 from "ts-api-utils";
2734
- import ts6 from "typescript";
3191
+ import { ESLintUtils as ESLintUtils10 } from "@typescript-eslint/utils";
3192
+ import * as tsutils3 from "ts-api-utils";
3193
+ import ts7 from "typescript";
2735
3194
  var noUnsafeSubjectNext = ruleCreator({
2736
3195
  defaultOptions: [],
2737
3196
  meta: {
@@ -2748,25 +3207,25 @@ var noUnsafeSubjectNext = ruleCreator({
2748
3207
  },
2749
3208
  name: "no-unsafe-subject-next",
2750
3209
  create: (context) => {
2751
- const { getTypeAtLocation, program } = ESLintUtils9.getParserServices(context);
3210
+ const { getTypeAtLocation, program } = ESLintUtils10.getParserServices(context);
2752
3211
  const typeChecker = program.getTypeChecker();
2753
3212
  return {
2754
3213
  [`CallExpression[callee.property.name='next']`]: (node) => {
2755
3214
  if (node.arguments.length === 0 && isMemberExpression(node.callee)) {
2756
3215
  const type = getTypeAtLocation(node.callee.object);
2757
- if (tsutils2.isTypeReference(type) && couldBeType(type, "Subject")) {
3216
+ if (tsutils3.isTypeReference(type) && couldBeType(type, "Subject")) {
2758
3217
  const [typeArg] = typeChecker.getTypeArguments(type);
2759
- if (tsutils2.isTypeFlagSet(typeArg, ts6.TypeFlags.Any)) {
3218
+ if (tsutils3.isTypeFlagSet(typeArg, ts7.TypeFlags.Any)) {
2760
3219
  return;
2761
3220
  }
2762
- if (tsutils2.isTypeFlagSet(typeArg, ts6.TypeFlags.Unknown)) {
3221
+ if (tsutils3.isTypeFlagSet(typeArg, ts7.TypeFlags.Unknown)) {
2763
3222
  return;
2764
3223
  }
2765
- if (tsutils2.isTypeFlagSet(typeArg, ts6.TypeFlags.Void)) {
3224
+ if (tsutils3.isTypeFlagSet(typeArg, ts7.TypeFlags.Void)) {
2766
3225
  return;
2767
3226
  }
2768
- if (tsutils2.isUnionType(typeArg) && typeArg.types.some(
2769
- (t) => tsutils2.isTypeFlagSet(t, ts6.TypeFlags.Void)
3227
+ if (tsutils3.isUnionType(typeArg) && typeArg.types.some(
3228
+ (t) => tsutils3.isTypeFlagSet(t, ts7.TypeFlags.Void)
2770
3229
  )) {
2771
3230
  return;
2772
3231
  }
@@ -2784,9 +3243,9 @@ var noUnsafeSubjectNext = ruleCreator({
2784
3243
  // src/rules/no-unsafe-switchmap.ts
2785
3244
  import { stripIndent as stripIndent6 } from "common-tags";
2786
3245
  import decamelize from "decamelize";
2787
- var defaultOptions11 = [];
3246
+ var defaultOptions12 = [];
2788
3247
  var noUnsafeSwitchmapRule = ruleCreator({
2789
- defaultOptions: defaultOptions11,
3248
+ defaultOptions: defaultOptions12,
2790
3249
  meta: {
2791
3250
  docs: {
2792
3251
  description: "Disallow unsafe `switchMap` usage in effects and epics.",
@@ -2909,7 +3368,7 @@ var noUnsafeSwitchmapRule = ruleCreator({
2909
3368
 
2910
3369
  // src/rules/no-unsafe-takeuntil.ts
2911
3370
  import { stripIndent as stripIndent7 } from "common-tags";
2912
- var defaultOptions12 = [];
3371
+ var defaultOptions13 = [];
2913
3372
  var allowedOperators = [
2914
3373
  "count",
2915
3374
  "defaultIfEmpty",
@@ -2934,7 +3393,7 @@ var allowedOperators = [
2934
3393
  "toArray"
2935
3394
  ];
2936
3395
  var noUnsafeTakeuntilRule = ruleCreator({
2937
- defaultOptions: defaultOptions12,
3396
+ defaultOptions: defaultOptions13,
2938
3397
  meta: {
2939
3398
  docs: {
2940
3399
  description: "Disallow applying operators after `takeUntil`.",
@@ -3013,9 +3472,9 @@ var noUnsafeTakeuntilRule = ruleCreator({
3013
3472
  });
3014
3473
 
3015
3474
  // src/rules/prefer-observer.ts
3016
- var defaultOptions13 = [];
3475
+ var defaultOptions14 = [];
3017
3476
  var preferObserverRule = ruleCreator({
3018
- defaultOptions: defaultOptions13,
3477
+ defaultOptions: defaultOptions14,
3019
3478
  meta: {
3020
3479
  docs: {
3021
3480
  description: "Disallow passing separate handlers to `subscribe` and `tap`.",
@@ -3250,10 +3709,10 @@ var preferRootOperatorsRule = ruleCreator({
3250
3709
  });
3251
3710
 
3252
3711
  // src/rules/suffix-subjects.ts
3253
- import { AST_NODE_TYPES as AST_NODE_TYPES7, ESLintUtils as ESLintUtils10 } from "@typescript-eslint/utils";
3254
- var defaultOptions14 = [];
3712
+ import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as ESLintUtils11 } from "@typescript-eslint/utils";
3713
+ var defaultOptions15 = [];
3255
3714
  var suffixSubjectsRule = ruleCreator({
3256
- defaultOptions: defaultOptions14,
3715
+ defaultOptions: defaultOptions15,
3257
3716
  meta: {
3258
3717
  docs: {
3259
3718
  description: "Enforce the use of a suffix in subject identifiers.",
@@ -3278,7 +3737,7 @@ var suffixSubjectsRule = ruleCreator({
3278
3737
  },
3279
3738
  name: "suffix-subjects",
3280
3739
  create: (context) => {
3281
- const { esTreeNodeToTSNodeMap } = ESLintUtils10.getParserServices(context);
3740
+ const { esTreeNodeToTSNodeMap } = ESLintUtils11.getParserServices(context);
3282
3741
  const { couldBeType: couldBeType2 } = getTypeServices(context);
3283
3742
  const [config = {}] = context.options;
3284
3743
  const validate = {
@@ -3334,7 +3793,7 @@ var suffixSubjectsRule = ruleCreator({
3334
3793
  if (!found) {
3335
3794
  return;
3336
3795
  }
3337
- if (!validate.variables && found.type === AST_NODE_TYPES7.VariableDeclarator) {
3796
+ if (!validate.variables && found.type === AST_NODE_TYPES9.VariableDeclarator) {
3338
3797
  return;
3339
3798
  }
3340
3799
  if (!validate.parameters) {
@@ -3401,7 +3860,7 @@ var suffixSubjectsRule = ruleCreator({
3401
3860
  if (!found) {
3402
3861
  return;
3403
3862
  }
3404
- if (!validate.variables && found.type === AST_NODE_TYPES7.VariableDeclarator) {
3863
+ if (!validate.variables && found.type === AST_NODE_TYPES9.VariableDeclarator) {
3405
3864
  return;
3406
3865
  }
3407
3866
  if (!validate.parameters) {
@@ -3448,11 +3907,11 @@ var suffixSubjectsRule = ruleCreator({
3448
3907
  });
3449
3908
 
3450
3909
  // src/rules/throw-error.ts
3451
- import { ESLintUtils as ESLintUtils11 } from "@typescript-eslint/utils";
3452
- import * as tsutils3 from "ts-api-utils";
3453
- var defaultOptions15 = [];
3910
+ import { ESLintUtils as ESLintUtils12 } from "@typescript-eslint/utils";
3911
+ import * as tsutils4 from "ts-api-utils";
3912
+ var defaultOptions16 = [];
3454
3913
  var throwErrorRule = ruleCreator({
3455
- defaultOptions: defaultOptions15,
3914
+ defaultOptions: defaultOptions16,
3456
3915
  meta: {
3457
3916
  docs: {
3458
3917
  description: "Enforce passing only `Error` values to `throwError`.",
@@ -3478,7 +3937,7 @@ var throwErrorRule = ruleCreator({
3478
3937
  },
3479
3938
  name: "throw-error",
3480
3939
  create: (context) => {
3481
- const { esTreeNodeToTSNodeMap, program, getTypeAtLocation } = ESLintUtils11.getParserServices(context);
3940
+ const { esTreeNodeToTSNodeMap, program, getTypeAtLocation } = ESLintUtils12.getParserServices(context);
3482
3941
  const { couldBeObservable } = getTypeServices(context);
3483
3942
  const [config = {}] = context.options;
3484
3943
  const { allowThrowingAny = true, allowThrowingUnknown = true } = config;
@@ -3493,10 +3952,10 @@ var throwErrorRule = ruleCreator({
3493
3952
  const body = tsNode.body;
3494
3953
  type = program.getTypeChecker().getTypeAtLocation(annotation != null ? annotation : body);
3495
3954
  }
3496
- if (allowThrowingAny && tsutils3.isIntrinsicAnyType(type)) {
3955
+ if (allowThrowingAny && tsutils4.isIntrinsicAnyType(type)) {
3497
3956
  return;
3498
3957
  }
3499
- if (allowThrowingUnknown && tsutils3.isIntrinsicUnknownType(type)) {
3958
+ if (allowThrowingUnknown && tsutils4.isIntrinsicUnknownType(type)) {
3500
3959
  return;
3501
3960
  }
3502
3961
  if (couldBeType(type, /^Error$/)) {
@@ -3554,6 +4013,7 @@ var plugin = {
3554
4013
  "no-implicit-any-catch": noImplicitAnyCatchRule,
3555
4014
  "no-index": noIndexRule,
3556
4015
  "no-internal": noInternalRule,
4016
+ "no-misused-observables": noMisusedObservablesRule,
3557
4017
  "no-nested-subscribe": noNestedSubscribeRule,
3558
4018
  "no-redundant-notify": noRedundantNotifyRule,
3559
4019
  "no-sharereplay": noSharereplayRule,
@@ -3561,6 +4021,7 @@ var plugin = {
3561
4021
  "no-subject-unsubscribe": noSubjectUnsubscribeRule,
3562
4022
  "no-subject-value": noSubjectValueRule,
3563
4023
  "no-subscribe-handlers": noSubscribeHandlersRule,
4024
+ "no-subscribe-in-pipe": noSubscribeInPipeRule,
3564
4025
  "no-tap": noTapRule,
3565
4026
  "no-topromise": noTopromiseRule,
3566
4027
  "no-unbound-methods": noUnboundMethodsRule,