eslint-plugin-rxjs-x 0.7.5 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.js +44 -18
  2. package/dist/index.mjs +44 -18
  3. package/package.json +16 -16
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// package.json
2
2
  var name = "eslint-plugin-rxjs-x";
3
- var version = "0.7.5";
3
+ var version = "0.7.7";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -218,6 +218,9 @@ function getLoc(node) {
218
218
  function hasTypeAnnotation(node) {
219
219
  return "typeAnnotation" in node && !!node.typeAnnotation;
220
220
  }
221
+ function isAccessorProperty(node) {
222
+ return node.type === _utils.AST_NODE_TYPES.AccessorProperty;
223
+ }
221
224
  function isArrayExpression(node) {
222
225
  return node.type === _utils.AST_NODE_TYPES.ArrayExpression;
223
226
  }
@@ -2032,7 +2035,7 @@ var noImplicitAnyCatchRule = ruleCreator({
2032
2035
  const sourceCode = context.sourceCode;
2033
2036
  function checkCallback(callback) {
2034
2037
  if (isArrowFunctionExpression(callback) || isFunctionExpression(callback)) {
2035
- const [param] = callback.params;
2038
+ const [param, ...restParams] = callback.params;
2036
2039
  if (!param) {
2037
2040
  return;
2038
2041
  }
@@ -2078,7 +2081,7 @@ var noImplicitAnyCatchRule = ruleCreator({
2078
2081
  }
2079
2082
  } else {
2080
2083
  let fix2 = function(fixer) {
2081
- if (isParenthesised(sourceCode, param)) {
2084
+ if (isParenthesised(sourceCode, param) || restParams.length > 0) {
2082
2085
  return fixer.insertTextAfter(param, ": unknown");
2083
2086
  }
2084
2087
  return [
@@ -2235,6 +2238,7 @@ var noInternalRule = ruleCreator({
2235
2238
 
2236
2239
  // src/rules/no-misused-observables.ts
2237
2240
 
2241
+ var _astutils = require('@typescript-eslint/utils/ast-utils');
2238
2242
 
2239
2243
 
2240
2244
  function parseChecksVoidReturn(checksVoidReturn) {
@@ -2376,10 +2380,14 @@ var noMisusedObservablesRule = ruleCreator({
2376
2380
  }
2377
2381
  }
2378
2382
  function checkJSXAttribute(node) {
2379
- if (!node.value || !isJSXExpressionContainer(node.value)) {
2383
+ if (node.value == null || !isJSXExpressionContainer(node.value)) {
2380
2384
  return;
2381
2385
  }
2382
- if (couldReturnObservable(node.value.expression)) {
2386
+ const expressionContainer = esTreeNodeToTSNodeMap.get(
2387
+ node.value
2388
+ );
2389
+ const contextualType = checker.getContextualType(expressionContainer);
2390
+ if (contextualType != null && isVoidReturningFunctionType(contextualType) && couldReturnObservable(node.value.expression)) {
2383
2391
  context.report({
2384
2392
  messageId: "forbiddenVoidReturnAttribute",
2385
2393
  node: node.value
@@ -2396,7 +2404,7 @@ var noMisusedObservablesRule = ruleCreator({
2396
2404
  for (const element of node.body.body) {
2397
2405
  const tsElement = esTreeNodeToTSNodeMap.get(element);
2398
2406
  const memberName = (_a = tsElement == null ? void 0 : tsElement.name) == null ? void 0 : _a.getText();
2399
- if (memberName === void 0) {
2407
+ if (memberName == null) {
2400
2408
  continue;
2401
2409
  }
2402
2410
  if (!couldReturnObservable(element)) {
@@ -2407,7 +2415,7 @@ var noMisusedObservablesRule = ruleCreator({
2407
2415
  }
2408
2416
  for (const heritageType of heritageTypes) {
2409
2417
  const heritageMember = getMemberIfExists(heritageType, memberName);
2410
- if (heritageMember === void 0) {
2418
+ if (heritageMember == null) {
2411
2419
  continue;
2412
2420
  }
2413
2421
  const memberType = checker.getTypeOfSymbolAtLocation(heritageMember, tsElement);
@@ -2425,7 +2433,7 @@ var noMisusedObservablesRule = ruleCreator({
2425
2433
  function checkProperty(node) {
2426
2434
  const tsNode = esTreeNodeToTSNodeMap.get(node);
2427
2435
  const contextualType = getPropertyContextualType(checker, tsNode);
2428
- if (contextualType === void 0) {
2436
+ if (contextualType == null) {
2429
2437
  return;
2430
2438
  }
2431
2439
  if (!isVoidReturningFunctionType(contextualType)) {
@@ -2434,14 +2442,29 @@ var noMisusedObservablesRule = ruleCreator({
2434
2442
  if (!couldReturnObservable(node.value)) {
2435
2443
  return;
2436
2444
  }
2437
- context.report({
2438
- messageId: "forbiddenVoidReturnProperty",
2439
- node: node.value
2440
- });
2445
+ if (_astutils.isFunction.call(void 0, node.value)) {
2446
+ const functionNode = node.value;
2447
+ if (functionNode.returnType) {
2448
+ context.report({
2449
+ messageId: "forbiddenVoidReturnProperty",
2450
+ node: functionNode.returnType.typeAnnotation
2451
+ });
2452
+ } else {
2453
+ context.report({
2454
+ messageId: "forbiddenVoidReturnProperty",
2455
+ loc: _astutils.getFunctionHeadLocation.call(void 0, functionNode, context.sourceCode)
2456
+ });
2457
+ }
2458
+ } else {
2459
+ context.report({
2460
+ messageId: "forbiddenVoidReturnProperty",
2461
+ node: node.value
2462
+ });
2463
+ }
2441
2464
  }
2442
2465
  function checkReturnStatement(node) {
2443
2466
  const tsNode = esTreeNodeToTSNodeMap.get(node);
2444
- if (tsNode.expression === void 0 || !node.argument) {
2467
+ if (tsNode.expression == null || !node.argument) {
2445
2468
  return;
2446
2469
  }
2447
2470
  function getFunctionNode() {
@@ -2456,7 +2479,7 @@ var noMisusedObservablesRule = ruleCreator({
2456
2479
  return;
2457
2480
  }
2458
2481
  const contextualType = checker.getContextualType(tsNode.expression);
2459
- if (contextualType === void 0) {
2482
+ if (contextualType == null) {
2460
2483
  return;
2461
2484
  }
2462
2485
  if (!isVoidReturningFunctionType(contextualType)) {
@@ -2484,7 +2507,7 @@ var noMisusedObservablesRule = ruleCreator({
2484
2507
  }
2485
2508
  function checkVariableDeclaration(node) {
2486
2509
  const tsNode = esTreeNodeToTSNodeMap.get(node);
2487
- if (tsNode.initializer === void 0 || !node.init || !node.id.typeAnnotation) {
2510
+ if (tsNode.initializer == null || node.init == null || node.id.typeAnnotation == null) {
2488
2511
  return;
2489
2512
  }
2490
2513
  if (!isPossiblyFunctionType(node.id.typeAnnotation)) {
@@ -2531,6 +2554,9 @@ function isVoidReturningFunctionType(type) {
2531
2554
  for (const subType of tsutils2.unionTypeParts(type)) {
2532
2555
  for (const signature of subType.getCallSignatures()) {
2533
2556
  const returnType = signature.getReturnType();
2557
+ if (couldBeType(returnType, "Observable")) {
2558
+ return false;
2559
+ }
2534
2560
  hasVoidReturn || (hasVoidReturn = tsutils2.isTypeFlagSet(returnType, _typescript2.default.TypeFlags.Void));
2535
2561
  }
2536
2562
  }
@@ -2547,7 +2573,7 @@ function getMemberIfExists(type, memberName) {
2547
2573
  return symbolMemberMatch != null ? symbolMemberMatch : tsutils2.getPropertyOfType(type, escapedMemberName);
2548
2574
  }
2549
2575
  function isStaticMember(node) {
2550
- return (isMethodDefinition(node) || isPropertyDefinition(node)) && node.static;
2576
+ return (isMethodDefinition(node) || isPropertyDefinition(node) || isAccessorProperty(node)) && node.static;
2551
2577
  }
2552
2578
  function getPropertyContextualType(checker, tsNode) {
2553
2579
  if (_typescript2.default.isPropertyAssignment(tsNode)) {
@@ -2563,11 +2589,11 @@ function getPropertyContextualType(checker, tsNode) {
2563
2589
  return;
2564
2590
  }
2565
2591
  const objType = checker.getContextualType(obj);
2566
- if (objType === void 0) {
2592
+ if (objType == null) {
2567
2593
  return;
2568
2594
  }
2569
2595
  const propertySymbol = checker.getPropertyOfType(objType, tsNode.name.text);
2570
- if (propertySymbol === void 0) {
2596
+ if (propertySymbol == null) {
2571
2597
  return;
2572
2598
  }
2573
2599
  return checker.getTypeOfSymbolAtLocation(propertySymbol, tsNode.name);
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // package.json
2
2
  var name = "eslint-plugin-rxjs-x";
3
- var version = "0.7.5";
3
+ var version = "0.7.7";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -218,6 +218,9 @@ import { AST_NODE_TYPES } from "@typescript-eslint/utils";
218
218
  function hasTypeAnnotation(node) {
219
219
  return "typeAnnotation" in node && !!node.typeAnnotation;
220
220
  }
221
+ function isAccessorProperty(node) {
222
+ return node.type === AST_NODE_TYPES.AccessorProperty;
223
+ }
221
224
  function isArrayExpression(node) {
222
225
  return node.type === AST_NODE_TYPES.ArrayExpression;
223
226
  }
@@ -2032,7 +2035,7 @@ var noImplicitAnyCatchRule = ruleCreator({
2032
2035
  const sourceCode = context.sourceCode;
2033
2036
  function checkCallback(callback) {
2034
2037
  if (isArrowFunctionExpression(callback) || isFunctionExpression(callback)) {
2035
- const [param] = callback.params;
2038
+ const [param, ...restParams] = callback.params;
2036
2039
  if (!param) {
2037
2040
  return;
2038
2041
  }
@@ -2078,7 +2081,7 @@ var noImplicitAnyCatchRule = ruleCreator({
2078
2081
  }
2079
2082
  } else {
2080
2083
  let fix2 = function(fixer) {
2081
- if (isParenthesised(sourceCode, param)) {
2084
+ if (isParenthesised(sourceCode, param) || restParams.length > 0) {
2082
2085
  return fixer.insertTextAfter(param, ": unknown");
2083
2086
  }
2084
2087
  return [
@@ -2235,6 +2238,7 @@ var noInternalRule = ruleCreator({
2235
2238
 
2236
2239
  // src/rules/no-misused-observables.ts
2237
2240
  import { AST_NODE_TYPES as AST_NODE_TYPES6, ESLintUtils as ESLintUtils8 } from "@typescript-eslint/utils";
2241
+ import { getFunctionHeadLocation, isFunction } from "@typescript-eslint/utils/ast-utils";
2238
2242
  import * as tsutils2 from "ts-api-utils";
2239
2243
  import ts6 from "typescript";
2240
2244
  function parseChecksVoidReturn(checksVoidReturn) {
@@ -2376,10 +2380,14 @@ var noMisusedObservablesRule = ruleCreator({
2376
2380
  }
2377
2381
  }
2378
2382
  function checkJSXAttribute(node) {
2379
- if (!node.value || !isJSXExpressionContainer(node.value)) {
2383
+ if (node.value == null || !isJSXExpressionContainer(node.value)) {
2380
2384
  return;
2381
2385
  }
2382
- if (couldReturnObservable(node.value.expression)) {
2386
+ const expressionContainer = esTreeNodeToTSNodeMap.get(
2387
+ node.value
2388
+ );
2389
+ const contextualType = checker.getContextualType(expressionContainer);
2390
+ if (contextualType != null && isVoidReturningFunctionType(contextualType) && couldReturnObservable(node.value.expression)) {
2383
2391
  context.report({
2384
2392
  messageId: "forbiddenVoidReturnAttribute",
2385
2393
  node: node.value
@@ -2396,7 +2404,7 @@ var noMisusedObservablesRule = ruleCreator({
2396
2404
  for (const element of node.body.body) {
2397
2405
  const tsElement = esTreeNodeToTSNodeMap.get(element);
2398
2406
  const memberName = (_a = tsElement == null ? void 0 : tsElement.name) == null ? void 0 : _a.getText();
2399
- if (memberName === void 0) {
2407
+ if (memberName == null) {
2400
2408
  continue;
2401
2409
  }
2402
2410
  if (!couldReturnObservable(element)) {
@@ -2407,7 +2415,7 @@ var noMisusedObservablesRule = ruleCreator({
2407
2415
  }
2408
2416
  for (const heritageType of heritageTypes) {
2409
2417
  const heritageMember = getMemberIfExists(heritageType, memberName);
2410
- if (heritageMember === void 0) {
2418
+ if (heritageMember == null) {
2411
2419
  continue;
2412
2420
  }
2413
2421
  const memberType = checker.getTypeOfSymbolAtLocation(heritageMember, tsElement);
@@ -2425,7 +2433,7 @@ var noMisusedObservablesRule = ruleCreator({
2425
2433
  function checkProperty(node) {
2426
2434
  const tsNode = esTreeNodeToTSNodeMap.get(node);
2427
2435
  const contextualType = getPropertyContextualType(checker, tsNode);
2428
- if (contextualType === void 0) {
2436
+ if (contextualType == null) {
2429
2437
  return;
2430
2438
  }
2431
2439
  if (!isVoidReturningFunctionType(contextualType)) {
@@ -2434,14 +2442,29 @@ var noMisusedObservablesRule = ruleCreator({
2434
2442
  if (!couldReturnObservable(node.value)) {
2435
2443
  return;
2436
2444
  }
2437
- context.report({
2438
- messageId: "forbiddenVoidReturnProperty",
2439
- node: node.value
2440
- });
2445
+ if (isFunction(node.value)) {
2446
+ const functionNode = node.value;
2447
+ if (functionNode.returnType) {
2448
+ context.report({
2449
+ messageId: "forbiddenVoidReturnProperty",
2450
+ node: functionNode.returnType.typeAnnotation
2451
+ });
2452
+ } else {
2453
+ context.report({
2454
+ messageId: "forbiddenVoidReturnProperty",
2455
+ loc: getFunctionHeadLocation(functionNode, context.sourceCode)
2456
+ });
2457
+ }
2458
+ } else {
2459
+ context.report({
2460
+ messageId: "forbiddenVoidReturnProperty",
2461
+ node: node.value
2462
+ });
2463
+ }
2441
2464
  }
2442
2465
  function checkReturnStatement(node) {
2443
2466
  const tsNode = esTreeNodeToTSNodeMap.get(node);
2444
- if (tsNode.expression === void 0 || !node.argument) {
2467
+ if (tsNode.expression == null || !node.argument) {
2445
2468
  return;
2446
2469
  }
2447
2470
  function getFunctionNode() {
@@ -2456,7 +2479,7 @@ var noMisusedObservablesRule = ruleCreator({
2456
2479
  return;
2457
2480
  }
2458
2481
  const contextualType = checker.getContextualType(tsNode.expression);
2459
- if (contextualType === void 0) {
2482
+ if (contextualType == null) {
2460
2483
  return;
2461
2484
  }
2462
2485
  if (!isVoidReturningFunctionType(contextualType)) {
@@ -2484,7 +2507,7 @@ var noMisusedObservablesRule = ruleCreator({
2484
2507
  }
2485
2508
  function checkVariableDeclaration(node) {
2486
2509
  const tsNode = esTreeNodeToTSNodeMap.get(node);
2487
- if (tsNode.initializer === void 0 || !node.init || !node.id.typeAnnotation) {
2510
+ if (tsNode.initializer == null || node.init == null || node.id.typeAnnotation == null) {
2488
2511
  return;
2489
2512
  }
2490
2513
  if (!isPossiblyFunctionType(node.id.typeAnnotation)) {
@@ -2531,6 +2554,9 @@ function isVoidReturningFunctionType(type) {
2531
2554
  for (const subType of tsutils2.unionTypeParts(type)) {
2532
2555
  for (const signature of subType.getCallSignatures()) {
2533
2556
  const returnType = signature.getReturnType();
2557
+ if (couldBeType(returnType, "Observable")) {
2558
+ return false;
2559
+ }
2534
2560
  hasVoidReturn || (hasVoidReturn = tsutils2.isTypeFlagSet(returnType, ts6.TypeFlags.Void));
2535
2561
  }
2536
2562
  }
@@ -2547,7 +2573,7 @@ function getMemberIfExists(type, memberName) {
2547
2573
  return symbolMemberMatch != null ? symbolMemberMatch : tsutils2.getPropertyOfType(type, escapedMemberName);
2548
2574
  }
2549
2575
  function isStaticMember(node) {
2550
- return (isMethodDefinition(node) || isPropertyDefinition(node)) && node.static;
2576
+ return (isMethodDefinition(node) || isPropertyDefinition(node) || isAccessorProperty(node)) && node.static;
2551
2577
  }
2552
2578
  function getPropertyContextualType(checker, tsNode) {
2553
2579
  if (ts6.isPropertyAssignment(tsNode)) {
@@ -2563,11 +2589,11 @@ function getPropertyContextualType(checker, tsNode) {
2563
2589
  return;
2564
2590
  }
2565
2591
  const objType = checker.getContextualType(obj);
2566
- if (objType === void 0) {
2592
+ if (objType == null) {
2567
2593
  return;
2568
2594
  }
2569
2595
  const propertySymbol = checker.getPropertyOfType(objType, tsNode.name.text);
2570
- if (propertySymbol === void 0) {
2596
+ if (propertySymbol == null) {
2571
2597
  return;
2572
2598
  }
2573
2599
  return checker.getTypeOfSymbolAtLocation(propertySymbol, tsNode.name);
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "eslint-plugin-rxjs-x",
3
3
  "type": "commonjs",
4
- "version": "0.7.5",
5
- "packageManager": "yarn@4.9.1+sha512.f95ce356460e05be48d66401c1ae64ef84d163dd689964962c6888a9810865e39097a5e9de748876c2e0bf89b232d583c33982773e9903ae7a76257270986538",
4
+ "version": "0.7.7",
5
+ "packageManager": "yarn@4.9.2+sha512.1fc009bc09d13cfd0e19efa44cbfc2b9cf6ca61482725eb35bbc5e257e093ebf4130db6dfe15d604ff4b79efd8e1e8e99b25fa7d0a6197c9f9826358d4d65c3c",
6
6
  "description": "ESLint v9+ plugin for RxJS",
7
7
  "author": "Jason Weinzierl <weinzierljason@gmail.com>",
8
8
  "license": "MIT",
@@ -72,29 +72,29 @@
72
72
  }
73
73
  },
74
74
  "devDependencies": {
75
- "@eslint/js": "^9.28.0",
76
- "@stylistic/eslint-plugin": "^4.4.0",
75
+ "@eslint/js": "^9.29.0",
76
+ "@stylistic/eslint-plugin": "^5.0.0",
77
77
  "@types/common-tags": "^1.8.4",
78
78
  "@types/node": "~18.18.0",
79
- "@typescript-eslint/rule-tester": "^8.33.1",
79
+ "@typescript-eslint/rule-tester": "^8.34.1",
80
80
  "@typescript/vfs": "^1.6.1",
81
- "@vitest/coverage-v8": "^3.2.0",
82
- "@vitest/eslint-plugin": "^1.2.1",
83
- "bumpp": "^10.1.1",
84
- "eslint": "^9.28.0",
81
+ "@vitest/coverage-v8": "^3.2.4",
82
+ "@vitest/eslint-plugin": "^1.2.7",
83
+ "bumpp": "^10.2.0",
84
+ "eslint": "^9.29.0",
85
85
  "eslint-config-flat-gitignore": "^2.1.0",
86
- "eslint-doc-generator": "^2.1.2",
87
- "eslint-import-resolver-typescript": "^4.4.2",
88
- "eslint-plugin-eslint-plugin": "^6.4.0",
89
- "eslint-plugin-import-x": "^4.15.0",
90
- "eslint-plugin-n": "^17.19.0",
86
+ "eslint-doc-generator": "^2.2.2",
87
+ "eslint-import-resolver-typescript": "^4.4.3",
88
+ "eslint-plugin-eslint-plugin": "^6.5.0",
89
+ "eslint-plugin-import-x": "^4.15.2",
90
+ "eslint-plugin-n": "^17.20.0",
91
91
  "markdownlint-cli2": "^0.18.1",
92
92
  "rxjs": "^7.8.2",
93
93
  "tsup": "^8.5.0",
94
94
  "typescript": "~5.8.3",
95
- "typescript-eslint": "^8.33.1",
95
+ "typescript-eslint": "^8.34.1",
96
96
  "vite": "^6.3.5",
97
- "vitest": "^3.2.0"
97
+ "vitest": "^3.2.4"
98
98
  },
99
99
  "engines": {
100
100
  "node": "^18.18.0 || ^20.9.0 || >= 21.1.0"