eslint-plugin-rxjs-x 0.2.1 → 0.2.3

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.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.1";
3
+ var version = "0.2.3";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -187,7 +187,7 @@ var banOperatorsRule = ruleCreator({
187
187
 
188
188
 
189
189
  // src/etc/could-be-function.ts
190
- var _typescript = require('typescript'); var ts2 = _interopRequireWildcard(_typescript); var ts = _interopRequireWildcard(_typescript); var ts3 = _interopRequireWildcard(_typescript); var ts4 = _interopRequireWildcard(_typescript); var ts5 = _interopRequireWildcard(_typescript); var ts6 = _interopRequireWildcard(_typescript);
190
+ var _typescript = require('typescript'); var _typescript2 = _interopRequireDefault(_typescript);
191
191
 
192
192
  // src/etc/could-be-type.ts
193
193
  var _tsapiutils = require('ts-api-utils'); var tsutils = _interopRequireWildcard(_tsapiutils); var tsutils2 = _interopRequireWildcard(_tsapiutils); var tsutils3 = _interopRequireWildcard(_tsapiutils); var tsutils4 = _interopRequireWildcard(_tsapiutils);
@@ -226,11 +226,11 @@ function couldImplement(type, name2, qualified) {
226
226
  const { symbol } = type;
227
227
  if (symbol) {
228
228
  const { valueDeclaration } = symbol;
229
- if (valueDeclaration && ts.isClassDeclaration(valueDeclaration)) {
229
+ if (valueDeclaration && _typescript2.default.isClassDeclaration(valueDeclaration)) {
230
230
  const { heritageClauses } = valueDeclaration;
231
231
  if (heritageClauses) {
232
232
  const implemented = heritageClauses.some(
233
- ({ token, types }) => token === ts.SyntaxKind.ImplementsKeyword && types.some((node) => isMatchingNode(node, name2, qualified))
233
+ ({ token, types }) => token === _typescript2.default.SyntaxKind.ImplementsKeyword && types.some((node) => isMatchingNode(node, name2, qualified))
234
234
  );
235
235
  if (implemented) {
236
236
  return true;
@@ -259,7 +259,7 @@ function isMatchingNode(node, name2, qualified) {
259
259
 
260
260
  // src/etc/could-be-function.ts
261
261
  function couldBeFunction(type) {
262
- return type.getCallSignatures().length > 0 || couldBeType(type, "Function") || couldBeType(type, "ArrowFunction") || couldBeType(type, ts2.InternalSymbolName.Function);
262
+ return type.getCallSignatures().length > 0 || couldBeType(type, "Function") || couldBeType(type, "ArrowFunction") || couldBeType(type, _typescript2.default.InternalSymbolName.Function);
263
263
  }
264
264
 
265
265
  // src/etc/find-parent.ts
@@ -285,8 +285,8 @@ function findParent(node, ...args) {
285
285
 
286
286
  function getLoc(node) {
287
287
  const sourceFile = node.getSourceFile();
288
- const start = ts3.getLineAndCharacterOfPosition(sourceFile, node.getStart());
289
- const end = ts3.getLineAndCharacterOfPosition(sourceFile, node.getEnd());
288
+ const start = _typescript2.default.getLineAndCharacterOfPosition(sourceFile, node.getStart());
289
+ const end = _typescript2.default.getLineAndCharacterOfPosition(sourceFile, node.getEnd());
290
290
  return {
291
291
  start: {
292
292
  line: start.line + 1,
@@ -369,9 +369,9 @@ function getTypeServices(context) {
369
369
  var _a;
370
370
  let tsTypeNode;
371
371
  const tsNode = esTreeNodeToTSNodeMap.get(node);
372
- if (ts4.isArrowFunction(tsNode) || ts4.isFunctionDeclaration(tsNode) || ts4.isMethodDeclaration(tsNode) || ts4.isFunctionExpression(tsNode)) {
372
+ if (_typescript2.default.isArrowFunction(tsNode) || _typescript2.default.isFunctionDeclaration(tsNode) || _typescript2.default.isMethodDeclaration(tsNode) || _typescript2.default.isFunctionExpression(tsNode)) {
373
373
  tsTypeNode = (_a = tsNode.type) != null ? _a : tsNode.body;
374
- } else if (ts4.isCallSignatureDeclaration(tsNode) || ts4.isMethodSignature(tsNode)) {
374
+ } else if (_typescript2.default.isCallSignatureDeclaration(tsNode) || _typescript2.default.isMethodSignature(tsNode)) {
375
375
  tsTypeNode = tsNode.type;
376
376
  }
377
377
  return Boolean(
@@ -969,7 +969,7 @@ var noCyclicActionRule = ruleCreator({
969
969
  const operatorType = getType(operatorCallExpression);
970
970
  const [signature] = typeChecker.getSignaturesOfType(
971
971
  operatorType,
972
- ts5.SignatureKind.Call
972
+ _typescript2.default.SignatureKind.Call
973
973
  );
974
974
  if (!signature) {
975
975
  return;
@@ -1412,6 +1412,7 @@ var noIgnoredObservableRule = ruleCreator({
1412
1412
  });
1413
1413
 
1414
1414
  // src/rules/no-ignored-replay-buffer.ts
1415
+
1415
1416
  var noIgnoredReplayBufferRule = ruleCreator({
1416
1417
  defaultOptions: [],
1417
1418
  meta: {
@@ -1427,6 +1428,14 @@ var noIgnoredReplayBufferRule = ruleCreator({
1427
1428
  },
1428
1429
  name: "no-ignored-replay-buffer",
1429
1430
  create: (context) => {
1431
+ function checkShareReplayConfig(node, shareReplayConfigArg) {
1432
+ if (!shareReplayConfigArg.properties.some((p) => p.type === _utils.AST_NODE_TYPES.Property && p.key.type === _utils.AST_NODE_TYPES.Identifier && p.key.name === "bufferSize")) {
1433
+ context.report({
1434
+ messageId: "forbidden",
1435
+ node
1436
+ });
1437
+ }
1438
+ }
1430
1439
  function checkNode(node, { arguments: args }) {
1431
1440
  if (!args || args.length === 0) {
1432
1441
  context.report({
@@ -1434,6 +1443,12 @@ var noIgnoredReplayBufferRule = ruleCreator({
1434
1443
  node
1435
1444
  });
1436
1445
  }
1446
+ if (node.name === "shareReplay" && (args == null ? void 0 : args.length) === 1) {
1447
+ const arg = args[0];
1448
+ if (arg.type === _utils.AST_NODE_TYPES.ObjectExpression) {
1449
+ checkShareReplayConfig(node, arg);
1450
+ }
1451
+ }
1437
1452
  }
1438
1453
  return {
1439
1454
  "NewExpression > Identifier[name='ReplaySubject']": (node) => {
@@ -1448,6 +1463,11 @@ var noIgnoredReplayBufferRule = ruleCreator({
1448
1463
  "CallExpression > Identifier[name=/^(publishReplay|shareReplay)$/]": (node) => {
1449
1464
  const callExpression = node.parent;
1450
1465
  checkNode(node, callExpression);
1466
+ },
1467
+ "CallExpression > MemberExpression > Identifier[name=/^(publishReplay|shareReplay)$/]": (node) => {
1468
+ const memberExpression = node.parent;
1469
+ const callExpression = memberExpression.parent;
1470
+ checkNode(node, callExpression);
1451
1471
  }
1452
1472
  };
1453
1473
  }
@@ -2424,17 +2444,17 @@ var noUnsafeSubjectNext = ruleCreator({
2424
2444
  const type = getType(node.callee.object);
2425
2445
  if (tsutils3.isTypeReference(type) && couldBeType(type, "Subject")) {
2426
2446
  const [typeArg] = typeChecker.getTypeArguments(type);
2427
- if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Any)) {
2447
+ if (tsutils3.isTypeFlagSet(typeArg, _typescript2.default.TypeFlags.Any)) {
2428
2448
  return;
2429
2449
  }
2430
- if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Unknown)) {
2450
+ if (tsutils3.isTypeFlagSet(typeArg, _typescript2.default.TypeFlags.Unknown)) {
2431
2451
  return;
2432
2452
  }
2433
- if (tsutils3.isTypeFlagSet(typeArg, ts6.TypeFlags.Void)) {
2453
+ if (tsutils3.isTypeFlagSet(typeArg, _typescript2.default.TypeFlags.Void)) {
2434
2454
  return;
2435
2455
  }
2436
2456
  if (tsutils3.isUnionType(typeArg) && typeArg.types.some(
2437
- (t) => tsutils3.isTypeFlagSet(t, ts6.TypeFlags.Void)
2457
+ (t) => tsutils3.isTypeFlagSet(t, _typescript2.default.TypeFlags.Void)
2438
2458
  )) {
2439
2459
  return;
2440
2460
  }
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.1";
3
+ var version = "0.2.3";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -187,11 +187,11 @@ var banOperatorsRule = ruleCreator({
187
187
  import { AST_NODE_TYPES as AST_NODE_TYPES5, ESLintUtils as ESLintUtils3 } from "@typescript-eslint/utils";
188
188
 
189
189
  // src/etc/could-be-function.ts
190
- import * as ts2 from "typescript";
190
+ import ts2 from "typescript";
191
191
 
192
192
  // src/etc/could-be-type.ts
193
193
  import * as tsutils from "ts-api-utils";
194
- import * as ts from "typescript";
194
+ import ts from "typescript";
195
195
  function couldBeType(type, name2, qualified) {
196
196
  if (tsutils.isTypeReference(type)) {
197
197
  type = type.target;
@@ -282,7 +282,7 @@ function findParent(node, ...args) {
282
282
  }
283
283
 
284
284
  // src/etc/get-loc.ts
285
- import * as ts3 from "typescript";
285
+ import ts3 from "typescript";
286
286
  function getLoc(node) {
287
287
  const sourceFile = node.getSourceFile();
288
288
  const start = ts3.getLineAndCharacterOfPosition(sourceFile, node.getStart());
@@ -302,7 +302,7 @@ function getLoc(node) {
302
302
  // src/etc/get-type-services.ts
303
303
  import { ESLintUtils as ESLintUtils2 } from "@typescript-eslint/utils";
304
304
  import * as tsutils2 from "ts-api-utils";
305
- import * as ts4 from "typescript";
305
+ import ts4 from "typescript";
306
306
 
307
307
  // src/etc/is.ts
308
308
  import { AST_NODE_TYPES as AST_NODE_TYPES3 } from "@typescript-eslint/utils";
@@ -920,7 +920,7 @@ var noCreateRule = ruleCreator({
920
920
 
921
921
  // src/rules/no-cyclic-action.ts
922
922
  import { stripIndent as stripIndent3 } from "common-tags";
923
- import * as ts5 from "typescript";
923
+ import ts5 from "typescript";
924
924
 
925
925
  // src/constants.ts
926
926
  var defaultObservable = String.raw`[Aa]ction(s|s\$|\$)$`;
@@ -1412,6 +1412,7 @@ var noIgnoredObservableRule = ruleCreator({
1412
1412
  });
1413
1413
 
1414
1414
  // src/rules/no-ignored-replay-buffer.ts
1415
+ import { AST_NODE_TYPES as AST_NODE_TYPES6 } from "@typescript-eslint/utils";
1415
1416
  var noIgnoredReplayBufferRule = ruleCreator({
1416
1417
  defaultOptions: [],
1417
1418
  meta: {
@@ -1427,6 +1428,14 @@ var noIgnoredReplayBufferRule = ruleCreator({
1427
1428
  },
1428
1429
  name: "no-ignored-replay-buffer",
1429
1430
  create: (context) => {
1431
+ function checkShareReplayConfig(node, shareReplayConfigArg) {
1432
+ if (!shareReplayConfigArg.properties.some((p) => p.type === AST_NODE_TYPES6.Property && p.key.type === AST_NODE_TYPES6.Identifier && p.key.name === "bufferSize")) {
1433
+ context.report({
1434
+ messageId: "forbidden",
1435
+ node
1436
+ });
1437
+ }
1438
+ }
1430
1439
  function checkNode(node, { arguments: args }) {
1431
1440
  if (!args || args.length === 0) {
1432
1441
  context.report({
@@ -1434,6 +1443,12 @@ var noIgnoredReplayBufferRule = ruleCreator({
1434
1443
  node
1435
1444
  });
1436
1445
  }
1446
+ if (node.name === "shareReplay" && (args == null ? void 0 : args.length) === 1) {
1447
+ const arg = args[0];
1448
+ if (arg.type === AST_NODE_TYPES6.ObjectExpression) {
1449
+ checkShareReplayConfig(node, arg);
1450
+ }
1451
+ }
1437
1452
  }
1438
1453
  return {
1439
1454
  "NewExpression > Identifier[name='ReplaySubject']": (node) => {
@@ -1448,6 +1463,11 @@ var noIgnoredReplayBufferRule = ruleCreator({
1448
1463
  "CallExpression > Identifier[name=/^(publishReplay|shareReplay)$/]": (node) => {
1449
1464
  const callExpression = node.parent;
1450
1465
  checkNode(node, callExpression);
1466
+ },
1467
+ "CallExpression > MemberExpression > Identifier[name=/^(publishReplay|shareReplay)$/]": (node) => {
1468
+ const memberExpression = node.parent;
1469
+ const callExpression = memberExpression.parent;
1470
+ checkNode(node, callExpression);
1451
1471
  }
1452
1472
  };
1453
1473
  }
@@ -1575,7 +1595,7 @@ var noIgnoredTakewhileValueRule = ruleCreator({
1575
1595
 
1576
1596
  // src/rules/no-implicit-any-catch.ts
1577
1597
  import {
1578
- AST_NODE_TYPES as AST_NODE_TYPES6
1598
+ AST_NODE_TYPES as AST_NODE_TYPES7
1579
1599
  } from "@typescript-eslint/utils";
1580
1600
  function isParenthesised(sourceCode, node) {
1581
1601
  const before = sourceCode.getTokenBefore(node);
@@ -1631,7 +1651,7 @@ var noImplicitAnyCatchRule = ruleCreator({
1631
1651
  const {
1632
1652
  typeAnnotation: { type }
1633
1653
  } = typeAnnotation;
1634
- if (type === AST_NODE_TYPES6.TSAnyKeyword) {
1654
+ if (type === AST_NODE_TYPES7.TSAnyKeyword) {
1635
1655
  let fix2 = function(fixer) {
1636
1656
  return fixer.replaceText(typeAnnotation, ": unknown");
1637
1657
  };
@@ -1650,7 +1670,7 @@ var noImplicitAnyCatchRule = ruleCreator({
1650
1670
  }
1651
1671
  ]
1652
1672
  });
1653
- } else if (type !== AST_NODE_TYPES6.TSUnknownKeyword) {
1673
+ } else if (type !== AST_NODE_TYPES7.TSUnknownKeyword) {
1654
1674
  let fix2 = function(fixer) {
1655
1675
  return fixer.replaceText(typeAnnotation, ": unknown");
1656
1676
  };
@@ -1945,7 +1965,7 @@ function isExpressionObserver(expressionStatement, couldBeType2) {
1945
1965
  }
1946
1966
 
1947
1967
  // src/rules/no-sharereplay.ts
1948
- import { AST_NODE_TYPES as AST_NODE_TYPES7 } from "@typescript-eslint/utils";
1968
+ import { AST_NODE_TYPES as AST_NODE_TYPES8 } from "@typescript-eslint/utils";
1949
1969
  var defaultOptions7 = [];
1950
1970
  var noSharereplayRule = ruleCreator({
1951
1971
  defaultOptions: defaultOptions7,
@@ -1976,7 +1996,7 @@ var noSharereplayRule = ruleCreator({
1976
1996
  "CallExpression[callee.name='shareReplay']": (node) => {
1977
1997
  let report = true;
1978
1998
  if (allowConfig) {
1979
- report = node.arguments.length !== 1 || node.arguments[0].type !== AST_NODE_TYPES7.ObjectExpression;
1999
+ report = node.arguments.length !== 1 || node.arguments[0].type !== AST_NODE_TYPES8.ObjectExpression;
1980
2000
  }
1981
2001
  if (report) {
1982
2002
  context.report({
@@ -2400,7 +2420,7 @@ var noUnsafeFirstRule = ruleCreator({
2400
2420
 
2401
2421
  // src/rules/no-unsafe-subject-next.ts
2402
2422
  import * as tsutils3 from "ts-api-utils";
2403
- import * as ts6 from "typescript";
2423
+ import ts6 from "typescript";
2404
2424
  var noUnsafeSubjectNext = ruleCreator({
2405
2425
  defaultOptions: [],
2406
2426
  meta: {
@@ -2780,7 +2800,7 @@ function isValidArgText(argText) {
2780
2800
  }
2781
2801
 
2782
2802
  // src/rules/suffix-subjects.ts
2783
- import { AST_NODE_TYPES as AST_NODE_TYPES8, ESLintUtils as ESLintUtils5 } from "@typescript-eslint/utils";
2803
+ import { AST_NODE_TYPES as AST_NODE_TYPES9, ESLintUtils as ESLintUtils5 } from "@typescript-eslint/utils";
2784
2804
  var defaultOptions13 = [];
2785
2805
  var suffixSubjectsRule = ruleCreator({
2786
2806
  defaultOptions: defaultOptions13,
@@ -2864,7 +2884,7 @@ var suffixSubjectsRule = ruleCreator({
2864
2884
  if (!found) {
2865
2885
  return;
2866
2886
  }
2867
- if (!validate.variables && found.type === AST_NODE_TYPES8.VariableDeclarator) {
2887
+ if (!validate.variables && found.type === AST_NODE_TYPES9.VariableDeclarator) {
2868
2888
  return;
2869
2889
  }
2870
2890
  if (!validate.parameters) {
@@ -2931,7 +2951,7 @@ var suffixSubjectsRule = ruleCreator({
2931
2951
  if (!found) {
2932
2952
  return;
2933
2953
  }
2934
- if (!validate.variables && found.type === AST_NODE_TYPES8.VariableDeclarator) {
2954
+ if (!validate.variables && found.type === AST_NODE_TYPES9.VariableDeclarator) {
2935
2955
  return;
2936
2956
  }
2937
2957
  if (!validate.parameters) {
@@ -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
+ ```
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.1",
4
+ "version": "0.2.3",
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>",
@@ -63,13 +63,18 @@
63
63
  "peerDependencies": {
64
64
  "eslint": "^8.57.0 || ^9.0.0",
65
65
  "rxjs": ">=7.0.0",
66
- "typescript": ">=4.2.0"
66
+ "typescript": ">=4.7.4"
67
+ },
68
+ "peerDependenciesMeta": {
69
+ "rxjs": {
70
+ "optional": true
71
+ }
67
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": "^18.18.0",
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.0.0",
91
+ "rxjs": "^7.8.1",
87
92
  "tsup": "^8.3.5",
88
93
  "tsx": "^4.19.2",
89
94
  "typescript": "~5.6.3",