eslint-plugin-rxjs-x 0.7.3 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.3";
3
+ var version = "0.7.4";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -284,6 +284,9 @@ function isPropertyDefinition(node) {
284
284
  function isUnaryExpression(node) {
285
285
  return node.type === _utils.AST_NODE_TYPES.UnaryExpression;
286
286
  }
287
+ function isUnionType(node) {
288
+ return node.type === _utils.AST_NODE_TYPES.TSUnionType;
289
+ }
287
290
 
288
291
  // src/etc/get-type-services.ts
289
292
  function getTypeServices(context) {
@@ -389,6 +392,41 @@ function findIsLastOperatorOrderValid(pipeCallExpression, operatorsRegExp, allow
389
392
  return { isOrderValid, operatorNode };
390
393
  }
391
394
 
395
+ // src/constants.ts
396
+ var defaultObservable = String.raw`[Aa]ction(s|s\$|\$)$`;
397
+ var SOURCES_OBJECT_ACCEPTING_STATIC_OBSERVABLE_CREATORS = [
398
+ "combineLatest",
399
+ "forkJoin"
400
+ ];
401
+ var DEFAULT_VALID_POST_COMPLETION_OPERATORS = [
402
+ "count",
403
+ "defaultIfEmpty",
404
+ "endWith",
405
+ "every",
406
+ "finalize",
407
+ "finally",
408
+ "isEmpty",
409
+ "last",
410
+ "max",
411
+ "min",
412
+ "publish",
413
+ "publishBehavior",
414
+ "publishLast",
415
+ "publishReplay",
416
+ "reduce",
417
+ "share",
418
+ "shareReplay",
419
+ "skipLast",
420
+ "takeLast",
421
+ "throwIfEmpty",
422
+ "toArray"
423
+ ];
424
+
425
+ // src/utils/is-sources-object-accepting-static-observable-creator.ts
426
+ function isSourcesObjectAcceptingStaticObservableCreator(expression) {
427
+ return isCallExpression(expression) && isIdentifier(expression.callee) && SOURCES_OBJECT_ACCEPTING_STATIC_OBSERVABLE_CREATORS.includes(expression.callee.name);
428
+ }
429
+
392
430
  // src/utils/rule-creator.ts
393
431
 
394
432
  var REPO_URL = "https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x";
@@ -717,7 +755,7 @@ var finnishRule = ruleCreator({
717
755
  "ObjectExpression > Property[computed=false] > Identifier": (node) => {
718
756
  if (validate.properties) {
719
757
  const parent = node.parent;
720
- if (node === parent.key) {
758
+ if (node === parent.key && !isSourcesObjectAcceptingStaticObservableCreator(parent.parent.parent)) {
721
759
  checkNode(node);
722
760
  }
723
761
  }
@@ -1028,34 +1066,6 @@ var noCreateRule = ruleCreator({
1028
1066
 
1029
1067
 
1030
1068
 
1031
-
1032
- // src/constants.ts
1033
- var defaultObservable = String.raw`[Aa]ction(s|s\$|\$)$`;
1034
- var DEFAULT_VALID_POST_COMPLETION_OPERATORS = [
1035
- "count",
1036
- "defaultIfEmpty",
1037
- "endWith",
1038
- "every",
1039
- "finalize",
1040
- "finally",
1041
- "isEmpty",
1042
- "last",
1043
- "max",
1044
- "min",
1045
- "publish",
1046
- "publishBehavior",
1047
- "publishLast",
1048
- "publishReplay",
1049
- "reduce",
1050
- "share",
1051
- "shareReplay",
1052
- "skipLast",
1053
- "takeLast",
1054
- "throwIfEmpty",
1055
- "toArray"
1056
- ];
1057
-
1058
- // src/rules/no-cyclic-action.ts
1059
1069
  function isTypeReference2(type) {
1060
1070
  return Boolean(type.target);
1061
1071
  }
@@ -1180,21 +1190,25 @@ var noExplicitGenericsRule = ruleCreator({
1180
1190
  });
1181
1191
  }
1182
1192
  function checkBehaviorSubjects(node) {
1193
+ var _a;
1183
1194
  const parent = node.parent;
1184
1195
  const {
1185
1196
  arguments: [value]
1186
1197
  } = parent;
1187
- if (isArrayExpression(value) || isObjectExpression(value)) {
1198
+ const typeArgs = (_a = parent.typeArguments) == null ? void 0 : _a.params[0];
1199
+ if (isArrayExpression(value) || isObjectExpression(value) || typeArgs && isUnionType(typeArgs)) {
1188
1200
  return;
1189
1201
  }
1190
1202
  report(node);
1191
1203
  }
1192
1204
  function checkNotifications(node) {
1205
+ var _a;
1193
1206
  const parent = node.parent;
1194
1207
  const {
1195
1208
  arguments: [, value]
1196
1209
  } = parent;
1197
- if (isArrayExpression(value) || isObjectExpression(value)) {
1210
+ const typeArgs = (_a = parent.typeArguments) == null ? void 0 : _a.params[0];
1211
+ if (isArrayExpression(value) || isObjectExpression(value) || typeArgs && isUnionType(typeArgs)) {
1198
1212
  return;
1199
1213
  }
1200
1214
  report(node);
@@ -3911,7 +3925,7 @@ var suffixSubjectsRule = ruleCreator({
3911
3925
  "ObjectExpression > Property[computed=false] > Identifier": (node) => {
3912
3926
  if (validate.properties) {
3913
3927
  const parent = node.parent;
3914
- if (node === parent.key) {
3928
+ if (node === parent.key && !isSourcesObjectAcceptingStaticObservableCreator(parent.parent.parent)) {
3915
3929
  checkNode(node);
3916
3930
  }
3917
3931
  }
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.3";
3
+ var version = "0.7.4";
4
4
 
5
5
  // src/configs/recommended.ts
6
6
  var createRecommendedConfig = (plugin2) => ({
@@ -284,6 +284,9 @@ function isPropertyDefinition(node) {
284
284
  function isUnaryExpression(node) {
285
285
  return node.type === AST_NODE_TYPES.UnaryExpression;
286
286
  }
287
+ function isUnionType(node) {
288
+ return node.type === AST_NODE_TYPES.TSUnionType;
289
+ }
287
290
 
288
291
  // src/etc/get-type-services.ts
289
292
  function getTypeServices(context) {
@@ -389,6 +392,41 @@ function findIsLastOperatorOrderValid(pipeCallExpression, operatorsRegExp, allow
389
392
  return { isOrderValid, operatorNode };
390
393
  }
391
394
 
395
+ // src/constants.ts
396
+ var defaultObservable = String.raw`[Aa]ction(s|s\$|\$)$`;
397
+ var SOURCES_OBJECT_ACCEPTING_STATIC_OBSERVABLE_CREATORS = [
398
+ "combineLatest",
399
+ "forkJoin"
400
+ ];
401
+ var DEFAULT_VALID_POST_COMPLETION_OPERATORS = [
402
+ "count",
403
+ "defaultIfEmpty",
404
+ "endWith",
405
+ "every",
406
+ "finalize",
407
+ "finally",
408
+ "isEmpty",
409
+ "last",
410
+ "max",
411
+ "min",
412
+ "publish",
413
+ "publishBehavior",
414
+ "publishLast",
415
+ "publishReplay",
416
+ "reduce",
417
+ "share",
418
+ "shareReplay",
419
+ "skipLast",
420
+ "takeLast",
421
+ "throwIfEmpty",
422
+ "toArray"
423
+ ];
424
+
425
+ // src/utils/is-sources-object-accepting-static-observable-creator.ts
426
+ function isSourcesObjectAcceptingStaticObservableCreator(expression) {
427
+ return isCallExpression(expression) && isIdentifier(expression.callee) && SOURCES_OBJECT_ACCEPTING_STATIC_OBSERVABLE_CREATORS.includes(expression.callee.name);
428
+ }
429
+
392
430
  // src/utils/rule-creator.ts
393
431
  import { ESLintUtils as ESLintUtils2 } from "@typescript-eslint/utils";
394
432
  var REPO_URL = "https://github.com/JasonWeinzierl/eslint-plugin-rxjs-x";
@@ -717,7 +755,7 @@ var finnishRule = ruleCreator({
717
755
  "ObjectExpression > Property[computed=false] > Identifier": (node) => {
718
756
  if (validate.properties) {
719
757
  const parent = node.parent;
720
- if (node === parent.key) {
758
+ if (node === parent.key && !isSourcesObjectAcceptingStaticObservableCreator(parent.parent.parent)) {
721
759
  checkNode(node);
722
760
  }
723
761
  }
@@ -1028,34 +1066,6 @@ var noCreateRule = ruleCreator({
1028
1066
  import { ESLintUtils as ESLintUtils4 } from "@typescript-eslint/utils";
1029
1067
  import { stripIndent as stripIndent3 } from "common-tags";
1030
1068
  import ts5 from "typescript";
1031
-
1032
- // src/constants.ts
1033
- var defaultObservable = String.raw`[Aa]ction(s|s\$|\$)$`;
1034
- var DEFAULT_VALID_POST_COMPLETION_OPERATORS = [
1035
- "count",
1036
- "defaultIfEmpty",
1037
- "endWith",
1038
- "every",
1039
- "finalize",
1040
- "finally",
1041
- "isEmpty",
1042
- "last",
1043
- "max",
1044
- "min",
1045
- "publish",
1046
- "publishBehavior",
1047
- "publishLast",
1048
- "publishReplay",
1049
- "reduce",
1050
- "share",
1051
- "shareReplay",
1052
- "skipLast",
1053
- "takeLast",
1054
- "throwIfEmpty",
1055
- "toArray"
1056
- ];
1057
-
1058
- // src/rules/no-cyclic-action.ts
1059
1069
  function isTypeReference2(type) {
1060
1070
  return Boolean(type.target);
1061
1071
  }
@@ -1180,21 +1190,25 @@ var noExplicitGenericsRule = ruleCreator({
1180
1190
  });
1181
1191
  }
1182
1192
  function checkBehaviorSubjects(node) {
1193
+ var _a;
1183
1194
  const parent = node.parent;
1184
1195
  const {
1185
1196
  arguments: [value]
1186
1197
  } = parent;
1187
- if (isArrayExpression(value) || isObjectExpression(value)) {
1198
+ const typeArgs = (_a = parent.typeArguments) == null ? void 0 : _a.params[0];
1199
+ if (isArrayExpression(value) || isObjectExpression(value) || typeArgs && isUnionType(typeArgs)) {
1188
1200
  return;
1189
1201
  }
1190
1202
  report(node);
1191
1203
  }
1192
1204
  function checkNotifications(node) {
1205
+ var _a;
1193
1206
  const parent = node.parent;
1194
1207
  const {
1195
1208
  arguments: [, value]
1196
1209
  } = parent;
1197
- if (isArrayExpression(value) || isObjectExpression(value)) {
1210
+ const typeArgs = (_a = parent.typeArguments) == null ? void 0 : _a.params[0];
1211
+ if (isArrayExpression(value) || isObjectExpression(value) || typeArgs && isUnionType(typeArgs)) {
1198
1212
  return;
1199
1213
  }
1200
1214
  report(node);
@@ -3911,7 +3925,7 @@ var suffixSubjectsRule = ruleCreator({
3911
3925
  "ObjectExpression > Property[computed=false] > Identifier": (node) => {
3912
3926
  if (validate.properties) {
3913
3927
  const parent = node.parent;
3914
- if (node === parent.key) {
3928
+ if (node === parent.key && !isSourcesObjectAcceptingStaticObservableCreator(parent.parent.parent)) {
3915
3929
  checkNode(node);
3916
3930
  }
3917
3931
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "eslint-plugin-rxjs-x",
3
3
  "type": "commonjs",
4
- "version": "0.7.3",
4
+ "version": "0.7.4",
5
5
  "packageManager": "yarn@4.9.1+sha512.f95ce356460e05be48d66401c1ae64ef84d163dd689964962c6888a9810865e39097a5e9de748876c2e0bf89b232d583c33982773e9903ae7a76257270986538",
6
6
  "description": "ESLint v9+ plugin for RxJS",
7
7
  "author": "Jason Weinzierl <weinzierljason@gmail.com>",