@ngrx/eslint-plugin 18.0.0-beta.1 → 18.0.0-rc.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.
Files changed (205) hide show
  1. package/jest.config.d.ts +15 -0
  2. package/package.json +3 -5
  3. package/schematics/ng-add/index.d.ts +3 -0
  4. package/schematics/ng-add/index.js +32 -20
  5. package/schematics/ng-add/index.js.map +1 -1
  6. package/schematics/ng-add/schema.d.ts +3 -0
  7. package/schematics/ng-add/schema.js.map +1 -1
  8. package/schematics/ng-add/schema.json +16 -51
  9. package/scripts/generate-config.d.ts +1 -0
  10. package/scripts/generate-config.js +73 -73
  11. package/scripts/generate-config.js.map +1 -1
  12. package/scripts/generate-docs.d.ts +1 -0
  13. package/scripts/generate-docs.js +33 -65
  14. package/scripts/generate-docs.js.map +1 -1
  15. package/scripts/generate-overview.d.ts +1 -0
  16. package/scripts/generate-overview.js +43 -75
  17. package/scripts/generate-overview.js.map +1 -1
  18. package/spec/utils/from-fixture.d.ts +8 -0
  19. package/spec/utils/from-fixture.js +62 -0
  20. package/spec/utils/from-fixture.js.map +1 -0
  21. package/spec/utils/index.d.ts +2 -0
  22. package/spec/utils/index.js +16 -19
  23. package/spec/utils/index.js.map +1 -1
  24. package/spec/utils/rule-tester.d.ts +5 -0
  25. package/spec/utils/rule-tester.js +23 -0
  26. package/spec/utils/rule-tester.js.map +1 -0
  27. package/src/configs/all.d.ts +7 -0
  28. package/src/configs/all.js +56 -32
  29. package/src/configs/all.js.map +1 -1
  30. package/src/configs/all.json +42 -0
  31. package/src/configs/component-store.d.ts +7 -0
  32. package/src/configs/component-store.js +23 -8
  33. package/src/configs/component-store.js.map +1 -1
  34. package/src/configs/component-store.json +9 -0
  35. package/src/configs/effects.d.ts +7 -0
  36. package/src/configs/effects.js +32 -11
  37. package/src/configs/effects.js.map +1 -1
  38. package/src/configs/effects.json +13 -0
  39. package/src/configs/operators.d.ts +7 -0
  40. package/src/configs/operators.js +28 -0
  41. package/src/configs/operators.js.map +1 -0
  42. package/src/configs/operators.json +7 -0
  43. package/src/configs/signals.d.ts +7 -0
  44. package/src/configs/signals.js +34 -0
  45. package/src/configs/signals.js.map +1 -0
  46. package/src/configs/signals.json +8 -0
  47. package/src/configs/store.d.ts +7 -0
  48. package/src/configs/store.js +38 -23
  49. package/src/configs/store.js.map +1 -1
  50. package/src/configs/store.json +24 -0
  51. package/src/index.d.ts +141 -0
  52. package/src/index.js +18 -3
  53. package/src/index.js.map +1 -1
  54. package/src/rule-creator.d.ts +24 -0
  55. package/src/rule-creator.js +12 -58
  56. package/src/rule-creator.js.map +1 -1
  57. package/src/rules/component-store/avoid-combining-component-store-selectors.d.ts +3 -0
  58. package/src/rules/component-store/avoid-combining-component-store-selectors.js +22 -47
  59. package/src/rules/component-store/avoid-combining-component-store-selectors.js.map +1 -1
  60. package/src/rules/component-store/avoid-mapping-component-store-selectors.d.ts +3 -0
  61. package/src/rules/component-store/avoid-mapping-component-store-selectors.js +17 -20
  62. package/src/rules/component-store/avoid-mapping-component-store-selectors.js.map +1 -1
  63. package/src/rules/component-store/updater-explicit-return-type.d.ts +3 -0
  64. package/src/rules/component-store/updater-explicit-return-type.js +17 -20
  65. package/src/rules/component-store/updater-explicit-return-type.js.map +1 -1
  66. package/src/rules/effects/avoid-cyclic-effects.d.ts +4 -0
  67. package/src/rules/effects/avoid-cyclic-effects.js +47 -109
  68. package/src/rules/effects/avoid-cyclic-effects.js.map +1 -1
  69. package/src/rules/effects/no-dispatch-in-effects.d.ts +5 -0
  70. package/src/rules/effects/no-dispatch-in-effects.js +17 -21
  71. package/src/rules/effects/no-dispatch-in-effects.js.map +1 -1
  72. package/src/rules/effects/no-effects-in-providers.d.ts +3 -0
  73. package/src/rules/effects/no-effects-in-providers.js +18 -49
  74. package/src/rules/effects/no-effects-in-providers.js.map +1 -1
  75. package/src/rules/effects/no-multiple-actions-in-effects.d.ts +5 -0
  76. package/src/rules/effects/no-multiple-actions-in-effects.js +31 -24
  77. package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -1
  78. package/src/rules/effects/prefer-action-creator-in-of-type.d.ts +3 -0
  79. package/src/rules/effects/prefer-action-creator-in-of-type.js +10 -13
  80. package/src/rules/effects/prefer-action-creator-in-of-type.js.map +1 -1
  81. package/src/rules/effects/prefer-effect-callback-in-block-statement.d.ts +4 -0
  82. package/src/rules/effects/prefer-effect-callback-in-block-statement.js +24 -43
  83. package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -1
  84. package/src/rules/effects/use-effects-lifecycle-interface.d.ts +3 -0
  85. package/src/rules/effects/use-effects-lifecycle-interface.js +21 -24
  86. package/src/rules/effects/use-effects-lifecycle-interface.js.map +1 -1
  87. package/src/rules/index.d.ts +33 -0
  88. package/src/rules/index.js +69 -53
  89. package/src/rules/index.js.map +1 -1
  90. package/src/rules/operators/prefer-concat-latest-from.d.ts +7 -0
  91. package/src/rules/operators/prefer-concat-latest-from.js +123 -0
  92. package/src/rules/operators/prefer-concat-latest-from.js.map +1 -0
  93. package/src/rules/signals/signal-state-no-arrays-at-root-level.d.ts +3 -0
  94. package/src/rules/signals/signal-state-no-arrays-at-root-level.js +59 -0
  95. package/src/rules/signals/signal-state-no-arrays-at-root-level.js.map +1 -0
  96. package/src/rules/signals/with-state-no-arrays-at-root-level.d.ts +4 -0
  97. package/src/rules/signals/with-state-no-arrays-at-root-level.js +72 -0
  98. package/src/rules/signals/with-state-no-arrays-at-root-level.js.map +1 -0
  99. package/src/rules/store/avoid-combining-selectors.d.ts +3 -0
  100. package/src/rules/store/avoid-combining-selectors.js +20 -45
  101. package/src/rules/store/avoid-combining-selectors.js.map +1 -1
  102. package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.d.ts +3 -0
  103. package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js +20 -47
  104. package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -1
  105. package/src/rules/store/avoid-duplicate-actions-in-reducer.d.ts +5 -0
  106. package/src/rules/store/avoid-duplicate-actions-in-reducer.js +33 -101
  107. package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -1
  108. package/src/rules/store/avoid-mapping-selectors.d.ts +3 -0
  109. package/src/rules/store/avoid-mapping-selectors.js +24 -30
  110. package/src/rules/store/avoid-mapping-selectors.js.map +1 -1
  111. package/src/rules/store/good-action-hygiene.d.ts +3 -0
  112. package/src/rules/store/good-action-hygiene.js +14 -34
  113. package/src/rules/store/good-action-hygiene.js.map +1 -1
  114. package/src/rules/store/no-multiple-global-stores.d.ts +6 -0
  115. package/src/rules/store/no-multiple-global-stores.js +34 -96
  116. package/src/rules/store/no-multiple-global-stores.js.map +1 -1
  117. package/src/rules/store/no-reducer-in-key-names.d.ts +5 -0
  118. package/src/rules/store/no-reducer-in-key-names.js +16 -20
  119. package/src/rules/store/no-reducer-in-key-names.js.map +1 -1
  120. package/src/rules/store/no-store-subscription.d.ts +3 -0
  121. package/src/rules/store/no-store-subscription.js +13 -16
  122. package/src/rules/store/no-store-subscription.js.map +1 -1
  123. package/src/rules/store/no-typed-global-store.d.ts +5 -0
  124. package/src/rules/store/no-typed-global-store.js +29 -70
  125. package/src/rules/store/no-typed-global-store.js.map +1 -1
  126. package/src/rules/store/on-function-explicit-return-type.d.ts +6 -0
  127. package/src/rules/store/on-function-explicit-return-type.js +23 -43
  128. package/src/rules/store/on-function-explicit-return-type.js.map +1 -1
  129. package/src/rules/store/prefer-action-creator-in-dispatch.d.ts +3 -0
  130. package/src/rules/store/prefer-action-creator-in-dispatch.js +15 -18
  131. package/src/rules/store/prefer-action-creator-in-dispatch.js.map +1 -1
  132. package/src/rules/store/prefer-action-creator.d.ts +3 -0
  133. package/src/rules/store/prefer-action-creator.js +10 -13
  134. package/src/rules/store/prefer-action-creator.js.map +1 -1
  135. package/src/rules/store/prefer-inline-action-props.d.ts +5 -0
  136. package/src/rules/store/prefer-inline-action-props.js +14 -18
  137. package/src/rules/store/prefer-inline-action-props.js.map +1 -1
  138. package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.d.ts +5 -0
  139. package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js +16 -37
  140. package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js.map +1 -1
  141. package/src/rules/store/prefer-selector-in-select.d.ts +3 -0
  142. package/src/rules/store/prefer-selector-in-select.js +21 -46
  143. package/src/rules/store/prefer-selector-in-select.js.map +1 -1
  144. package/src/rules/store/prefix-selectors-with-select.d.ts +5 -0
  145. package/src/rules/store/prefix-selectors-with-select.js +26 -39
  146. package/src/rules/store/prefix-selectors-with-select.js.map +1 -1
  147. package/src/rules/store/select-style.d.ts +11 -0
  148. package/src/rules/store/select-style.js +53 -108
  149. package/src/rules/store/select-style.js.map +1 -1
  150. package/src/rules/store/use-consistent-global-store-name.d.ts +6 -0
  151. package/src/rules/store/use-consistent-global-store-name.js +24 -80
  152. package/src/rules/store/use-consistent-global-store-name.js.map +1 -1
  153. package/src/utils/helper-functions/docs.d.ts +1 -0
  154. package/src/utils/helper-functions/docs.js +1 -3
  155. package/src/utils/helper-functions/docs.js.map +1 -1
  156. package/src/utils/helper-functions/folder.d.ts +5 -0
  157. package/src/utils/helper-functions/folder.js +16 -88
  158. package/src/utils/helper-functions/folder.js.map +1 -1
  159. package/src/utils/helper-functions/guards.d.ts +97 -0
  160. package/src/utils/helper-functions/guards.js +27 -31
  161. package/src/utils/helper-functions/guards.js.map +1 -1
  162. package/src/utils/helper-functions/index.d.ts +6 -0
  163. package/src/utils/helper-functions/ngrx-modules.d.ts +8 -0
  164. package/src/utils/helper-functions/ngrx-modules.js +7 -6
  165. package/src/utils/helper-functions/ngrx-modules.js.map +1 -1
  166. package/src/utils/helper-functions/rules.d.ts +3 -0
  167. package/src/utils/helper-functions/rules.js +47 -0
  168. package/src/utils/helper-functions/rules.js.map +1 -0
  169. package/src/utils/helper-functions/utils.d.ts +48 -0
  170. package/src/utils/helper-functions/utils.js +68 -143
  171. package/src/utils/helper-functions/utils.js.map +1 -1
  172. package/src/utils/helper-functions/versions.d.ts +1 -0
  173. package/src/utils/helper-functions/versions.js +9 -10
  174. package/src/utils/helper-functions/versions.js.map +1 -1
  175. package/src/utils/index.d.ts +2 -0
  176. package/src/utils/selectors/index.d.ts +29 -0
  177. package/src/utils/selectors/index.js +30 -44
  178. package/src/utils/selectors/index.js.map +1 -1
  179. package/v9/index.d.ts +29 -0
  180. package/v9/index.js +38 -0
  181. package/v9/index.js.map +1 -0
  182. package/src/configs/all-requiring-type-checking.js +0 -46
  183. package/src/configs/all-requiring-type-checking.js.map +0 -1
  184. package/src/configs/component-store-strict.js +0 -15
  185. package/src/configs/component-store-strict.js.map +0 -1
  186. package/src/configs/effects-requiring-type-checking.js +0 -25
  187. package/src/configs/effects-requiring-type-checking.js.map +0 -1
  188. package/src/configs/effects-strict-requiring-type-checking.js +0 -25
  189. package/src/configs/effects-strict-requiring-type-checking.js.map +0 -1
  190. package/src/configs/effects-strict.js +0 -18
  191. package/src/configs/effects-strict.js.map +0 -1
  192. package/src/configs/index.js +0 -33
  193. package/src/configs/index.js.map +0 -1
  194. package/src/configs/recommended-requiring-type-checking.js +0 -46
  195. package/src/configs/recommended-requiring-type-checking.js.map +0 -1
  196. package/src/configs/recommended.js +0 -39
  197. package/src/configs/recommended.js.map +0 -1
  198. package/src/configs/store-strict.js +0 -30
  199. package/src/configs/store-strict.js.map +0 -1
  200. package/src/configs/strict-requiring-type-checking.js +0 -46
  201. package/src/configs/strict-requiring-type-checking.js.map +0 -1
  202. package/src/configs/strict.js +0 -39
  203. package/src/configs/strict.js.map +0 -1
  204. package/src/rules/effects/prefer-concat-latest-from.js +0 -153
  205. package/src/rules/effects/prefer-concat-latest-from.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-state-no-arrays-at-root-level.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/signals/with-state-no-arrays-at-root-level.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { ESLintUtils, type TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { isArrayExpression } from '../../utils';\n\nexport const messageId = 'withStateNoArraysAtRootLevel';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'signals',\n docs: {\n description: `withState should accept a record or dictionary as an input argument.`,\n requiresTypeChecking: true,\n },\n schema: [],\n messages: {\n [messageId]: `Wrap the array in an record or dictionary.`,\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`CallExpression[callee.name=withState]`](node: TSESTree.CallExpression) {\n const [argument] = node.arguments;\n if (isArrayExpression(argument)) {\n context.report({\n node: argument,\n messageId,\n });\n } else if (argument) {\n const services = ESLintUtils.getParserServices(context);\n const typeChecker = services.program.getTypeChecker();\n const type = services.getTypeAtLocation(argument);\n\n if (typeChecker.isArrayType(type)) {\n context.report({\n node: argument,\n messageId,\n });\n }\n }\n },\n };\n },\n});\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const messageId = "avoidCombiningSelectors";
2
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidCombiningSelectors", readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
3
+ export default _default;
@@ -22,23 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __values = (this && this.__values) || function(o) {
26
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
27
- if (m) return m.call(o);
28
- if (o && typeof o.length === "number") return {
29
- next: function () {
30
- if (o && i >= o.length) o = void 0;
31
- return { value: o && o[i++], done: !o };
32
- }
33
- };
34
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
35
- };
36
- var _a;
37
25
  Object.defineProperty(exports, "__esModule", { value: true });
38
26
  exports.messageId = void 0;
39
- var path = __importStar(require("path"));
40
- var rule_creator_1 = require("../../rule-creator");
41
- var utils_1 = require("../../utils");
27
+ const path = __importStar(require("path"));
28
+ const rule_creator_1 = require("../../rule-creator");
29
+ const utils_1 = require("../../utils");
42
30
  exports.messageId = 'avoidCombiningSelectors';
43
31
  exports.default = (0, rule_creator_1.createRule)({
44
32
  name: path.parse(__filename).name,
@@ -47,48 +35,35 @@ exports.default = (0, rule_creator_1.createRule)({
47
35
  ngrxModule: 'store',
48
36
  docs: {
49
37
  description: 'Prefer combining selectors at the selector level.',
50
- recommended: 'warn',
51
38
  },
52
39
  schema: [],
53
- messages: (_a = {},
54
- _a[exports.messageId] = 'Combine selectors at the selector level.',
55
- _a),
40
+ messages: {
41
+ [exports.messageId]: 'Combine selectors at the selector level.',
42
+ },
56
43
  },
57
44
  defaultOptions: [],
58
- create: function (context) {
59
- var _a;
60
- var _b = (0, utils_1.getNgRxStores)(context).identifiers, identifiers = _b === void 0 ? [] : _b;
61
- var storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
45
+ create: (context) => {
46
+ const { identifiers = [] } = (0, utils_1.getNgRxStores)(context);
47
+ const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
62
48
  if (!storeNames) {
63
49
  return {};
64
50
  }
65
- var pipeableOrStoreSelect = ":matches(".concat((0, utils_1.namedExpression)(storeNames), "[callee.property.name='pipe']:has(CallExpression[callee.name='select']), ").concat((0, utils_1.selectExpression)(storeNames), ")");
66
- var selectsInArray = [];
67
- return _a = {},
68
- _a["CallExpression[callee.name='combineLatest'] ".concat(pipeableOrStoreSelect, " ~ ").concat(pipeableOrStoreSelect)] = function (node) {
51
+ const pipeableOrStoreSelect = `:matches(${(0, utils_1.namedExpression)(storeNames)}[callee.property.name='pipe']:has(CallExpression[callee.name='select']), ${(0, utils_1.selectExpression)(storeNames)})`;
52
+ const selectsInArray = [];
53
+ return {
54
+ [`CallExpression[callee.name='combineLatest'] ${pipeableOrStoreSelect} ~ ${pipeableOrStoreSelect}`](node) {
69
55
  selectsInArray.push(node);
70
56
  },
71
- _a["CallExpression[callee.name='combineLatest']:exit"] = function () {
72
- var e_1, _a;
73
- try {
74
- for (var selectsInArray_1 = __values(selectsInArray), selectsInArray_1_1 = selectsInArray_1.next(); !selectsInArray_1_1.done; selectsInArray_1_1 = selectsInArray_1.next()) {
75
- var node = selectsInArray_1_1.value;
76
- context.report({
77
- node: node,
78
- messageId: exports.messageId,
79
- });
80
- }
81
- }
82
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
83
- finally {
84
- try {
85
- if (selectsInArray_1_1 && !selectsInArray_1_1.done && (_a = selectsInArray_1.return)) _a.call(selectsInArray_1);
86
- }
87
- finally { if (e_1) throw e_1.error; }
57
+ [`CallExpression[callee.name='combineLatest']:exit`]() {
58
+ for (const node of selectsInArray) {
59
+ context.report({
60
+ node,
61
+ messageId: exports.messageId,
62
+ });
88
63
  }
89
64
  selectsInArray.length = 0;
90
65
  },
91
- _a;
66
+ };
92
67
  },
93
68
  });
94
69
  //# sourceMappingURL=avoid-combining-selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-combining-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-combining-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,SAAS,GAAG,yBAAyB,CAAC;AAKnD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;YAChE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IAAG,0CAA0C;eACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,IAAM,qBAAqB,GAAG,mBAAY,IAAA,uBAAe,EACvD,UAAU,CACX,sFAA4E,IAAA,wBAAgB,EAC3F,UAAU,CACX,MAAY,CAAC;QAEd,IAAM,cAAc,GAA8B,EAAE,CAAC;QACrD;YACE,GAAC,sDAA+C,qBAAqB,gBAAM,qBAAqB,CAAE,IAAlG,UACE,IAA6B;gBAE7B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YACD,GAAC,kDAAkD,IAAnD;;;oBACE,KAAmB,IAAA,mBAAA,SAAA,cAAc,CAAA,8CAAA,0EAAE,CAAC;wBAA/B,IAAM,IAAI,2BAAA;wBACb,OAAO,CAAC,MAAM,CAAC;4BACb,IAAI,MAAA;4BACJ,SAAS,mBAAA;yBACV,CAAC,CAAC;oBACL,CAAC;;;;;;;;;gBACD,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n namedExpression,\n selectExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidCombiningSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Prefer combining selectors at the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Combine selectors at the selector level.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeableOrStoreSelect = `:matches(${namedExpression(\n storeNames\n )}[callee.property.name='pipe']:has(CallExpression[callee.name='select']), ${selectExpression(\n storeNames\n )})` as const;\n\n const selectsInArray: TSESTree.CallExpression[] = [];\n return {\n [`CallExpression[callee.name='combineLatest'] ${pipeableOrStoreSelect} ~ ${pipeableOrStoreSelect}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest']:exit`]() {\n for (const node of selectsInArray) {\n context.report({\n node,\n messageId,\n });\n }\n selectsInArray.length = 0;\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-combining-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-combining-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAKqB;AAER,QAAA,SAAS,GAAG,yBAAyB,CAAC;AAKnD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,mDAAmD;SACjE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EAAE,0CAA0C;SACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,MAAM,qBAAqB,GAAG,YAAY,IAAA,uBAAe,EACvD,UAAU,CACX,4EAA4E,IAAA,wBAAgB,EAC3F,UAAU,CACX,GAAY,CAAC;QAEd,MAAM,cAAc,GAA8B,EAAE,CAAC;QACrD,OAAO;YACL,CAAC,+CAA+C,qBAAqB,MAAM,qBAAqB,EAAE,CAAC,CACjG,IAA6B;gBAE7B,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;YACD,CAAC,kDAAkD,CAAC;gBAClD,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE,CAAC;oBAClC,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAT,iBAAS;qBACV,CAAC,CAAC;gBACL,CAAC;gBACD,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n namedExpression,\n selectExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidCombiningSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Prefer combining selectors at the selector level.',\n },\n schema: [],\n messages: {\n [messageId]: 'Combine selectors at the selector level.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeableOrStoreSelect = `:matches(${namedExpression(\n storeNames\n )}[callee.property.name='pipe']:has(CallExpression[callee.name='select']), ${selectExpression(\n storeNames\n )})` as const;\n\n const selectsInArray: TSESTree.CallExpression[] = [];\n return {\n [`CallExpression[callee.name='combineLatest'] ${pipeableOrStoreSelect} ~ ${pipeableOrStoreSelect}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest']:exit`]() {\n for (const node of selectsInArray) {\n context.report({\n node,\n messageId,\n });\n }\n selectsInArray.length = 0;\n },\n };\n },\n});\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const messageId = "avoidDispatchingMultipleActionsSequentially";
2
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidDispatchingMultipleActionsSequentially", readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
3
+ export default _default;
@@ -22,23 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __values = (this && this.__values) || function(o) {
26
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
27
- if (m) return m.call(o);
28
- if (o && typeof o.length === "number") return {
29
- next: function () {
30
- if (o && i >= o.length) o = void 0;
31
- return { value: o && o[i++], done: !o };
32
- }
33
- };
34
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
35
- };
36
- var _a;
37
25
  Object.defineProperty(exports, "__esModule", { value: true });
38
26
  exports.messageId = void 0;
39
- var path = __importStar(require("path"));
40
- var rule_creator_1 = require("../../rule-creator");
41
- var utils_1 = require("../../utils");
27
+ const path = __importStar(require("path"));
28
+ const rule_creator_1 = require("../../rule-creator");
29
+ const utils_1 = require("../../utils");
42
30
  exports.messageId = 'avoidDispatchingMultipleActionsSequentially';
43
31
  exports.default = (0, rule_creator_1.createRule)({
44
32
  name: path.parse(__filename).name,
@@ -47,52 +35,37 @@ exports.default = (0, rule_creator_1.createRule)({
47
35
  ngrxModule: 'store',
48
36
  docs: {
49
37
  description: 'It is recommended to only dispatch one `Action` at a time.',
50
- recommended: 'warn',
51
38
  },
52
39
  schema: [],
53
- messages: (_a = {},
54
- _a[exports.messageId] = 'Avoid dispatching many actions in a row to accomplish a larger conceptual "transaction".',
55
- _a),
40
+ messages: {
41
+ [exports.messageId]: 'Avoid dispatching many actions in a row to accomplish a larger conceptual "transaction".',
42
+ },
56
43
  },
57
44
  defaultOptions: [],
58
- create: function (context) {
59
- var _a;
60
- var _b = (0, utils_1.getNgRxStores)(context).identifiers, identifiers = _b === void 0 ? [] : _b;
61
- var storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
45
+ create: (context) => {
46
+ const { identifiers = [] } = (0, utils_1.getNgRxStores)(context);
47
+ const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
62
48
  if (!storeNames) {
63
49
  return {};
64
50
  }
65
- var collectedDispatches = [];
66
- return _a = {},
67
- _a["BlockStatement > ExpressionStatement > ".concat((0, utils_1.dispatchExpression)(storeNames))] = function (node) {
51
+ const collectedDispatches = [];
52
+ return {
53
+ [`BlockStatement > ExpressionStatement > ${(0, utils_1.dispatchExpression)(storeNames)}`](node) {
68
54
  collectedDispatches.push(node);
69
55
  },
70
- _a['BlockStatement:exit'] = function () {
71
- var e_1, _a;
72
- var withSameParent = collectedDispatches.filter(function (d1) {
73
- return collectedDispatches.some(function (d2) { var _a, _b; return d2 !== d1 && ((_a = d2.parent) === null || _a === void 0 ? void 0 : _a.parent) === ((_b = d1.parent) === null || _b === void 0 ? void 0 : _b.parent); });
74
- });
56
+ 'BlockStatement:exit'() {
57
+ const withSameParent = collectedDispatches.filter((d1) => collectedDispatches.some((d2) => d2 !== d1 && d2.parent?.parent === d1.parent?.parent));
75
58
  if (withSameParent.length > 1) {
76
- try {
77
- for (var withSameParent_1 = __values(withSameParent), withSameParent_1_1 = withSameParent_1.next(); !withSameParent_1_1.done; withSameParent_1_1 = withSameParent_1.next()) {
78
- var node = withSameParent_1_1.value;
79
- context.report({
80
- node: node,
81
- messageId: exports.messageId,
82
- });
83
- }
84
- }
85
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
86
- finally {
87
- try {
88
- if (withSameParent_1_1 && !withSameParent_1_1.done && (_a = withSameParent_1.return)) _a.call(withSameParent_1);
89
- }
90
- finally { if (e_1) throw e_1.error; }
59
+ for (const node of withSameParent) {
60
+ context.report({
61
+ node,
62
+ messageId: exports.messageId,
63
+ });
91
64
  }
92
65
  }
93
66
  collectedDispatches.length = 0;
94
67
  },
95
- _a;
68
+ };
96
69
  },
97
70
  });
98
71
  //# sourceMappingURL=avoid-dispatching-multiple-actions-sequentially.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-dispatching-multiple-actions-sequentially.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-dispatching-multiple-actions-sequentially.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA2E;AAE9D,QAAA,SAAS,GAAG,6CAA6C,CAAC;AAKvE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;YACzE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0FAA0F;eAC7F;KACF;IACD,cAAc,EAAE,EAAE;IAClB,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as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { asPattern, dispatchExpression, getNgRxStores } from '../../utils';\n\nexport const messageId = 'avoidDispatchingMultipleActionsSequentially';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'It is recommended to only dispatch one `Action` at a time.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Avoid dispatching many actions in a row to accomplish a larger conceptual \"transaction\".',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const collectedDispatches: TSESTree.CallExpression[] = [];\n\n return {\n [`BlockStatement > ExpressionStatement > ${dispatchExpression(\n storeNames\n )}`](node: TSESTree.CallExpression) {\n collectedDispatches.push(node);\n },\n 'BlockStatement:exit'() {\n const withSameParent = collectedDispatches.filter((d1) =>\n collectedDispatches.some(\n (d2) => d2 !== d1 && d2.parent?.parent === d1.parent?.parent\n )\n );\n if (withSameParent.length > 1) {\n for (const node of withSameParent) {\n context.report({\n node,\n messageId,\n });\n }\n }\n\n collectedDispatches.length = 0;\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-dispatching-multiple-actions-sequentially.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-dispatching-multiple-actions-sequentially.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAA2E;AAE9D,QAAA,SAAS,GAAG,6CAA6C,CAAC;AAKvE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU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CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { asPattern, dispatchExpression, getNgRxStores } from '../../utils';\n\nexport const messageId = 'avoidDispatchingMultipleActionsSequentially';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'It is recommended to only dispatch one `Action` at a time.',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Avoid dispatching many actions in a row to accomplish a larger conceptual \"transaction\".',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const collectedDispatches: TSESTree.CallExpression[] = [];\n\n return {\n [`BlockStatement > ExpressionStatement > ${dispatchExpression(\n storeNames\n )}`](node: TSESTree.CallExpression) {\n collectedDispatches.push(node);\n },\n 'BlockStatement:exit'() {\n const withSameParent = collectedDispatches.filter((d1) =>\n collectedDispatches.some(\n (d2) => d2 !== d1 && d2.parent?.parent === d1.parent?.parent\n )\n );\n if (withSameParent.length > 1) {\n for (const node of withSameParent) {\n context.report({\n node,\n messageId,\n });\n }\n }\n\n collectedDispatches.length = 0;\n },\n };\n },\n});\n"]}
@@ -0,0 +1,5 @@
1
+ export declare const avoidDuplicateActionsInReducer = "avoidDuplicateActionsInReducer";
2
+ export declare const avoidDuplicateActionsInReducerSuggest = "avoidDuplicateActionsInReducerSuggest";
3
+ type MessageIds = typeof avoidDuplicateActionsInReducer | typeof avoidDuplicateActionsInReducerSuggest;
4
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
5
+ export default _default;
@@ -22,48 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __read = (this && this.__read) || function (o, n) {
26
- var m = typeof Symbol === "function" && o[Symbol.iterator];
27
- if (!m) return o;
28
- var i = m.call(o), r, ar = [], e;
29
- try {
30
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
31
- }
32
- catch (error) { e = { error: error }; }
33
- finally {
34
- try {
35
- if (r && !r.done && (m = i["return"])) m.call(i);
36
- }
37
- finally { if (e) throw e.error; }
38
- }
39
- return ar;
40
- };
41
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
42
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
43
- if (ar || !(i in from)) {
44
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
45
- ar[i] = from[i];
46
- }
47
- }
48
- return to.concat(ar || Array.prototype.slice.call(from));
49
- };
50
- var __values = (this && this.__values) || function(o) {
51
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
52
- if (m) return m.call(o);
53
- if (o && typeof o.length === "number") return {
54
- next: function () {
55
- if (o && i >= o.length) o = void 0;
56
- return { value: o && o[i++], done: !o };
57
- }
58
- };
59
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
60
- };
61
- var _a;
62
25
  Object.defineProperty(exports, "__esModule", { value: true });
63
26
  exports.avoidDuplicateActionsInReducerSuggest = exports.avoidDuplicateActionsInReducer = void 0;
64
- var path = __importStar(require("path"));
65
- var rule_creator_1 = require("../../rule-creator");
66
- var utils_1 = require("../../utils");
27
+ const path = __importStar(require("path"));
28
+ const rule_creator_1 = require("../../rule-creator");
29
+ const utils_1 = require("../../utils");
67
30
  exports.avoidDuplicateActionsInReducer = 'avoidDuplicateActionsInReducer';
68
31
  exports.avoidDuplicateActionsInReducerSuggest = 'avoidDuplicateActionsInReducerSuggest';
69
32
  exports.default = (0, rule_creator_1.createRule)({
@@ -74,77 +37,46 @@ exports.default = (0, rule_creator_1.createRule)({
74
37
  ngrxModule: 'store',
75
38
  docs: {
76
39
  description: 'A `Reducer` should handle an `Action` once.',
77
- recommended: 'warn',
78
- suggestion: true,
79
40
  },
80
41
  schema: [],
81
- messages: (_a = {},
82
- _a[exports.avoidDuplicateActionsInReducer] = 'The `Reducer` handles a duplicate `Action` `{{ actionName }}`.',
83
- _a[exports.avoidDuplicateActionsInReducerSuggest] = 'Remove this duplication.',
84
- _a),
42
+ messages: {
43
+ [exports.avoidDuplicateActionsInReducer]: 'The `Reducer` handles a duplicate `Action` `{{ actionName }}`.',
44
+ [exports.avoidDuplicateActionsInReducerSuggest]: 'Remove this duplication.',
45
+ },
85
46
  },
86
47
  defaultOptions: [],
87
- create: function (context) {
88
- var _a;
89
- var sourceCode = context.getSourceCode();
90
- var collectedActions = new Map();
91
- return _a = {},
92
- _a["".concat(utils_1.createReducer, " > CallExpression[callee.name='on'][arguments.0.type='Identifier']")] = function (_a) {
93
- var _b;
94
- var _c = __read(_a.arguments, 1), action = _c[0];
95
- var actions = (_b = collectedActions.get(action.name)) !== null && _b !== void 0 ? _b : [];
96
- collectedActions.set(action.name, __spreadArray(__spreadArray([], __read(actions), false), [action], false));
48
+ create: (context) => {
49
+ const sourceCode = context.getSourceCode();
50
+ const collectedActions = new Map();
51
+ return {
52
+ [`${utils_1.createReducer} > CallExpression[callee.name='on'][arguments.0.type='Identifier']`]({ arguments: [action], }) {
53
+ const actions = collectedActions.get(action.name) ?? [];
54
+ collectedActions.set(action.name, [...actions, action]);
97
55
  },
98
- _a["".concat(utils_1.createReducer, ":exit")] = function () {
99
- var e_1, _a, e_2, _b;
100
- try {
101
- for (var collectedActions_1 = __values(collectedActions), collectedActions_1_1 = collectedActions_1.next(); !collectedActions_1_1.done; collectedActions_1_1 = collectedActions_1.next()) {
102
- var _c = __read(collectedActions_1_1.value, 2), actionName = _c[0], identifiers = _c[1];
103
- if (identifiers.length <= 1) {
104
- break;
105
- }
106
- var _loop_1 = function (node) {
107
- context.report({
108
- node: node,
109
- messageId: exports.avoidDuplicateActionsInReducer,
110
- data: {
111
- actionName: actionName,
112
- },
113
- suggest: [
114
- {
115
- messageId: exports.avoidDuplicateActionsInReducerSuggest,
116
- fix: function (fixer) {
117
- return (0, utils_1.getNodeToCommaRemoveFix)(sourceCode, fixer, node.parent);
118
- },
119
- },
120
- ],
121
- });
122
- };
123
- try {
124
- for (var identifiers_1 = (e_2 = void 0, __values(identifiers)), identifiers_1_1 = identifiers_1.next(); !identifiers_1_1.done; identifiers_1_1 = identifiers_1.next()) {
125
- var node = identifiers_1_1.value;
126
- _loop_1(node);
127
- }
128
- }
129
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
130
- finally {
131
- try {
132
- if (identifiers_1_1 && !identifiers_1_1.done && (_b = identifiers_1.return)) _b.call(identifiers_1);
133
- }
134
- finally { if (e_2) throw e_2.error; }
135
- }
56
+ [`${utils_1.createReducer}:exit`]() {
57
+ for (const [actionName, identifiers] of collectedActions) {
58
+ if (identifiers.length <= 1) {
59
+ break;
136
60
  }
137
- }
138
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
139
- finally {
140
- try {
141
- if (collectedActions_1_1 && !collectedActions_1_1.done && (_a = collectedActions_1.return)) _a.call(collectedActions_1);
61
+ for (const node of identifiers) {
62
+ context.report({
63
+ node,
64
+ messageId: exports.avoidDuplicateActionsInReducer,
65
+ data: {
66
+ actionName,
67
+ },
68
+ suggest: [
69
+ {
70
+ messageId: exports.avoidDuplicateActionsInReducerSuggest,
71
+ fix: (fixer) => (0, utils_1.getNodeToCommaRemoveFix)(sourceCode, fixer, node.parent),
72
+ },
73
+ ],
74
+ });
142
75
  }
143
- finally { if (e_1) throw e_1.error; }
144
76
  }
145
77
  collectedActions.clear();
146
78
  },
147
- _a;
79
+ };
148
80
  },
149
81
  });
150
82
  //# sourceMappingURL=avoid-duplicate-actions-in-reducer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-duplicate-actions-in-reducer.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-duplicate-actions-in-reducer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAqE;AAExD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAClE,QAAA,qCAAqC,GAChD,uCAAuC,CAAC;AAQ1C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;YAC1D,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,sCAA8B,IAC7B,gEAAgE;YAClE,GAAC,6CAAqC,IAAG,0BAA0B;eACpE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd,IAAM,UAAU,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QAC3C,IAAM,gBAAgB,GAAG,IAAI,GAAG,EAAoB,CAAC;QAErD;YACE,GAAC,UAAG,qBAAa,uEAAoE,IAArF,UAAuF,EAItF;;oBAHC,KAAA,uBAAmB,EAAP,MAAM,QAAA;gBAIlB,IAAM,OAAO,GAAG,MAAA,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAI,EAAE,CAAC;gBACxD,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,yCAAM,OAAO,YAAE,MAAM,UAAE,CAAC;YAC1D,CAAC;YACD,GAAC,UAAG,qBAAa,UAAO,IAAxB;;;oBACE,KAAwC,IAAA,qBAAA,SAAA,gBAAgB,CAAA,kDAAA,gFAAE,CAAC;wBAAhD,IAAA,KAAA,qCAAyB,EAAxB,UAAU,QAAA,EAAE,WAAW,QAAA;wBACjC,IAAI,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;4BAC5B,MAAM;wBACR,CAAC;gDAEU,IAAI;4BACb,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI,MAAA;gCACJ,SAAS,EAAE,sCAA8B;gCACzC,IAAI,EAAE;oCACJ,UAAU,YAAA;iCACX;gCACD,OAAO,EAAE;oCACP;wCACE,SAAS,EAAE,6CAAqC;wCAChD,GAAG,EAAE,UAAC,KAAK;4CACT,OAAA,IAAA,+BAAuB,EAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;wCAAvD,CAAuD;qCAC1D;iCACF;6BACF,CAAC,CAAC;;;4BAdL,KAAmB,IAAA,+BAAA,SAAA,WAAW,CAAA,CAAA,wCAAA;gCAAzB,IAAM,IAAI,wBAAA;wCAAJ,IAAI;6BAed;;;;;;;;;oBACH,CAAC;;;;;;;;;gBAED,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAC3B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { createReducer, getNodeToCommaRemoveFix } from '../../utils';\n\nexport const avoidDuplicateActionsInReducer = 'avoidDuplicateActionsInReducer';\nexport const avoidDuplicateActionsInReducerSuggest =\n 'avoidDuplicateActionsInReducerSuggest';\n\ntype MessageIds =\n | typeof avoidDuplicateActionsInReducer\n | typeof avoidDuplicateActionsInReducerSuggest;\ntype Options = readonly [];\ntype Action = TSESTree.Identifier & { parent: TSESTree.CallExpression };\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'A `Reducer` should handle an `Action` once.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [avoidDuplicateActionsInReducer]:\n 'The `Reducer` handles a duplicate `Action` `{{ actionName }}`.',\n [avoidDuplicateActionsInReducerSuggest]: 'Remove this duplication.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const collectedActions = new Map<string, Action[]>();\n\n return {\n [`${createReducer} > CallExpression[callee.name='on'][arguments.0.type='Identifier']`]({\n arguments: [action],\n }: TSESTree.CallExpression & {\n arguments: Action[];\n }) {\n const actions = collectedActions.get(action.name) ?? [];\n collectedActions.set(action.name, [...actions, action]);\n },\n [`${createReducer}:exit`]() {\n for (const [actionName, identifiers] of collectedActions) {\n if (identifiers.length <= 1) {\n break;\n }\n\n for (const node of identifiers) {\n context.report({\n node,\n messageId: avoidDuplicateActionsInReducer,\n data: {\n actionName,\n },\n suggest: [\n {\n messageId: avoidDuplicateActionsInReducerSuggest,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(sourceCode, fixer, node.parent),\n },\n ],\n });\n }\n }\n\n collectedActions.clear();\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-duplicate-actions-in-reducer.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-duplicate-actions-in-reducer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAqE;AAExD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAClE,QAAA,qCAAqC,GAChD,uCAAuC,CAAC;AAQ1C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;SAC3D;QACD,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B,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { createReducer, getNodeToCommaRemoveFix } from '../../utils';\n\nexport const avoidDuplicateActionsInReducer = 'avoidDuplicateActionsInReducer';\nexport const avoidDuplicateActionsInReducerSuggest =\n 'avoidDuplicateActionsInReducerSuggest';\n\ntype MessageIds =\n | typeof avoidDuplicateActionsInReducer\n | typeof avoidDuplicateActionsInReducerSuggest;\ntype Options = readonly [];\ntype Action = TSESTree.Identifier & { parent: TSESTree.CallExpression };\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'A `Reducer` should handle an `Action` once.',\n },\n schema: [],\n messages: {\n [avoidDuplicateActionsInReducer]:\n 'The `Reducer` handles a duplicate `Action` `{{ actionName }}`.',\n [avoidDuplicateActionsInReducerSuggest]: 'Remove this duplication.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const collectedActions = new Map<string, Action[]>();\n\n return {\n [`${createReducer} > CallExpression[callee.name='on'][arguments.0.type='Identifier']`]({\n arguments: [action],\n }: TSESTree.CallExpression & {\n arguments: Action[];\n }) {\n const actions = collectedActions.get(action.name) ?? [];\n collectedActions.set(action.name, [...actions, action]);\n },\n [`${createReducer}:exit`]() {\n for (const [actionName, identifiers] of collectedActions) {\n if (identifiers.length <= 1) {\n break;\n }\n\n for (const node of identifiers) {\n context.report({\n node,\n messageId: avoidDuplicateActionsInReducer,\n data: {\n actionName,\n },\n suggest: [\n {\n messageId: avoidDuplicateActionsInReducerSuggest,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(sourceCode, fixer, node.parent),\n },\n ],\n });\n }\n }\n\n collectedActions.clear();\n },\n };\n },\n});\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const messageId = "avoidMapppingSelectors";
2
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidMapppingSelectors", readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
3
+ export default _default;
@@ -22,13 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var _a;
26
25
  Object.defineProperty(exports, "__esModule", { value: true });
27
26
  exports.messageId = void 0;
28
- var eslint_etc_1 = require("eslint-etc");
29
- var path = __importStar(require("path"));
30
- var rule_creator_1 = require("../../rule-creator");
31
- var utils_1 = require("../../utils");
27
+ const path = __importStar(require("path"));
28
+ const rule_creator_1 = require("../../rule-creator");
29
+ const utils_1 = require("../../utils");
32
30
  exports.messageId = 'avoidMapppingSelectors';
33
31
  exports.default = (0, rule_creator_1.createRule)({
34
32
  name: path.parse(__filename).name,
@@ -37,28 +35,26 @@ exports.default = (0, rule_creator_1.createRule)({
37
35
  ngrxModule: 'store',
38
36
  docs: {
39
37
  description: 'Avoid mapping logic outside the selector level.',
40
- recommended: 'warn',
41
38
  },
42
39
  schema: [],
43
- messages: (_a = {},
44
- _a[exports.messageId] = 'Map logic at the selector level instead.',
45
- _a),
40
+ messages: {
41
+ [exports.messageId]: 'Map logic at the selector level instead.',
42
+ },
46
43
  },
47
44
  defaultOptions: [],
48
- create: function (context) {
49
- var _a;
50
- var _b = (0, utils_1.getNgRxStores)(context).identifiers, identifiers = _b === void 0 ? [] : _b;
51
- var storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
45
+ create: (context) => {
46
+ const { identifiers = [] } = (0, utils_1.getNgRxStores)(context);
47
+ const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
52
48
  if (!storeNames) {
53
49
  return {};
54
50
  }
55
- var pipeWithSelectAndMapSelector = "".concat((0, utils_1.pipeExpression)(storeNames), ":has(CallExpression[callee.name='select'] ~ CallExpression[callee.name='map'])");
56
- var selectSelector = "".concat((0, utils_1.namedCallableExpression)(storeNames), "[callee.object.callee.property.name='select']");
51
+ const pipeWithSelectAndMapSelector = `${(0, utils_1.pipeExpression)(storeNames)}:has(CallExpression[callee.name='select'] ~ CallExpression[callee.name='map'])`;
52
+ const selectSelector = `${(0, utils_1.namedCallableExpression)(storeNames)}[callee.object.callee.property.name='select']`;
57
53
  function isInCreateEffect(node) {
58
- var parent = node.parent;
54
+ let parent = node.parent;
59
55
  while (parent) {
60
- if ((0, eslint_etc_1.isCallExpression)(parent) &&
61
- (0, eslint_etc_1.isIdentifier)(parent.callee) &&
56
+ if ((0, utils_1.isCallExpression)(parent) &&
57
+ (0, utils_1.isIdentifier)(parent.callee) &&
62
58
  parent.callee.name === 'createEffect') {
63
59
  return true;
64
60
  }
@@ -66,13 +62,13 @@ exports.default = (0, rule_creator_1.createRule)({
66
62
  }
67
63
  return false;
68
64
  }
69
- var pipeHasThisExpression = false;
70
- var selectorQuery = ":matches(".concat(selectSelector, ", ").concat(pipeWithSelectAndMapSelector, ")");
71
- return _a = {},
72
- _a["".concat(selectorQuery, " > CallExpression:has(ThisExpression)")] = function (node) {
65
+ let pipeHasThisExpression = false;
66
+ const selectorQuery = `:matches(${selectSelector}, ${pipeWithSelectAndMapSelector})`;
67
+ return {
68
+ [`${selectorQuery} > CallExpression:has(ThisExpression)`](_node) {
73
69
  pipeHasThisExpression = true;
74
70
  },
75
- _a["".concat(selectorQuery, "[callee.property.name=pipe]:exit")] = function (node) {
71
+ [`${selectorQuery}[callee.property.name=pipe]:exit`](node) {
76
72
  if (pipeHasThisExpression) {
77
73
  pipeHasThisExpression = false;
78
74
  return;
@@ -80,12 +76,10 @@ exports.default = (0, rule_creator_1.createRule)({
80
76
  if (isInCreateEffect(node)) {
81
77
  return;
82
78
  }
83
- var operators = node.arguments;
84
- var mapOperator = operators.find(function (operator) {
85
- return (0, eslint_etc_1.isCallExpression)(operator) &&
86
- (0, eslint_etc_1.isIdentifier)(operator.callee) &&
87
- operator.callee.name === 'map';
88
- });
79
+ const operators = node.arguments;
80
+ const mapOperator = operators.find((operator) => (0, utils_1.isCallExpression)(operator) &&
81
+ (0, utils_1.isIdentifier)(operator.callee) &&
82
+ operator.callee.name === 'map');
89
83
  if (mapOperator) {
90
84
  context.report({
91
85
  node: mapOperator,
@@ -93,7 +87,7 @@ exports.default = (0, rule_creator_1.createRule)({
93
87
  });
94
88
  }
95
89
  },
96
- _a;
90
+ };
97
91
  },
98
92
  });
99
93
  //# sourceMappingURL=avoid-mapping-selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-mapping-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-mapping-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA4D;AAC5D,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;YAC9D,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IAAG,0CAA0C;eACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;QACpD,IAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,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MAAM,CAAC,IAAI,KAAK,KAAK;gBAF9B,CAE8B,CACjC,CAAC;gBACF,IAAI,WAAW,EAAE,CAAC;oBAChB,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,WAAW;wBACjB,SAAS,mBAAA;qBACV,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { isCallExpression, isIdentifier } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n isMemberExpression,\n namedCallableExpression,\n pipeExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidMapppingSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Avoid mapping logic outside the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Map logic at the selector level instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeWithSelectAndMapSelector = `${pipeExpression(\n storeNames\n )}:has(CallExpression[callee.name='select'] ~ CallExpression[callee.name='map'])` as const;\n const selectSelector = `${namedCallableExpression(\n storeNames\n )}[callee.object.callee.property.name='select']` as const;\n\n function isInCreateEffect(node: TSESTree.CallExpression) {\n let parent = node.parent;\n while (parent) {\n if (\n isCallExpression(parent) &&\n isIdentifier(parent.callee) &&\n parent.callee.name === 'createEffect'\n ) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n }\n\n let pipeHasThisExpression = false;\n\n const selectorQuery = `:matches(${selectSelector}, ${pipeWithSelectAndMapSelector})`;\n return {\n [`${selectorQuery} > CallExpression:has(ThisExpression)`](\n node: TSESTree.CallExpression\n ) {\n pipeHasThisExpression = true;\n },\n [`${selectorQuery}[callee.property.name=pipe]:exit`](\n node: TSESTree.CallExpression\n ) {\n if (pipeHasThisExpression) {\n pipeHasThisExpression = false;\n return;\n }\n\n if (isInCreateEffect(node)) {\n return;\n }\n\n const operators = node.arguments;\n const mapOperator = operators.find(\n (operator) =>\n isCallExpression(operator) &&\n isIdentifier(operator.callee) &&\n operator.callee.name === 'map'\n );\n if (mapOperator) {\n context.report({\n node: mapOperator,\n messageId,\n });\n }\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-mapping-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-mapping-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAOqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;SAC/D;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EAAE,0CAA0C;SACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;QACpD,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC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IAAI,KAAK,KAAK,CACjC,CAAC;gBACF,IAAI,WAAW,EAAE,CAAC;oBAChB,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,WAAW;wBACjB,SAAS,EAAT,iBAAS;qBACV,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n isCallExpression,\n isIdentifier,\n namedCallableExpression,\n pipeExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidMapppingSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Avoid mapping logic outside the selector level.',\n },\n schema: [],\n messages: {\n [messageId]: 'Map logic at the selector level instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeWithSelectAndMapSelector = `${pipeExpression(\n storeNames\n )}:has(CallExpression[callee.name='select'] ~ CallExpression[callee.name='map'])` as const;\n const selectSelector = `${namedCallableExpression(\n storeNames\n )}[callee.object.callee.property.name='select']` as const;\n\n function isInCreateEffect(node: TSESTree.CallExpression) {\n let parent: TSESTree.Node | undefined = node.parent;\n while (parent) {\n if (\n isCallExpression(parent) &&\n isIdentifier(parent.callee) &&\n parent.callee.name === 'createEffect'\n ) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n }\n\n let pipeHasThisExpression = false;\n\n const selectorQuery = `:matches(${selectSelector}, ${pipeWithSelectAndMapSelector})`;\n return {\n [`${selectorQuery} > CallExpression:has(ThisExpression)`](\n _node: TSESTree.CallExpression\n ) {\n pipeHasThisExpression = true;\n },\n [`${selectorQuery}[callee.property.name=pipe]:exit`](\n node: TSESTree.CallExpression\n ) {\n if (pipeHasThisExpression) {\n pipeHasThisExpression = false;\n return;\n }\n\n if (isInCreateEffect(node)) {\n return;\n }\n\n const operators = node.arguments;\n const mapOperator = operators.find(\n (operator) =>\n isCallExpression(operator) &&\n isIdentifier(operator.callee) &&\n operator.callee.name === 'map'\n );\n if (mapOperator) {\n context.report({\n node: mapOperator,\n messageId,\n });\n }\n },\n };\n },\n});\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const messageId = "goodActionHygiene";
2
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"goodActionHygiene", readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
3
+ export default _default;