@ngrx/eslint-plugin 18.0.0-beta.1 → 18.0.0-rc.1

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 +4 -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 +18 -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 +13 -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 +153 -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 +35 -0
  88. package/src/rules/index.js +74 -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 +10 -11
  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
@@ -22,12 +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 path = __importStar(require("path"));
29
- var rule_creator_1 = require("../../rule-creator");
30
- 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");
31
30
  exports.messageId = 'useEffectsLifecycleInterface';
32
31
  exports.default = (0, rule_creator_1.createRule)({
33
32
  name: path.parse(__filename).name,
@@ -36,53 +35,51 @@ exports.default = (0, rule_creator_1.createRule)({
36
35
  ngrxModule: 'effects',
37
36
  docs: {
38
37
  description: 'Ensures classes implement lifecycle interfaces corresponding to the declared lifecycle methods.',
39
- recommended: 'warn',
40
38
  },
41
39
  fixable: 'code',
42
40
  schema: [],
43
- messages: (_a = {},
44
- _a[exports.messageId] = 'Lifecycle interface `{{ interfaceName }}` should be implemented for method `{{ methodName }}`.',
45
- _a),
41
+ messages: {
42
+ [exports.messageId]: 'Lifecycle interface `{{ interfaceName }}` should be implemented for method `{{ methodName }}`.',
43
+ },
46
44
  },
47
45
  defaultOptions: [],
48
- create: function (context) {
49
- var _a;
50
- var lifecycleMapper = {
46
+ create: (context) => {
47
+ const lifecycleMapper = {
51
48
  ngrxOnIdentifyEffects: 'OnIdentifyEffects',
52
49
  ngrxOnInitEffects: 'OnInitEffects',
53
50
  ngrxOnRunEffects: 'OnRunEffects',
54
51
  };
55
- var lifecyclesPattern = Object.keys(lifecycleMapper).join('|');
56
- return _a = {},
57
- _a["ClassDeclaration > ClassBody > MethodDefinition > Identifier[name=/".concat(lifecyclesPattern, "/]")] = function (node) {
58
- var classDeclaration = node.parent.parent.parent;
59
- var methodName = node.name;
60
- var interfaceName = lifecycleMapper[methodName];
52
+ const lifecyclesPattern = Object.keys(lifecycleMapper).join('|');
53
+ return {
54
+ [`ClassDeclaration > ClassBody > MethodDefinition > Identifier[name=/${lifecyclesPattern}/]`](node) {
55
+ const classDeclaration = node.parent.parent.parent;
56
+ const methodName = node.name;
57
+ const interfaceName = lifecycleMapper[methodName];
61
58
  if ((0, utils_1.getInterface)(classDeclaration, interfaceName)) {
62
59
  return;
63
60
  }
64
61
  context.report({
65
- fix: function (fixer) {
66
- var _a = (0, utils_1.getImplementsSchemaFixer)(classDeclaration, interfaceName), implementsNodeReplace = _a.implementsNodeReplace, implementsTextReplace = _a.implementsTextReplace;
62
+ fix: (fixer) => {
63
+ const { implementsNodeReplace, implementsTextReplace } = (0, utils_1.getImplementsSchemaFixer)(classDeclaration, interfaceName);
67
64
  return [
68
65
  fixer.insertTextAfter(implementsNodeReplace, implementsTextReplace),
69
66
  ].concat((0, utils_1.getImportAddFix)({
70
67
  compatibleWithTypeOnlyImport: true,
71
- fixer: fixer,
68
+ fixer,
72
69
  importName: interfaceName,
73
70
  moduleName: utils_1.NGRX_MODULE_PATHS.effects,
74
71
  node: classDeclaration,
75
72
  }));
76
73
  },
77
- node: node,
74
+ node,
78
75
  messageId: exports.messageId,
79
76
  data: {
80
- interfaceName: interfaceName,
81
- methodName: methodName,
77
+ interfaceName,
78
+ methodName,
82
79
  },
83
80
  });
84
81
  },
85
- _a;
82
+ };
86
83
  },
87
84
  });
88
85
  //# sourceMappingURL=use-effects-lifecycle-interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-effects-lifecycle-interface.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/use-effects-lifecycle-interface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,SAAS,GAAG,8BAA8B,CAAC;AAKxD,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,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EACT,iGAAiG;YACnG,WAAW,EAAE,MAAM;SACpB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,gGAAgG;eACnG;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd,IAAM,eAAe,GAAG;YACtB,qBAAqB,EAAE,mBAAmB;YAC1C,iBAAiB,EAAE,eAAe;YAClC,gBAAgB,EAAE,cAAc;SACxB,CAAC;QACX,IAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEjE;YACE,GAAC,6EAAsE,iBAAiB,OAAI,IAA5F,UACE,IAKC;gBAED,IAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;gBACnD,IAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;gBAC7B,IAAM,aAAa,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;gBAElD,IAAI,IAAA,oBAAY,EAAC,gBAAgB,EAAE,aAAa,CAAC,EAAE,CAAC;oBAClD,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,GAAG,EAAE,UAAC,KAAK;wBACH,IAAA,KACJ,IAAA,gCAAwB,EAAC,gBAAgB,EAAE,aAAa,CAAC,EADnD,qBAAqB,2BAAA,EAAE,qBAAqB,2BACO,CAAC;wBAC5D,OAAO;4BACL,KAAK,CAAC,eAAe,CACnB,qBAAqB,EACrB,qBAAqB,CACtB;yBACF,CAAC,MAAM,CACN,IAAA,uBAAe,EAAC;4BACd,4BAA4B,EAAE,IAAI;4BAClC,KAAK,OAAA;4BACL,UAAU,EAAE,aAAa;4BACzB,UAAU,EAAE,yBAAiB,CAAC,OAAO;4BACrC,IAAI,EAAE,gBAAgB;yBACvB,CAAC,CACH,CAAC;oBACJ,CAAC;oBACD,IAAI,MAAA;oBACJ,SAAS,mBAAA;oBACT,IAAI,EAAE;wBACJ,aAAa,eAAA;wBACb,UAAU,YAAA;qBACX;iBACF,CAAC,CAAC;YACL,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 getImplementsSchemaFixer,\n getImportAddFix,\n getInterface,\n NGRX_MODULE_PATHS,\n} from '../../utils';\n\nexport const messageId = 'useEffectsLifecycleInterface';\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: 'effects',\n docs: {\n description:\n 'Ensures classes implement lifecycle interfaces corresponding to the declared lifecycle methods.',\n recommended: 'warn',\n },\n fixable: 'code',\n schema: [],\n messages: {\n [messageId]:\n 'Lifecycle interface `{{ interfaceName }}` should be implemented for method `{{ methodName }}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const lifecycleMapper = {\n ngrxOnIdentifyEffects: 'OnIdentifyEffects',\n ngrxOnInitEffects: 'OnInitEffects',\n ngrxOnRunEffects: 'OnRunEffects',\n } as const;\n const lifecyclesPattern = Object.keys(lifecycleMapper).join('|');\n\n return {\n [`ClassDeclaration > ClassBody > MethodDefinition > Identifier[name=/${lifecyclesPattern}/]`](\n node: TSESTree.Identifier & {\n name: keyof typeof lifecycleMapper;\n parent: TSESTree.MethodDefinition & {\n parent: TSESTree.ClassBody & { parent: TSESTree.ClassDeclaration };\n };\n }\n ) {\n const classDeclaration = node.parent.parent.parent;\n const methodName = node.name;\n const interfaceName = lifecycleMapper[methodName];\n\n if (getInterface(classDeclaration, interfaceName)) {\n return;\n }\n\n context.report({\n fix: (fixer) => {\n const { implementsNodeReplace, implementsTextReplace } =\n getImplementsSchemaFixer(classDeclaration, interfaceName);\n return [\n fixer.insertTextAfter(\n implementsNodeReplace,\n implementsTextReplace\n ),\n ].concat(\n getImportAddFix({\n compatibleWithTypeOnlyImport: true,\n fixer,\n importName: interfaceName,\n moduleName: NGRX_MODULE_PATHS.effects,\n node: classDeclaration,\n })\n );\n },\n node,\n messageId,\n data: {\n interfaceName,\n methodName,\n },\n });\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"use-effects-lifecycle-interface.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/use-effects-lifecycle-interface.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAKqB;AAER,QAAA,SAAS,GAAG,8BAA8B,CAAC;AAKxD,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,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EACT,iGAAiG;SACpG;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,gGAAgG;SACnG;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,eAAe,GAAG;YACtB,qBAAqB,EAAE,mBAAmB;YAC1C,iBAAiB,EAAE,eAAe;YAClC,gBAAgB,EAAE,cAAc;SACxB,CAAC;QACX,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEjE,OAAO;YACL,CAAC,sEAAsE,iBAAiB,IAAI,CAAC,CAC3F,IAKC;gBAED,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;gBACnD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;gBAC7B,MAAM,aAAa,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;gBAElD,IAAI,IAAA,oBAAY,EAAC,gBAAgB,EAAE,aAAa,CAAC,EAAE,CAAC;oBAClD,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;wBACb,MAAM,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,GACpD,IAAA,gCAAwB,EAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC;wBAC5D,OAAO;4BACL,KAAK,CAAC,eAAe,CACnB,qBAAqB,EACrB,qBAAqB,CACtB;yBACF,CAAC,MAAM,CACN,IAAA,uBAAe,EAAC;4BACd,4BAA4B,EAAE,IAAI;4BAClC,KAAK;4BACL,UAAU,EAAE,aAAa;4BACzB,UAAU,EAAE,yBAAiB,CAAC,OAAO;4BACrC,IAAI,EAAE,gBAAgB;yBACvB,CAAC,CACH,CAAC;oBACJ,CAAC;oBACD,IAAI;oBACJ,SAAS,EAAT,iBAAS;oBACT,IAAI,EAAE;wBACJ,aAAa;wBACb,UAAU;qBACX;iBACF,CAAC,CAAC;YACL,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 getImplementsSchemaFixer,\n getImportAddFix,\n getInterface,\n NGRX_MODULE_PATHS,\n} from '../../utils';\n\nexport const messageId = 'useEffectsLifecycleInterface';\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: 'effects',\n docs: {\n description:\n 'Ensures classes implement lifecycle interfaces corresponding to the declared lifecycle methods.',\n },\n fixable: 'code',\n schema: [],\n messages: {\n [messageId]:\n 'Lifecycle interface `{{ interfaceName }}` should be implemented for method `{{ methodName }}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const lifecycleMapper = {\n ngrxOnIdentifyEffects: 'OnIdentifyEffects',\n ngrxOnInitEffects: 'OnInitEffects',\n ngrxOnRunEffects: 'OnRunEffects',\n } as const;\n const lifecyclesPattern = Object.keys(lifecycleMapper).join('|');\n\n return {\n [`ClassDeclaration > ClassBody > MethodDefinition > Identifier[name=/${lifecyclesPattern}/]`](\n node: TSESTree.Identifier & {\n name: keyof typeof lifecycleMapper;\n parent: TSESTree.MethodDefinition & {\n parent: TSESTree.ClassBody & { parent: TSESTree.ClassDeclaration };\n };\n }\n ) {\n const classDeclaration = node.parent.parent.parent;\n const methodName = node.name;\n const interfaceName = lifecycleMapper[methodName];\n\n if (getInterface(classDeclaration, interfaceName)) {\n return;\n }\n\n context.report({\n fix: (fixer) => {\n const { implementsNodeReplace, implementsTextReplace } =\n getImplementsSchemaFixer(classDeclaration, interfaceName);\n return [\n fixer.insertTextAfter(\n implementsNodeReplace,\n implementsTextReplace\n ),\n ].concat(\n getImportAddFix({\n compatibleWithTypeOnlyImport: true,\n fixer,\n importName: interfaceName,\n moduleName: NGRX_MODULE_PATHS.effects,\n node: classDeclaration,\n })\n );\n },\n node,\n messageId,\n data: {\n interfaceName,\n methodName,\n },\n });\n },\n };\n },\n});\n"]}
@@ -0,0 +1,35 @@
1
+ export declare const rules: {
2
+ 'avoid-combining-component-store-selectors': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidCombiningComponentStoreSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
3
+ 'avoid-mapping-component-store-selectors': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidMappingComponentStoreSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
4
+ 'updater-explicit-return-type': import("@typescript-eslint/utils/ts-eslint").RuleModule<"updaterExplicitReturnType", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
5
+ 'avoid-cyclic-effects': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidCyclicEffects", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
6
+ 'no-dispatch-in-effects': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noDispatchInEffects" | "noDispatchInEffectsSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
7
+ 'no-effects-in-providers': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noEffectsInProviders", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
8
+ 'no-multiple-actions-in-effects': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noMultipleActionsInEffects", readonly unknown[], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
9
+ 'prefer-action-creator-in-of-type': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferActionCreatorInOfType", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
10
+ 'prefer-effect-callback-in-block-statement': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferEffectCallbackInBlockStatement", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
11
+ 'use-effects-lifecycle-interface': import("@typescript-eslint/utils/ts-eslint").RuleModule<"useEffectsLifecycleInterface", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
12
+ 'avoid-combining-selectors': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidCombiningSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
13
+ 'avoid-dispatching-multiple-actions-sequentially': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidDispatchingMultipleActionsSequentially", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
14
+ 'avoid-duplicate-actions-in-reducer': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidDuplicateActionsInReducer" | "avoidDuplicateActionsInReducerSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
15
+ 'avoid-mapping-selectors': import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidMapppingSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
16
+ 'good-action-hygiene': import("@typescript-eslint/utils/ts-eslint").RuleModule<"goodActionHygiene", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
17
+ 'no-multiple-global-stores': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noMultipleGlobalStores" | "noMultipleGlobalStoresSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
18
+ 'no-reducer-in-key-names': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noReducerInKeyNames" | "noReducerInKeyNamesSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
19
+ 'no-store-subscription': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noStoreSubscription", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
20
+ 'no-typed-global-store': import("@typescript-eslint/utils/ts-eslint").RuleModule<"noTypedStore" | "noTypedStoreSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
21
+ 'on-function-explicit-return-type': import("@typescript-eslint/utils/ts-eslint").RuleModule<"onFunctionExplicitReturnType" | "onFunctionExplicitReturnTypeSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
22
+ 'prefer-action-creator': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferActionCreator", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
23
+ 'prefer-action-creator-in-dispatch': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferActionCreatorInDispatch", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
24
+ 'prefer-inline-action-props': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferInlineActionProps" | "preferInlineActionPropsSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
25
+ 'prefer-one-generic-in-create-for-feature-selector': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferOneGenericInCreateForFeatureSelector" | "preferOneGenericInCreateForFeatureSelectorSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
26
+ 'prefer-selector-in-select': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferSelectorInSelect", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
27
+ 'prefix-selectors-with-select': import("@typescript-eslint/utils/ts-eslint").RuleModule<"prefixSelectorsWithSelect" | "prefixSelectorsWithSelectSuggest", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
28
+ 'select-style': import("@typescript-eslint/utils/ts-eslint").RuleModule<"operator" | "method", readonly ["operator" | "method"], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
29
+ 'use-consistent-global-store-name': import("@typescript-eslint/utils/ts-eslint").RuleModule<"useConsistentGlobalStoreName" | "useConsistentGlobalStoreNameSuggest", readonly [string], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
30
+ 'prefer-concat-latest-from': import("@typescript-eslint/utils/ts-eslint").RuleModule<"preferConcatLatestFrom", readonly [{
31
+ readonly strict: boolean;
32
+ }], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
33
+ 'signal-state-no-arrays-at-root-level': import("@typescript-eslint/utils/ts-eslint").RuleModule<"signalStateNoArraysAtRootLevel", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
34
+ 'with-state-no-arrays-at-root-level': import("@typescript-eslint/utils/ts-eslint").RuleModule<"withStateNoArraysAtRootLevel", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
35
+ };
@@ -1,59 +1,80 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- var desc = Object.getOwnPropertyDescriptor(m, k);
16
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
- desc = { enumerable: true, get: function() { return m[k]; } };
18
- }
19
- Object.defineProperty(o, k2, desc);
20
- }) : (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- o[k2] = m[k];
23
- }));
24
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
- Object.defineProperty(o, "default", { enumerable: true, value: v });
26
- }) : function(o, v) {
27
- o["default"] = v;
28
- });
29
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
- __setModuleDefault(result, mod);
34
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
35
4
  };
36
5
  Object.defineProperty(exports, "__esModule", { value: true });
37
6
  exports.rules = void 0;
38
- var path = __importStar(require("path"));
39
- var utils_1 = require("../utils");
40
- // Copied from https://github.com/jest-community/eslint-plugin-jest/blob/main/src/index.ts
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
- var interopRequireDefault = function (obj) {
43
- return (obj === null || obj === void 0 ? void 0 : obj.__esModule) ? obj : { default: obj };
44
- };
45
- var importDefault = function (moduleName) {
46
- // eslint-disable-next-line @typescript-eslint/no-var-requires
47
- return interopRequireDefault(require(moduleName)).default;
7
+ // component-store
8
+ const avoid_combining_component_store_selectors_1 = __importDefault(require("./component-store/avoid-combining-component-store-selectors"));
9
+ const avoid_mapping_component_store_selectors_1 = __importDefault(require("./component-store/avoid-mapping-component-store-selectors"));
10
+ const updater_explicit_return_type_1 = __importDefault(require("./component-store/updater-explicit-return-type"));
11
+ // effects
12
+ const avoid_cyclic_effects_1 = __importDefault(require("./effects/avoid-cyclic-effects"));
13
+ const no_dispatch_in_effects_1 = __importDefault(require("./effects/no-dispatch-in-effects"));
14
+ const no_effects_in_providers_1 = __importDefault(require("./effects/no-effects-in-providers"));
15
+ const no_multiple_actions_in_effects_1 = __importDefault(require("./effects/no-multiple-actions-in-effects"));
16
+ const prefer_action_creator_in_of_type_1 = __importDefault(require("./effects/prefer-action-creator-in-of-type"));
17
+ const prefer_effect_callback_in_block_statement_1 = __importDefault(require("./effects/prefer-effect-callback-in-block-statement"));
18
+ const use_effects_lifecycle_interface_1 = __importDefault(require("./effects/use-effects-lifecycle-interface"));
19
+ // store
20
+ const avoid_combining_selectors_1 = __importDefault(require("./store/avoid-combining-selectors"));
21
+ const avoid_dispatching_multiple_actions_sequentially_1 = __importDefault(require("./store/avoid-dispatching-multiple-actions-sequentially"));
22
+ const avoid_duplicate_actions_in_reducer_1 = __importDefault(require("./store/avoid-duplicate-actions-in-reducer"));
23
+ const avoid_mapping_selectors_1 = __importDefault(require("./store/avoid-mapping-selectors"));
24
+ const good_action_hygiene_1 = __importDefault(require("./store/good-action-hygiene"));
25
+ const no_multiple_global_stores_1 = __importDefault(require("./store/no-multiple-global-stores"));
26
+ const no_reducer_in_key_names_1 = __importDefault(require("./store/no-reducer-in-key-names"));
27
+ const no_store_subscription_1 = __importDefault(require("./store/no-store-subscription"));
28
+ const no_typed_global_store_1 = __importDefault(require("./store/no-typed-global-store"));
29
+ const on_function_explicit_return_type_1 = __importDefault(require("./store/on-function-explicit-return-type"));
30
+ const prefer_action_creator_1 = __importDefault(require("./store/prefer-action-creator"));
31
+ const prefer_action_creator_in_dispatch_1 = __importDefault(require("./store/prefer-action-creator-in-dispatch"));
32
+ const prefer_inline_action_props_1 = __importDefault(require("./store/prefer-inline-action-props"));
33
+ const prefer_one_generic_in_create_for_feature_selector_1 = __importDefault(require("./store/prefer-one-generic-in-create-for-feature-selector"));
34
+ const prefer_selector_in_select_1 = __importDefault(require("./store/prefer-selector-in-select"));
35
+ const prefix_selectors_with_select_1 = __importDefault(require("./store/prefix-selectors-with-select"));
36
+ const select_style_1 = __importDefault(require("./store/select-style"));
37
+ const use_consistent_global_store_name_1 = __importDefault(require("./store/use-consistent-global-store-name"));
38
+ // operators
39
+ const prefer_concat_latest_from_1 = __importDefault(require("./operators/prefer-concat-latest-from"));
40
+ const signal_state_no_arrays_at_root_level_1 = __importDefault(require("./signals/signal-state-no-arrays-at-root-level"));
41
+ const with_state_no_arrays_at_root_level_1 = __importDefault(require("./signals/with-state-no-arrays-at-root-level"));
42
+ exports.rules = {
43
+ // component-store
44
+ 'avoid-combining-component-store-selectors': avoid_combining_component_store_selectors_1.default,
45
+ 'avoid-mapping-component-store-selectors': avoid_mapping_component_store_selectors_1.default,
46
+ 'updater-explicit-return-type': updater_explicit_return_type_1.default,
47
+ //effects
48
+ 'avoid-cyclic-effects': avoid_cyclic_effects_1.default,
49
+ 'no-dispatch-in-effects': no_dispatch_in_effects_1.default,
50
+ 'no-effects-in-providers': no_effects_in_providers_1.default,
51
+ 'no-multiple-actions-in-effects': no_multiple_actions_in_effects_1.default,
52
+ 'prefer-action-creator-in-of-type': prefer_action_creator_in_of_type_1.default,
53
+ 'prefer-effect-callback-in-block-statement': prefer_effect_callback_in_block_statement_1.default,
54
+ 'use-effects-lifecycle-interface': use_effects_lifecycle_interface_1.default,
55
+ // store
56
+ 'avoid-combining-selectors': avoid_combining_selectors_1.default,
57
+ 'avoid-dispatching-multiple-actions-sequentially': avoid_dispatching_multiple_actions_sequentially_1.default,
58
+ 'avoid-duplicate-actions-in-reducer': avoid_duplicate_actions_in_reducer_1.default,
59
+ 'avoid-mapping-selectors': avoid_mapping_selectors_1.default,
60
+ 'good-action-hygiene': good_action_hygiene_1.default,
61
+ 'no-multiple-global-stores': no_multiple_global_stores_1.default,
62
+ 'no-reducer-in-key-names': no_reducer_in_key_names_1.default,
63
+ 'no-store-subscription': no_store_subscription_1.default,
64
+ 'no-typed-global-store': no_typed_global_store_1.default,
65
+ 'on-function-explicit-return-type': on_function_explicit_return_type_1.default,
66
+ 'prefer-action-creator': prefer_action_creator_1.default,
67
+ 'prefer-action-creator-in-dispatch': prefer_action_creator_in_dispatch_1.default,
68
+ 'prefer-inline-action-props': prefer_inline_action_props_1.default,
69
+ 'prefer-one-generic-in-create-for-feature-selector': prefer_one_generic_in_create_for_feature_selector_1.default,
70
+ 'prefer-selector-in-select': prefer_selector_in_select_1.default,
71
+ 'prefix-selectors-with-select': prefix_selectors_with_select_1.default,
72
+ 'select-style': select_style_1.default,
73
+ 'use-consistent-global-store-name': use_consistent_global_store_name_1.default,
74
+ // operators
75
+ 'prefer-concat-latest-from': prefer_concat_latest_from_1.default,
76
+ // signals
77
+ 'signal-state-no-arrays-at-root-level': signal_state_no_arrays_at_root_level_1.default,
78
+ 'with-state-no-arrays-at-root-level': with_state_no_arrays_at_root_level_1.default,
48
79
  };
49
- var rulesDir = __dirname;
50
- var excludedFiles = ['index'];
51
- exports.rules = Array.from((0, utils_1.traverseFolder)(rulesDir))
52
- .filter(function (rule) { return !excludedFiles.includes(rule.file); })
53
- .reduce(function (allRules, rule) {
54
- var _a;
55
- var ruleModule = importDefault(rule.path);
56
- ruleModule.meta.ngrxModule = path.basename(path.dirname(rule.path));
57
- return __assign(__assign({}, allRules), (_a = {}, _a[rule.file] = ruleModule, _a));
58
- }, {});
59
80
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/rules/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA6B;AAG7B,kCAA0C;AAE1C,0FAA0F;AAE1F,8DAA8D;AAC9D,IAAM,qBAAqB,GAAG,UAAC,GAAQ;IACrC,OAAA,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,EAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE;AAAxC,CAAwC,CAAC;AAE3C,IAAM,aAAa,GAAG,UAAC,UAAkB;IACvC,8DAA8D;IAC9D,OAAA,qBAAqB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO;AAAlD,CAAkD,CAAC;AAErD,IAAM,QAAQ,GAAG,SAAS,CAAC;AAC3B,IAAM,aAAa,GAAG,CAAC,OAAO,CAAC,CAAC;AAEnB,QAAA,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAA,sBAAc,EAAC,QAAQ,CAAC,CAAC;KACtD,MAAM,CAAC,UAAC,IAAI,IAAK,OAAA,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAlC,CAAkC,CAAC;KACpD,MAAM,CAA6C,UAAC,QAAQ,EAAE,IAAI;;IACjE,IAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAA+B,CAAC;IAC1E,UAAU,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CACxC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CACT,CAAC;IACjB,6BACK,QAAQ,gBACV,IAAI,CAAC,IAAI,IAAG,UAAU,OACvB;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC","sourcesContent":["import * as path from 'path';\nimport type { NgRxRuleModule } from '../rule-creator';\nimport type { NGRX_MODULE } from '../utils';\nimport { traverseFolder } from '../utils';\n\n// Copied from https://github.com/jest-community/eslint-plugin-jest/blob/main/src/index.ts\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst interopRequireDefault = (obj: any): { default: unknown } =>\n obj?.__esModule ? obj : { default: obj };\n\nconst importDefault = (moduleName: string) =>\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n interopRequireDefault(require(moduleName)).default;\n\nconst rulesDir = __dirname;\nconst excludedFiles = ['index'];\n\nexport const rules = Array.from(traverseFolder(rulesDir))\n .filter((rule) => !excludedFiles.includes(rule.file))\n .reduce<Record<string, NgRxRuleModule<[], string>>>((allRules, rule) => {\n const ruleModule = importDefault(rule.path) as NgRxRuleModule<[], string>;\n ruleModule.meta.ngrxModule = path.basename(\n path.dirname(rule.path)\n ) as NGRX_MODULE;\n return {\n ...allRules,\n [rule.file]: ruleModule,\n };\n }, {});\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/rules/index.ts"],"names":[],"mappings":";;;;;;AAAA,kBAAkB;AAClB,4IAAgH;AAChH,wIAA4G;AAC5G,kHAAuF;AACvF,UAAU;AACV,0FAAgE;AAChE,8FAAmE;AACnE,gGAAqE;AACrE,8GAAkF;AAClF,kHAAqF;AACrF,oIAAuG;AACvG,gHAAqF;AACrF,QAAQ;AACR,kGAAwE;AACxE,8IAAkH;AAClH,oHAAwF;AACxF,8FAAoE;AACpE,sFAA4D;AAC5D,kGAAuE;AACvE,8FAAkE;AAClE,0FAAgE;AAChE,0FAA+D;AAC/D,gHAAoF;AACpF,0FAAgE;AAChE,kHAAsF;AACtF,oGAAyE;AACzE,kJAAmH;AACnH,kGAAuE;AACvE,wGAA6E;AAC7E,wEAA+C;AAC/C,gHAAoF;AACpF,YAAY;AACZ,sGAA2E;AAC3E,0HAA4F;AAC5F,sHAAwF;AAE3E,QAAA,KAAK,GAAG;IACnB,kBAAkB;IAClB,2CAA2C,EACzC,mDAAqC;IACvC,yCAAyC,EACvC,iDAAmC;IACrC,8BAA8B,EAAE,sCAAyB;IACzD,SAAS;IACT,sBAAsB,EAAE,8BAAkB;IAC1C,wBAAwB,EAAE,gCAAmB;IAC7C,yBAAyB,EAAE,iCAAoB;IAC/C,gCAAgC,EAAE,wCAA0B;IAC5D,kCAAkC,EAAE,0CAA2B;IAC/D,2CAA2C,EACzC,mDAAoC;IACtC,iCAAiC,EAAE,yCAA4B;IAC/D,QAAQ;IACR,2BAA2B,EAAE,mCAAuB;IACpD,iDAAiD,EAC/C,yDAA2C;IAC7C,oCAAoC,EAAE,4CAA8B;IACpE,yBAAyB,EAAE,iCAAqB;IAChD,qBAAqB,EAAE,6BAAiB;IACxC,2BAA2B,EAAE,mCAAsB;IACnD,yBAAyB,EAAE,iCAAmB;IAC9C,uBAAuB,EAAE,+BAAmB;IAC5C,uBAAuB,EAAE,+BAAkB;IAC3C,kCAAkC,EAAE,0CAA4B;IAChE,uBAAuB,EAAE,+BAAmB;IAC5C,mCAAmC,EAAE,2CAA6B;IAClE,4BAA4B,EAAE,oCAAuB;IACrD,mDAAmD,EACjD,2DAA0C;IAC5C,2BAA2B,EAAE,mCAAsB;IACnD,8BAA8B,EAAE,sCAAyB;IACzD,cAAc,EAAE,sBAAW;IAC3B,kCAAkC,EAAE,0CAA4B;IAChE,YAAY;IACZ,2BAA2B,EAAE,mCAAsB;IACnD,UAAU;IACV,sCAAsC,EAAE,8CAA8B;IACtE,oCAAoC,EAAE,4CAA4B;CACnE,CAAC","sourcesContent":["// component-store\nimport avoidCombiningComponentStoreSelectors from './component-store/avoid-combining-component-store-selectors';\nimport avoidMappingComponentStoreSelectors from './component-store/avoid-mapping-component-store-selectors';\nimport updaterExplicitReturnType from './component-store/updater-explicit-return-type';\n// effects\nimport avoidCyclicEffects from './effects/avoid-cyclic-effects';\nimport noDispatchInEffects from './effects/no-dispatch-in-effects';\nimport noEffectsInProviders from './effects/no-effects-in-providers';\nimport noMultipleActionsInEffects from './effects/no-multiple-actions-in-effects';\nimport preferActionCreatorInOfType from './effects/prefer-action-creator-in-of-type';\nimport preferEffectCallbackInBlockStatement from './effects/prefer-effect-callback-in-block-statement';\nimport useEffectsLifecycleInterface from './effects/use-effects-lifecycle-interface';\n// store\nimport avoidCombiningSelectors from './store/avoid-combining-selectors';\nimport avoidDispatchingMultipleActionsSequentially from './store/avoid-dispatching-multiple-actions-sequentially';\nimport avoidDuplicateActionsInReducer from './store/avoid-duplicate-actions-in-reducer';\nimport avoidMappingSelectors from './store/avoid-mapping-selectors';\nimport goodActionHygiene from './store/good-action-hygiene';\nimport noMultipleGlobalStores from './store/no-multiple-global-stores';\nimport noReducerInKeyNames from './store/no-reducer-in-key-names';\nimport noStoreSubscription from './store/no-store-subscription';\nimport noTypedGlobalStore from './store/no-typed-global-store';\nimport onFunctionExplicitReturnType from './store/on-function-explicit-return-type';\nimport preferActionCreator from './store/prefer-action-creator';\nimport preferActionCreatorInDispatch from './store/prefer-action-creator-in-dispatch';\nimport preferInlineActionProps from './store/prefer-inline-action-props';\nimport preferOneGenericInCreateForFeatureSelector from './store/prefer-one-generic-in-create-for-feature-selector';\nimport preferSelectorInSelect from './store/prefer-selector-in-select';\nimport prefixSelectorsWithSelect from './store/prefix-selectors-with-select';\nimport selectStyle from './store/select-style';\nimport useConsistentGlobalStoreName from './store/use-consistent-global-store-name';\n// operators\nimport preferConcatLatestFrom from './operators/prefer-concat-latest-from';\nimport signalStateNoArraysAtRootLevel from './signals/signal-state-no-arrays-at-root-level';\nimport withStateNoArraysAtRootLevel from './signals/with-state-no-arrays-at-root-level';\n\nexport const rules = {\n // component-store\n 'avoid-combining-component-store-selectors':\n avoidCombiningComponentStoreSelectors,\n 'avoid-mapping-component-store-selectors':\n avoidMappingComponentStoreSelectors,\n 'updater-explicit-return-type': updaterExplicitReturnType,\n //effects\n 'avoid-cyclic-effects': avoidCyclicEffects,\n 'no-dispatch-in-effects': noDispatchInEffects,\n 'no-effects-in-providers': noEffectsInProviders,\n 'no-multiple-actions-in-effects': noMultipleActionsInEffects,\n 'prefer-action-creator-in-of-type': preferActionCreatorInOfType,\n 'prefer-effect-callback-in-block-statement':\n preferEffectCallbackInBlockStatement,\n 'use-effects-lifecycle-interface': useEffectsLifecycleInterface,\n // store\n 'avoid-combining-selectors': avoidCombiningSelectors,\n 'avoid-dispatching-multiple-actions-sequentially':\n avoidDispatchingMultipleActionsSequentially,\n 'avoid-duplicate-actions-in-reducer': avoidDuplicateActionsInReducer,\n 'avoid-mapping-selectors': avoidMappingSelectors,\n 'good-action-hygiene': goodActionHygiene,\n 'no-multiple-global-stores': noMultipleGlobalStores,\n 'no-reducer-in-key-names': noReducerInKeyNames,\n 'no-store-subscription': noStoreSubscription,\n 'no-typed-global-store': noTypedGlobalStore,\n 'on-function-explicit-return-type': onFunctionExplicitReturnType,\n 'prefer-action-creator': preferActionCreator,\n 'prefer-action-creator-in-dispatch': preferActionCreatorInDispatch,\n 'prefer-inline-action-props': preferInlineActionProps,\n 'prefer-one-generic-in-create-for-feature-selector':\n preferOneGenericInCreateForFeatureSelector,\n 'prefer-selector-in-select': preferSelectorInSelect,\n 'prefix-selectors-with-select': prefixSelectorsWithSelect,\n 'select-style': selectStyle,\n 'use-consistent-global-store-name': useConsistentGlobalStoreName,\n // operators\n 'prefer-concat-latest-from': preferConcatLatestFrom,\n // signals\n 'signal-state-no-arrays-at-root-level': signalStateNoArraysAtRootLevel,\n 'with-state-no-arrays-at-root-level': withStateNoArraysAtRootLevel,\n};\n"]}
@@ -0,0 +1,7 @@
1
+ import { type TSESLint } from '@typescript-eslint/utils';
2
+ export declare const messageId = "preferConcatLatestFrom";
3
+ type Options = readonly [{
4
+ readonly strict: boolean;
5
+ }];
6
+ declare const _default: TSESLint.RuleModule<"preferConcatLatestFrom", Options, unknown, TSESLint.RuleListener>;
7
+ export default _default;
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.messageId = void 0;
27
+ const utils_1 = require("@typescript-eslint/utils");
28
+ const path = __importStar(require("path"));
29
+ const rule_creator_1 = require("../../rule-creator");
30
+ const utils_2 = require("../../utils");
31
+ exports.messageId = 'preferConcatLatestFrom';
32
+ const defaultOptions = { strict: false };
33
+ const concatLatestFromKeyword = 'concatLatestFrom';
34
+ const withLatestFromKeyword = 'withLatestFrom';
35
+ exports.default = (0, rule_creator_1.createRule)({
36
+ name: path.parse(__filename).name,
37
+ meta: {
38
+ type: 'problem',
39
+ ngrxModule: 'operators',
40
+ docs: {
41
+ description: `Use \`${concatLatestFromKeyword}\` instead of \`${withLatestFromKeyword}\` to prevent the selector from firing until the correct \`Action\` is dispatched.`,
42
+ },
43
+ fixable: 'code',
44
+ schema: [
45
+ {
46
+ type: 'object',
47
+ properties: {
48
+ strict: {
49
+ type: 'boolean',
50
+ default: defaultOptions.strict,
51
+ },
52
+ },
53
+ additionalProperties: false,
54
+ },
55
+ ],
56
+ messages: {
57
+ [exports.messageId]: `Use \`${concatLatestFromKeyword}\` instead of \`${withLatestFromKeyword}\`.`,
58
+ },
59
+ },
60
+ defaultOptions: [defaultOptions],
61
+ create: (context, [options]) => {
62
+ if (options.strict) {
63
+ return {
64
+ [`${utils_2.createEffectExpression} CallExpression > Identifier[name='withLatestFrom']`](node) {
65
+ context.report({
66
+ node,
67
+ messageId: exports.messageId,
68
+ fix: (fixer) => getFixes(context.getSourceCode(), fixer, node),
69
+ });
70
+ },
71
+ };
72
+ }
73
+ const { identifiers = [], sourceCode } = (0, utils_2.getNgRxEffectActions)(context);
74
+ const actionsNames = identifiers.length > 0 ? (0, utils_2.asPattern)(identifiers) : null;
75
+ if (!actionsNames) {
76
+ return {};
77
+ }
78
+ return {
79
+ [`${utils_2.createEffectExpression} ${(0, utils_2.namedExpression)(actionsNames)} > CallExpression[arguments.length=1] > Identifier[name='${withLatestFromKeyword}']`](node) {
80
+ context.report({
81
+ node,
82
+ messageId: exports.messageId,
83
+ fix: (fixer) => getFixes(sourceCode, fixer, node),
84
+ });
85
+ },
86
+ [`${utils_2.createEffectExpression} ${(0, utils_2.namedExpression)(actionsNames)} > CallExpression[arguments.length>1] > Identifier[name='${withLatestFromKeyword}']`](node) {
87
+ context.report({
88
+ node,
89
+ messageId: exports.messageId,
90
+ });
91
+ },
92
+ };
93
+ },
94
+ });
95
+ function getFixes(sourceCode, fixer, node) {
96
+ const { parent } = node;
97
+ const isUsingDeprecatedProjectorArgument = parent.arguments.length > 1;
98
+ const [firstArgument] = parent.arguments;
99
+ const nextToken = isUsingDeprecatedProjectorArgument &&
100
+ sourceCode.getTokenAfter(firstArgument);
101
+ return [
102
+ fixer.replaceText(node, concatLatestFromKeyword),
103
+ ...(firstArgument.type == utils_1.AST_NODE_TYPES.ArrowFunctionExpression
104
+ ? []
105
+ : [fixer.insertTextBefore(firstArgument, '() => ')]),
106
+ ].concat((0, utils_2.getImportAddFix)({
107
+ fixer,
108
+ importName: concatLatestFromKeyword,
109
+ moduleName: utils_2.NGRX_MODULE_PATHS.operators,
110
+ node,
111
+ }), ...(isUsingDeprecatedProjectorArgument && nextToken
112
+ ? [
113
+ (0, utils_2.getImportAddFix)({
114
+ fixer,
115
+ importName: 'map',
116
+ moduleName: 'rxjs/operators',
117
+ node,
118
+ }),
119
+ fixer.insertTextAfterRange(nextToken.range, '), map('),
120
+ ]
121
+ : []));
122
+ }
123
+ //# sourceMappingURL=prefer-concat-latest-from.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefer-concat-latest-from.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/operators/prefer-concat-latest-from.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAIkC;AAClC,2CAA6B;AAC7B,qDAAgD;AAChD,uCAOqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAQlD,MAAM,cAAc,GAAoB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC1D,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AACnD,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,WAAW;QACvB,IAAI,EAAE;YACJ,WAAW,EAAE,SAAS,uBAAuB,mBAAmB,qBAAqB,oFAAoF;SAC1K;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,SAAS;wBACf,OAAO,EAAE,cAAc,CAAC,MAAM;qBAC/B;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EAAE,SAAS,uBAAuB,mBAAmB,qBAAqB,KAAK;SAC3F;KACF;IACD,cAAc,EAAE,CAAC,cAAc,CAAC;IAChC,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE;QAC7B,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO;gBACL,CAAC,GAAG,8BAAsB,qDAAqD,CAAC,CAC9E,IAA8B;oBAE9B,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI;wBACJ,SAAS,EAAT,iBAAS;wBACT,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC;qBAC/D,CAAC,CAAC;gBACL,CAAC;aACF,CAAC;QACJ,CAAC;QAED,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,IAAA,4BAAoB,EAAC,OAAO,CAAC,CAAC;QACvE,MAAM,YAAY,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE5E,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL,CAAC,GAAG,8BAAsB,IAAI,IAAA,uBAAe,EAC3C,YAAY,CACb,4DAA4D,qBAAqB,IAAI,CAAC,CACrF,IAA8B;gBAE9B,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAT,iBAAS;oBACT,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC;iBAClD,CAAC,CAAC;YACL,CAAC;YACD,CAAC,GAAG,8BAAsB,IAAI,IAAA,uBAAe,EAC3C,YAAY,CACb,4DAA4D,qBAAqB,IAAI,CAAC,CACrF,IAA8B;gBAE9B,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAT,iBAAS;iBACV,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,QAAQ,CACf,UAAyC,EACzC,KAAyB,EACzB,IAA8B;IAE9B,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,MAAM,kCAAkC,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACvE,MAAM,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC;IACzC,MAAM,SAAS,GACb,kCAAkC;QAClC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAC1C,OAAO;QACL,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,uBAAuB,CAAC;QAChD,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,sBAAc,CAAC,uBAAuB;YAC9D,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC;KACvD,CAAC,MAAM,CACN,IAAA,uBAAe,EAAC;QACd,KAAK;QACL,UAAU,EAAE,uBAAuB;QACnC,UAAU,EAAE,yBAAiB,CAAC,SAAS;QACvC,IAAI;KACL,CAAC,EACF,GAAG,CAAC,kCAAkC,IAAI,SAAS;QACjD,CAAC,CAAC;YACE,IAAA,uBAAe,EAAC;gBACd,KAAK;gBACL,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,gBAAgB;gBAC5B,IAAI;aACL,CAAC;YACF,KAAK,CAAC,oBAAoB,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;SACvD;QACH,CAAC,CAAC,EAAE,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n AST_NODE_TYPES,\n type TSESLint,\n type TSESTree,\n} from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n createEffectExpression,\n getImportAddFix,\n getNgRxEffectActions,\n namedExpression,\n NGRX_MODULE_PATHS,\n} from '../../utils';\n\nexport const messageId = 'preferConcatLatestFrom';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [{ readonly strict: boolean }];\ntype WithLatestFromIdentifier = TSESTree.Identifier & {\n parent: TSESTree.CallExpression;\n};\n\nconst defaultOptions: Options[number] = { strict: false };\nconst concatLatestFromKeyword = 'concatLatestFrom';\nconst withLatestFromKeyword = 'withLatestFrom';\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'operators',\n docs: {\n description: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\` to prevent the selector from firing until the correct \\`Action\\` is dispatched.`,\n },\n fixable: 'code',\n schema: [\n {\n type: 'object',\n properties: {\n strict: {\n type: 'boolean',\n default: defaultOptions.strict,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n [messageId]: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\`.`,\n },\n },\n defaultOptions: [defaultOptions],\n create: (context, [options]) => {\n if (options.strict) {\n return {\n [`${createEffectExpression} CallExpression > Identifier[name='withLatestFrom']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(context.getSourceCode(), fixer, node),\n });\n },\n };\n }\n\n const { identifiers = [], sourceCode } = getNgRxEffectActions(context);\n const actionsNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!actionsNames) {\n return {};\n }\n\n return {\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length=1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(sourceCode, fixer, node),\n });\n },\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length>1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n\nfunction getFixes(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: WithLatestFromIdentifier\n) {\n const { parent } = node;\n const isUsingDeprecatedProjectorArgument = parent.arguments.length > 1;\n const [firstArgument] = parent.arguments;\n const nextToken =\n isUsingDeprecatedProjectorArgument &&\n sourceCode.getTokenAfter(firstArgument);\n return [\n fixer.replaceText(node, concatLatestFromKeyword),\n ...(firstArgument.type == AST_NODE_TYPES.ArrowFunctionExpression\n ? []\n : [fixer.insertTextBefore(firstArgument, '() => ')]),\n ].concat(\n getImportAddFix({\n fixer,\n importName: concatLatestFromKeyword,\n moduleName: NGRX_MODULE_PATHS.operators,\n node,\n }),\n ...(isUsingDeprecatedProjectorArgument && nextToken\n ? [\n getImportAddFix({\n fixer,\n importName: 'map',\n moduleName: 'rxjs/operators',\n node,\n }),\n fixer.insertTextAfterRange(nextToken.range, '), map('),\n ]\n : [])\n );\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export declare const messageId = "signalStateNoArraysAtRootLevel";
2
+ declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"signalStateNoArraysAtRootLevel", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
3
+ export default _default;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.messageId = void 0;
27
+ const path = __importStar(require("path"));
28
+ const rule_creator_1 = require("../../rule-creator");
29
+ const utils_1 = require("../../utils");
30
+ exports.messageId = 'signalStateNoArraysAtRootLevel';
31
+ exports.default = (0, rule_creator_1.createRule)({
32
+ name: path.parse(__filename).name,
33
+ meta: {
34
+ type: 'problem',
35
+ ngrxModule: 'signals',
36
+ docs: {
37
+ description: `signalState should accept a record or dictionary as an input argument.`,
38
+ },
39
+ schema: [],
40
+ messages: {
41
+ [exports.messageId]: `Wrap the array in an record or dictionary.`,
42
+ },
43
+ },
44
+ defaultOptions: [],
45
+ create: (context) => {
46
+ return {
47
+ [`CallExpression[callee.name=signalState]`](node) {
48
+ const [argument] = node.arguments;
49
+ if ((0, utils_1.isArrayExpression)(argument)) {
50
+ context.report({
51
+ node: argument,
52
+ messageId: exports.messageId,
53
+ });
54
+ }
55
+ },
56
+ };
57
+ },
58
+ });
59
+ //# sourceMappingURL=signal-state-no-arrays-at-root-level.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-state-no-arrays-at-root-level.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/signals/signal-state-no-arrays-at-root-level.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAgD;AAEnC,QAAA,SAAS,GAAG,gCAAgC,CAAC;AAK1D,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EAAE,wEAAwE;SACtF;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EAAE,4CAA4C;SAC1D;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO;YACL,CAAC,yCAAyC,CAAC,CACzC,IAA6B;gBAE7B,MAAM,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;gBAClC,IAAI,IAAA,yBAAiB,EAAC,QAAQ,CAAC,EAAE,CAAC;oBAChC,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,QAAQ;wBACd,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 { isArrayExpression } from '../../utils';\n\nexport const messageId = 'signalStateNoArraysAtRootLevel';\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: `signalState should accept a record or dictionary as an input argument.`,\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=signalState]`](\n node: TSESTree.CallExpression\n ) {\n const [argument] = node.arguments;\n if (isArrayExpression(argument)) {\n context.report({\n node: argument,\n messageId,\n });\n }\n },\n };\n },\n});\n"]}
@@ -0,0 +1,4 @@
1
+ import { ESLintUtils } from '@typescript-eslint/utils';
2
+ export declare const messageId = "withStateNoArraysAtRootLevel";
3
+ declare const _default: ESLintUtils.RuleModule<"withStateNoArraysAtRootLevel", readonly [], unknown, ESLintUtils.RuleListener>;
4
+ export default _default;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.messageId = void 0;
27
+ const utils_1 = require("@typescript-eslint/utils");
28
+ const path = __importStar(require("path"));
29
+ const rule_creator_1 = require("../../rule-creator");
30
+ const utils_2 = require("../../utils");
31
+ exports.messageId = 'withStateNoArraysAtRootLevel';
32
+ exports.default = (0, rule_creator_1.createRule)({
33
+ name: path.parse(__filename).name,
34
+ meta: {
35
+ type: 'problem',
36
+ ngrxModule: 'signals',
37
+ docs: {
38
+ description: `withState should accept a record or dictionary as an input argument.`,
39
+ requiresTypeChecking: true,
40
+ },
41
+ schema: [],
42
+ messages: {
43
+ [exports.messageId]: `Wrap the array in an record or dictionary.`,
44
+ },
45
+ },
46
+ defaultOptions: [],
47
+ create: (context) => {
48
+ return {
49
+ [`CallExpression[callee.name=withState]`](node) {
50
+ const [argument] = node.arguments;
51
+ if ((0, utils_2.isArrayExpression)(argument)) {
52
+ context.report({
53
+ node: argument,
54
+ messageId: exports.messageId,
55
+ });
56
+ }
57
+ else if (argument) {
58
+ const services = utils_1.ESLintUtils.getParserServices(context);
59
+ const typeChecker = services.program.getTypeChecker();
60
+ const type = services.getTypeAtLocation(argument);
61
+ if (typeChecker.isArrayType(type)) {
62
+ context.report({
63
+ node: argument,
64
+ messageId: exports.messageId,
65
+ });
66
+ }
67
+ }
68
+ },
69
+ };
70
+ },
71
+ });
72
+ //# sourceMappingURL=with-state-no-arrays-at-root-level.js.map