@ngrx/eslint-plugin 14.0.0-beta.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 (130) hide show
  1. package/jest.config.js +22 -0
  2. package/jest.config.js.map +1 -0
  3. package/migrations/migration.json +3 -0
  4. package/package.json +51 -0
  5. package/schematics/collection.json +10 -0
  6. package/schematics/ng-add/index.js +51 -0
  7. package/schematics/ng-add/index.js.map +1 -0
  8. package/schematics/ng-add/schema.js +3 -0
  9. package/schematics/ng-add/schema.js.map +1 -0
  10. package/schematics/ng-add/schema.json +87 -0
  11. package/scripts/generate-config.js +85 -0
  12. package/scripts/generate-config.js.map +1 -0
  13. package/scripts/generate-docs.js +90 -0
  14. package/scripts/generate-docs.js.map +1 -0
  15. package/scripts/generate-overview.js +98 -0
  16. package/scripts/generate-overview.js.map +1 -0
  17. package/spec/utils/index.js +22 -0
  18. package/spec/utils/index.js.map +1 -0
  19. package/src/configs/all-requiring-type-checking.js +46 -0
  20. package/src/configs/all-requiring-type-checking.js.map +1 -0
  21. package/src/configs/all.js +39 -0
  22. package/src/configs/all.js.map +1 -0
  23. package/src/configs/component-store-strict.js +11 -0
  24. package/src/configs/component-store-strict.js.map +1 -0
  25. package/src/configs/component-store.js +11 -0
  26. package/src/configs/component-store.js.map +1 -0
  27. package/src/configs/effects-requiring-type-checking.js +27 -0
  28. package/src/configs/effects-requiring-type-checking.js.map +1 -0
  29. package/src/configs/effects-strict-requiring-type-checking.js +27 -0
  30. package/src/configs/effects-strict-requiring-type-checking.js.map +1 -0
  31. package/src/configs/effects-strict.js +20 -0
  32. package/src/configs/effects-strict.js.map +1 -0
  33. package/src/configs/effects.js +20 -0
  34. package/src/configs/effects.js.map +1 -0
  35. package/src/configs/index.js +33 -0
  36. package/src/configs/index.js.map +1 -0
  37. package/src/configs/recommended-requiring-type-checking.js +46 -0
  38. package/src/configs/recommended-requiring-type-checking.js.map +1 -0
  39. package/src/configs/recommended.js +39 -0
  40. package/src/configs/recommended.js.map +1 -0
  41. package/src/configs/store-strict.js +30 -0
  42. package/src/configs/store-strict.js.map +1 -0
  43. package/src/configs/store.js +30 -0
  44. package/src/configs/store.js.map +1 -0
  45. package/src/configs/strict-requiring-type-checking.js +46 -0
  46. package/src/configs/strict-requiring-type-checking.js.map +1 -0
  47. package/src/configs/strict.js +39 -0
  48. package/src/configs/strict.js.map +1 -0
  49. package/src/index.js +8 -0
  50. package/src/index.js.map +1 -0
  51. package/src/rule-creator.js +29 -0
  52. package/src/rule-creator.js.map +1 -0
  53. package/src/rules/component-store/updater-explicit-return-type.js +69 -0
  54. package/src/rules/component-store/updater-explicit-return-type.js.map +1 -0
  55. package/src/rules/effects/avoid-cyclic-effects.js +202 -0
  56. package/src/rules/effects/avoid-cyclic-effects.js.map +1 -0
  57. package/src/rules/effects/no-dispatch-in-effects.js +83 -0
  58. package/src/rules/effects/no-dispatch-in-effects.js.map +1 -0
  59. package/src/rules/effects/no-effect-decorator-and-creator.js +107 -0
  60. package/src/rules/effects/no-effect-decorator-and-creator.js.map +1 -0
  61. package/src/rules/effects/no-effect-decorator.js +124 -0
  62. package/src/rules/effects/no-effect-decorator.js.map +1 -0
  63. package/src/rules/effects/no-effects-in-providers.js +105 -0
  64. package/src/rules/effects/no-effects-in-providers.js.map +1 -0
  65. package/src/rules/effects/no-multiple-actions-in-effects.js +77 -0
  66. package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -0
  67. package/src/rules/effects/prefer-action-creator-in-of-type.js +58 -0
  68. package/src/rules/effects/prefer-action-creator-in-of-type.js.map +1 -0
  69. package/src/rules/effects/prefer-concat-latest-from.js +153 -0
  70. package/src/rules/effects/prefer-concat-latest-from.js.map +1 -0
  71. package/src/rules/effects/prefer-effect-callback-in-block-statement.js +99 -0
  72. package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -0
  73. package/src/rules/effects/use-effects-lifecycle-interface.js +88 -0
  74. package/src/rules/effects/use-effects-lifecycle-interface.js.map +1 -0
  75. package/src/rules/index.js +59 -0
  76. package/src/rules/index.js.map +1 -0
  77. package/src/rules/store/avoid-combining-selectors.js +65 -0
  78. package/src/rules/store/avoid-combining-selectors.js.map +1 -0
  79. package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js +95 -0
  80. package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -0
  81. package/src/rules/store/avoid-duplicate-actions-in-reducer.js +150 -0
  82. package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -0
  83. package/src/rules/store/avoid-mapping-selectors.js +82 -0
  84. package/src/rules/store/avoid-mapping-selectors.js.map +1 -0
  85. package/src/rules/store/good-action-hygiene.js +84 -0
  86. package/src/rules/store/good-action-hygiene.js.map +1 -0
  87. package/src/rules/store/no-multiple-global-stores.js +157 -0
  88. package/src/rules/store/no-multiple-global-stores.js.map +1 -0
  89. package/src/rules/store/no-reducer-in-key-names.js +76 -0
  90. package/src/rules/store/no-reducer-in-key-names.js.map +1 -0
  91. package/src/rules/store/no-store-subscription.js +64 -0
  92. package/src/rules/store/no-store-subscription.js.map +1 -0
  93. package/src/rules/store/no-typed-global-store.js +101 -0
  94. package/src/rules/store/no-typed-global-store.js.map +1 -0
  95. package/src/rules/store/on-function-explicit-return-type.js +106 -0
  96. package/src/rules/store/on-function-explicit-return-type.js.map +1 -0
  97. package/src/rules/store/prefer-action-creator-in-dispatch.js +70 -0
  98. package/src/rules/store/prefer-action-creator-in-dispatch.js.map +1 -0
  99. package/src/rules/store/prefer-action-creator.js +58 -0
  100. package/src/rules/store/prefer-action-creator.js.map +1 -0
  101. package/src/rules/store/prefer-inline-action-props.js +72 -0
  102. package/src/rules/store/prefer-inline-action-props.js.map +1 -0
  103. package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js +93 -0
  104. package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js.map +1 -0
  105. package/src/rules/store/prefer-selector-in-select.js +93 -0
  106. package/src/rules/store/prefer-selector-in-select.js.map +1 -0
  107. package/src/rules/store/prefix-selectors-with-select.js +107 -0
  108. package/src/rules/store/prefix-selectors-with-select.js.map +1 -0
  109. package/src/rules/store/select-style.js +196 -0
  110. package/src/rules/store/select-style.js.map +1 -0
  111. package/src/rules/store/use-consistent-global-store-name.js +139 -0
  112. package/src/rules/store/use-consistent-global-store-name.js.map +1 -0
  113. package/src/utils/helper-functions/docs.js +8 -0
  114. package/src/utils/helper-functions/docs.js.map +1 -0
  115. package/src/utils/helper-functions/folder.js +118 -0
  116. package/src/utils/helper-functions/folder.js.map +1 -0
  117. package/src/utils/helper-functions/guards.js +56 -0
  118. package/src/utils/helper-functions/guards.js.map +1 -0
  119. package/src/utils/helper-functions/index.js +23 -0
  120. package/src/utils/helper-functions/index.js.map +1 -0
  121. package/src/utils/helper-functions/ngrx-modules.js +10 -0
  122. package/src/utils/helper-functions/ngrx-modules.js.map +1 -0
  123. package/src/utils/helper-functions/utils.js +302 -0
  124. package/src/utils/helper-functions/utils.js.map +1 -0
  125. package/src/utils/helper-functions/versions.js +70 -0
  126. package/src/utils/helper-functions/versions.js.map +1 -0
  127. package/src/utils/index.js +19 -0
  128. package/src/utils/index.js.map +1 -0
  129. package/src/utils/selectors/index.js +58 -0
  130. package/src/utils/selectors/index.js.map +1 -0
@@ -0,0 +1,82 @@
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
+ var _a;
26
+ exports.__esModule = true;
27
+ 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");
32
+ exports.messageId = 'avoidMapppingSelectors';
33
+ exports["default"] = (0, rule_creator_1.createRule)({
34
+ name: path.parse(__filename).name,
35
+ meta: {
36
+ type: 'suggestion',
37
+ ngrxModule: 'store',
38
+ docs: {
39
+ description: 'Avoid mapping logic outside the selector level.',
40
+ recommended: 'warn'
41
+ },
42
+ schema: [],
43
+ messages: (_a = {},
44
+ _a[exports.messageId] = 'Map logic at the selector level instead.',
45
+ _a)
46
+ },
47
+ 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;
52
+ if (!storeNames) {
53
+ return {};
54
+ }
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']");
57
+ function isInCreateEffect(node) {
58
+ var parent = node.parent;
59
+ while (parent) {
60
+ if ((0, eslint_etc_1.isCallExpression)(parent) &&
61
+ (0, eslint_etc_1.isIdentifier)(parent.callee) &&
62
+ parent.callee.name === 'createEffect') {
63
+ return true;
64
+ }
65
+ parent = parent.parent;
66
+ }
67
+ return false;
68
+ }
69
+ return _a = {},
70
+ _a[":matches(".concat(selectSelector, ", ").concat(pipeWithSelectAndMapSelector, ") > CallExpression[callee.name='map']:not(:has(ThisExpression))")] = function (node) {
71
+ if (isInCreateEffect(node)) {
72
+ return;
73
+ }
74
+ context.report({
75
+ node: node,
76
+ messageId: exports.messageId
77
+ });
78
+ },
79
+ _a;
80
+ }
81
+ });
82
+ //# sourceMappingURL=avoid-mapping-selectors.js.map
@@ -0,0 +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,qCAKqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,qBAAe,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;YACf,OAAO,EAAE,CAAC;SACX;QAED,IAAM,4BAA4B,GAAG,UAAG,IAAA,sBAAc,EACpD,UAAU,CACX,mFAAyF,CAAC;QAC3F,IAAM,cAAc,GAAG,UAAG,IAAA,+BAAuB,EAC/C,UAAU,CACX,kDAAwD,CAAC;QAE1D,SAAS,gBAAgB,CAAC,IAA6B;YACrD,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YACzB,OAAO,MAAM,EAAE;gBACb,IACE,IAAA,6BAAgB,EAAC,MAAM,CAAC;oBACxB,IAAA,yBAAY,EAAC,MAAM,CAAC,MAAM,CAAC;oBAC3B,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,cAAc,EACrC;oBACA,OAAO,IAAI,CAAC;iBACb;gBACD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;aACxB;YACD,OAAO,KAAK,CAAC;QACf,CAAC;QAED;YACE,GAAC,mBAAY,cAAc,eAAK,4BAA4B,oEAAiE,IAA7H,UACE,IAA6B;gBAE7B,IAAI,gBAAgB,CAAC,IAAI,CAAC,EAAE;oBAC1B,OAAO;iBACR;gBACD,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;iBACV,CAAC,CAAC;YACL,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 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 return {\n [`:matches(${selectSelector}, ${pipeWithSelectAndMapSelector}) > CallExpression[callee.name='map']:not(:has(ThisExpression))`](\n node: TSESTree.CallExpression\n ) {\n if (isInCreateEffect(node)) {\n return;\n }\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
@@ -0,0 +1,84 @@
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
+ 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 _a;
42
+ exports.__esModule = true;
43
+ exports.messageId = void 0;
44
+ var path = __importStar(require("path"));
45
+ var rule_creator_1 = require("../../rule-creator");
46
+ var utils_1 = require("../../utils");
47
+ exports.messageId = 'goodActionHygiene';
48
+ exports["default"] = (0, rule_creator_1.createRule)({
49
+ name: path.parse(__filename).name,
50
+ meta: {
51
+ type: 'suggestion',
52
+ ngrxModule: 'store',
53
+ docs: {
54
+ description: 'Ensures the use of good action hygiene.',
55
+ recommended: 'warn'
56
+ },
57
+ schema: [],
58
+ messages: (_a = {},
59
+ _a[exports.messageId] = 'Action type `{{ actionType }}` does not follow the good action hygiene practice, use "[Source] {{ actionType }}" to define action types.',
60
+ _a)
61
+ },
62
+ defaultOptions: [],
63
+ create: function (context) {
64
+ var _a;
65
+ var sourceEventPattern = /[[].*[\]]\s.*/;
66
+ return _a = {},
67
+ _a[utils_1.actionCreatorWithLiteral] = function (_a) {
68
+ var _b = __read(_a.arguments, 1), node = _b[0];
69
+ var actionType = node.value;
70
+ if (sourceEventPattern.test(actionType)) {
71
+ return;
72
+ }
73
+ context.report({
74
+ node: node,
75
+ messageId: exports.messageId,
76
+ data: {
77
+ actionType: actionType
78
+ }
79
+ });
80
+ },
81
+ _a;
82
+ }
83
+ });
84
+ //# sourceMappingURL=good-action-hygiene.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"good-action-hygiene.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/good-action-hygiene.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAuD;AAE1C,QAAA,SAAS,GAAG,mBAAmB,CAAC;AAK7C,qBAAe,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,yCAAyC;YACtD,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0IAA0I;eAC7I;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd,IAAM,kBAAkB,GAAG,eAAe,CAAC;QAE3C;YACE,GAAC,gCAAwB,IAAzB,UAA2B,EAI1B;oBAHC,KAAA,uBAAiB,EAAL,IAAI,QAAA;gBAIR,IAAO,UAAU,GAAK,IAAI,MAAT,CAAU;gBAEnC,IAAI,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;oBACvC,OAAO;iBACR;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;oBACT,IAAI,EAAE;wBACJ,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 { actionCreatorWithLiteral } from '../../utils';\n\nexport const messageId = 'goodActionHygiene';\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: 'Ensures the use of good action hygiene.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Action type `{{ actionType }}` does not follow the good action hygiene practice, use \"[Source] {{ actionType }}\" to define action types.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceEventPattern = /[[].*[\\]]\\s.*/;\n\n return {\n [actionCreatorWithLiteral]({\n arguments: [node],\n }: Omit<TSESTree.CallExpression, 'arguments'> & {\n arguments: TSESTree.StringLiteral[];\n }) {\n const { value: actionType } = node;\n\n if (sourceEventPattern.test(actionType)) {\n return;\n }\n\n context.report({\n node,\n messageId,\n data: {\n actionType,\n },\n });\n },\n };\n },\n});\n"]}
@@ -0,0 +1,157 @@
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
+ 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 __read = (this && this.__read) || function (o, n) {
37
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
38
+ if (!m) return o;
39
+ var i = m.call(o), r, ar = [], e;
40
+ try {
41
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
42
+ }
43
+ catch (error) { e = { error: error }; }
44
+ finally {
45
+ try {
46
+ if (r && !r.done && (m = i["return"])) m.call(i);
47
+ }
48
+ finally { if (e) throw e.error; }
49
+ }
50
+ return ar;
51
+ };
52
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
53
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
54
+ if (ar || !(i in from)) {
55
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
56
+ ar[i] = from[i];
57
+ }
58
+ }
59
+ return to.concat(ar || Array.prototype.slice.call(from));
60
+ };
61
+ var _a;
62
+ exports.__esModule = true;
63
+ exports.noMultipleGlobalStoresSuggest = exports.noMultipleGlobalStores = void 0;
64
+ var path = __importStar(require("path"));
65
+ var rule_creator_1 = require("../../rule-creator");
66
+ var utils_1 = require("../../utils");
67
+ exports.noMultipleGlobalStores = 'noMultipleGlobalStores';
68
+ exports.noMultipleGlobalStoresSuggest = 'noMultipleGlobalStoresSuggest';
69
+ exports["default"] = (0, rule_creator_1.createRule)({
70
+ name: path.parse(__filename).name,
71
+ meta: {
72
+ type: 'suggestion',
73
+ hasSuggestions: true,
74
+ ngrxModule: 'store',
75
+ docs: {
76
+ description: 'There should only be one global store injected.',
77
+ recommended: 'warn',
78
+ suggestion: true
79
+ },
80
+ schema: [],
81
+ messages: (_a = {},
82
+ _a[exports.noMultipleGlobalStores] = 'Global store should be injected only once.',
83
+ _a[exports.noMultipleGlobalStoresSuggest] = 'Remove this reference.',
84
+ _a)
85
+ },
86
+ defaultOptions: [],
87
+ create: function (context) {
88
+ return {
89
+ Program: function () {
90
+ var e_1, _a, e_2, _b;
91
+ var _c = (0, utils_1.getNgRxStores)(context), _d = _c.identifiers, identifiers = _d === void 0 ? [] : _d, sourceCode = _c.sourceCode;
92
+ var flattenedIdentifiers = groupBy(identifiers).values();
93
+ try {
94
+ for (var flattenedIdentifiers_1 = __values(flattenedIdentifiers), flattenedIdentifiers_1_1 = flattenedIdentifiers_1.next(); !flattenedIdentifiers_1_1.done; flattenedIdentifiers_1_1 = flattenedIdentifiers_1.next()) {
95
+ var identifiers_2 = flattenedIdentifiers_1_1.value;
96
+ if (identifiers_2.length <= 1) {
97
+ continue;
98
+ }
99
+ var _loop_1 = function (node) {
100
+ var nodeToReport = getNodeToReport(node);
101
+ context.report({
102
+ node: nodeToReport,
103
+ messageId: exports.noMultipleGlobalStores,
104
+ suggest: [
105
+ {
106
+ messageId: exports.noMultipleGlobalStoresSuggest,
107
+ fix: function (fixer) { return getFixes(sourceCode, fixer, nodeToReport); }
108
+ },
109
+ ]
110
+ });
111
+ };
112
+ try {
113
+ for (var identifiers_1 = (e_2 = void 0, __values(identifiers_2)), identifiers_1_1 = identifiers_1.next(); !identifiers_1_1.done; identifiers_1_1 = identifiers_1.next()) {
114
+ var node = identifiers_1_1.value;
115
+ _loop_1(node);
116
+ }
117
+ }
118
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
119
+ finally {
120
+ try {
121
+ if (identifiers_1_1 && !identifiers_1_1.done && (_b = identifiers_1["return"])) _b.call(identifiers_1);
122
+ }
123
+ finally { if (e_2) throw e_2.error; }
124
+ }
125
+ }
126
+ }
127
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
128
+ finally {
129
+ try {
130
+ if (flattenedIdentifiers_1_1 && !flattenedIdentifiers_1_1.done && (_a = flattenedIdentifiers_1["return"])) _a.call(flattenedIdentifiers_1);
131
+ }
132
+ finally { if (e_1) throw e_1.error; }
133
+ }
134
+ }
135
+ };
136
+ }
137
+ });
138
+ function getNodeToReport(node) {
139
+ return node.parent && (0, utils_1.isTSParameterProperty)(node.parent) ? node.parent : node;
140
+ }
141
+ function getFixes(sourceCode, fixer, node) {
142
+ var parent = node.parent;
143
+ var nodeToRemove = parent && (0, utils_1.isTSParameterProperty)(parent) ? parent : node;
144
+ return (0, utils_1.getNodeToCommaRemoveFix)(sourceCode, fixer, nodeToRemove);
145
+ }
146
+ function groupBy(identifiers) {
147
+ return identifiers.reduce(function (accumulator, identifier) {
148
+ var parent = (0, utils_1.isTSParameterProperty)(identifier.parent)
149
+ ? identifier.parent.parent
150
+ : identifier.parent;
151
+ var collectedIdentifiers = accumulator.get(parent);
152
+ return accumulator.set(parent, __spreadArray(__spreadArray([], __read((collectedIdentifiers !== null && collectedIdentifiers !== void 0 ? collectedIdentifiers : [])), false), [
153
+ identifier,
154
+ ], false));
155
+ }, new Map());
156
+ }
157
+ //# sourceMappingURL=no-multiple-global-stores.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-multiple-global-stores.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-multiple-global-stores.ts"],"names":[],"mappings":"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","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n getNgRxStores,\n getNodeToCommaRemoveFix,\n isTSParameterProperty,\n} from '../../utils';\n\nexport const noMultipleGlobalStores = 'noMultipleGlobalStores';\nexport const noMultipleGlobalStoresSuggest = 'noMultipleGlobalStoresSuggest';\n\ntype MessageIds =\n | typeof noMultipleGlobalStores\n | typeof noMultipleGlobalStoresSuggest;\ntype Options = readonly [];\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: 'There should only be one global store injected.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noMultipleGlobalStores]: 'Global store should be injected only once.',\n [noMultipleGlobalStoresSuggest]: 'Remove this reference.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n Program() {\n const { identifiers = [], sourceCode } = getNgRxStores(context);\n const flattenedIdentifiers = groupBy(identifiers).values();\n\n for (const identifiers of flattenedIdentifiers) {\n if (identifiers.length <= 1) {\n continue;\n }\n\n for (const node of identifiers) {\n const nodeToReport = getNodeToReport(node);\n context.report({\n node: nodeToReport,\n messageId: noMultipleGlobalStores,\n suggest: [\n {\n messageId: noMultipleGlobalStoresSuggest,\n fix: (fixer) => getFixes(sourceCode, fixer, nodeToReport),\n },\n ],\n });\n }\n }\n },\n };\n },\n});\n\nfunction getNodeToReport(node: TSESTree.Node) {\n return node.parent && isTSParameterProperty(node.parent) ? node.parent : node;\n}\n\nfunction getFixes(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: TSESTree.Node\n) {\n const { parent } = node;\n const nodeToRemove = parent && isTSParameterProperty(parent) ? parent : node;\n return getNodeToCommaRemoveFix(sourceCode, fixer, nodeToRemove);\n}\n\ntype Identifiers = NonNullable<ReturnType<typeof getNgRxStores>['identifiers']>;\n\nfunction groupBy(identifiers: Identifiers): Map<TSESTree.Node, Identifiers> {\n return identifiers.reduce<Map<TSESTree.Node, Identifiers>>(\n (accumulator, identifier) => {\n const parent = isTSParameterProperty(identifier.parent)\n ? identifier.parent.parent\n : identifier.parent;\n const collectedIdentifiers = accumulator.get(parent);\n return accumulator.set(parent, [\n ...(collectedIdentifiers ?? []),\n identifier,\n ]);\n },\n new Map()\n );\n}\n"]}
@@ -0,0 +1,76 @@
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
+ var _a;
26
+ exports.__esModule = true;
27
+ exports.noReducerInKeyNamesSuggest = exports.noReducerInKeyNames = void 0;
28
+ var path = __importStar(require("path"));
29
+ var rule_creator_1 = require("../../rule-creator");
30
+ var utils_1 = require("../../utils");
31
+ exports.noReducerInKeyNames = 'noReducerInKeyNames';
32
+ exports.noReducerInKeyNamesSuggest = 'noReducerInKeyNamesSuggest';
33
+ var reducerKeyword = 'reducer';
34
+ exports["default"] = (0, rule_creator_1.createRule)({
35
+ name: path.parse(__filename).name,
36
+ meta: {
37
+ type: 'suggestion',
38
+ hasSuggestions: true,
39
+ ngrxModule: 'store',
40
+ docs: {
41
+ description: "Avoid the word \"".concat(reducerKeyword, "\" in the key names."),
42
+ recommended: 'warn',
43
+ suggestion: true
44
+ },
45
+ schema: [],
46
+ messages: (_a = {},
47
+ _a[exports.noReducerInKeyNames] = "Avoid the word \"".concat(reducerKeyword, "\" in the key names to better represent the state."),
48
+ _a[exports.noReducerInKeyNamesSuggest] = "Remove the word \"".concat(reducerKeyword, "\"."),
49
+ _a)
50
+ },
51
+ defaultOptions: [],
52
+ create: function (context) {
53
+ var _a;
54
+ return _a = {},
55
+ _a[":matches(".concat(utils_1.storeActionReducerMap, ", ").concat(utils_1.actionReducerMap, ") > ").concat((0, utils_1.metadataProperty)(/reducer/i), " > .key")] = function (node) {
56
+ context.report({
57
+ node: node,
58
+ messageId: exports.noReducerInKeyNames,
59
+ suggest: [
60
+ {
61
+ messageId: exports.noReducerInKeyNamesSuggest,
62
+ fix: function (fixer) {
63
+ var keyName = (0, utils_1.getRawText)(node);
64
+ if (!keyName) {
65
+ return null;
66
+ }
67
+ return fixer.replaceText(node, keyName.replace(new RegExp(reducerKeyword, 'i'), ''));
68
+ }
69
+ },
70
+ ]
71
+ });
72
+ },
73
+ _a;
74
+ }
75
+ });
76
+ //# sourceMappingURL=no-reducer-in-key-names.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-reducer-in-key-names.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-reducer-in-key-names.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAC5C,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAOvE,IAAM,cAAc,GAAG,SAAS,CAAC;AAEjC,qBAAe,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,2BAAmB,cAAc,yBAAqB;YACnE,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,2BAAmB,IAAG,2BAAmB,cAAc,uDAAmD;YAC3G,GAAC,kCAA0B,IAAG,4BAAoB,cAAc,QAAI;eACrE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd;YACE,GAAC,mBAAY,6BAAqB,eAAK,wBAAgB,iBAAO,IAAA,wBAAgB,EAC5E,UAAU,CACX,YAAS,IAFV,UAEY,IAA8B;gBACxC,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,EAAE,2BAAmB;oBAC9B,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,kCAA0B;4BACrC,GAAG,EAAE,UAAC,KAAK;gCACT,IAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC;gCAEjC,IAAI,CAAC,OAAO,EAAE;oCACZ,OAAO,IAAI,CAAC;iCACb;gCAED,OAAO,KAAK,CAAC,WAAW,CACtB,IAAI,EACJ,OAAO,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,cAAc,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CACrD,CAAC;4BACJ,CAAC;yBACF;qBACF;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 actionReducerMap,\n getRawText,\n metadataProperty,\n storeActionReducerMap,\n} from '../../utils';\n\nexport const noReducerInKeyNames = 'noReducerInKeyNames';\nexport const noReducerInKeyNamesSuggest = 'noReducerInKeyNamesSuggest';\n\ntype MessageIds =\n | typeof noReducerInKeyNames\n | typeof noReducerInKeyNamesSuggest;\ntype Options = readonly [];\n\nconst reducerKeyword = 'reducer';\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: `Avoid the word \"${reducerKeyword}\" in the key names.`,\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noReducerInKeyNames]: `Avoid the word \"${reducerKeyword}\" in the key names to better represent the state.`,\n [noReducerInKeyNamesSuggest]: `Remove the word \"${reducerKeyword}\".`,\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`:matches(${storeActionReducerMap}, ${actionReducerMap}) > ${metadataProperty(\n /reducer/i\n )} > .key`](node: TSESTree.Property['key']) {\n context.report({\n node,\n messageId: noReducerInKeyNames,\n suggest: [\n {\n messageId: noReducerInKeyNamesSuggest,\n fix: (fixer) => {\n const keyName = getRawText(node);\n\n if (!keyName) {\n return null;\n }\n\n return fixer.replaceText(\n node,\n keyName.replace(new RegExp(reducerKeyword, 'i'), '')\n );\n },\n },\n ],\n });\n },\n };\n },\n});\n"]}
@@ -0,0 +1,64 @@
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
+ var _a;
26
+ exports.__esModule = true;
27
+ exports.messageId = void 0;
28
+ var path = __importStar(require("path"));
29
+ var rule_creator_1 = require("../../rule-creator");
30
+ var utils_1 = require("../../utils");
31
+ exports.messageId = 'noStoreSubscription';
32
+ exports["default"] = (0, rule_creator_1.createRule)({
33
+ name: path.parse(__filename).name,
34
+ meta: {
35
+ type: 'suggestion',
36
+ ngrxModule: 'store',
37
+ docs: {
38
+ description: 'Using the `async` pipe is preferred over `store` subscription.',
39
+ recommended: 'warn'
40
+ },
41
+ schema: [],
42
+ messages: (_a = {},
43
+ _a[exports.messageId] = '`Store` subscription is forbidden. Use the `async` pipe instead.',
44
+ _a)
45
+ },
46
+ defaultOptions: [],
47
+ create: function (context) {
48
+ var _a;
49
+ var _b = (0, utils_1.getNgRxStores)(context).identifiers, identifiers = _b === void 0 ? [] : _b;
50
+ var storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
51
+ if (!storeNames) {
52
+ return {};
53
+ }
54
+ return _a = {},
55
+ _a["".concat((0, utils_1.namedCallableExpression)(storeNames), " > MemberExpression > Identifier[name='subscribe']")] = function (node) {
56
+ context.report({
57
+ node: node,
58
+ messageId: exports.messageId
59
+ });
60
+ },
61
+ _a;
62
+ }
63
+ });
64
+ //# sourceMappingURL=no-store-subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-store-subscription.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-store-subscription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAgF;AAEnE,QAAA,SAAS,GAAG,qBAAqB,CAAC;AAK/C,qBAAe,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,EACT,gEAAgE;YAClE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,kEAAkE;eACrE;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;YACf,OAAO,EAAE,CAAC;SACX;QAED;YACE,GAAC,UAAG,IAAA,+BAAuB,EACzB,UAAU,CACX,uDAAoD,IAFrD,UAGE,IAAyB;gBAEzB,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI,MAAA;oBACJ,SAAS,mBAAA;iBACV,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 { asPattern, getNgRxStores, namedCallableExpression } from '../../utils';\n\nexport const messageId = 'noStoreSubscription';\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:\n 'Using the `async` pipe is preferred over `store` subscription.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n '`Store` subscription is forbidden. Use the `async` pipe 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 return {\n [`${namedCallableExpression(\n storeNames\n )} > MemberExpression > Identifier[name='subscribe']`](\n node: TSESTree.Identifier\n ) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
@@ -0,0 +1,101 @@
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
+ 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
+ exports.__esModule = true;
38
+ exports.noTypedStoreSuggest = exports.noTypedStore = void 0;
39
+ var path = __importStar(require("path"));
40
+ var rule_creator_1 = require("../../rule-creator");
41
+ var utils_1 = require("../../utils");
42
+ exports.noTypedStore = 'noTypedStore';
43
+ exports.noTypedStoreSuggest = 'noTypedStoreSuggest';
44
+ exports["default"] = (0, rule_creator_1.createRule)({
45
+ name: path.parse(__filename).name,
46
+ meta: {
47
+ type: 'suggestion',
48
+ hasSuggestions: true,
49
+ ngrxModule: 'store',
50
+ docs: {
51
+ description: 'The global store should not be typed.',
52
+ recommended: 'warn',
53
+ suggestion: true
54
+ },
55
+ schema: [],
56
+ messages: (_a = {},
57
+ _a[exports.noTypedStore] = '`Store` should not be typed, use `Store` (without generic) instead.',
58
+ _a[exports.noTypedStoreSuggest] = 'Remove generic from `Store`.',
59
+ _a)
60
+ },
61
+ defaultOptions: [],
62
+ create: function (context) {
63
+ return {
64
+ Program: function () {
65
+ var e_1, _a;
66
+ var _b = (0, utils_1.getNgRxStores)(context).identifiers, identifiers = _b === void 0 ? [] : _b;
67
+ var _loop_1 = function (typeAnnotation) {
68
+ if (!(0, utils_1.isTSTypeReference)(typeAnnotation) ||
69
+ !typeAnnotation.typeParameters) {
70
+ return "continue";
71
+ }
72
+ var typeParameters = typeAnnotation.typeParameters;
73
+ context.report({
74
+ node: typeParameters,
75
+ messageId: exports.noTypedStore,
76
+ suggest: [
77
+ {
78
+ messageId: exports.noTypedStoreSuggest,
79
+ fix: function (fixer) { return fixer.remove(typeParameters); }
80
+ },
81
+ ]
82
+ });
83
+ };
84
+ try {
85
+ for (var identifiers_1 = __values(identifiers), identifiers_1_1 = identifiers_1.next(); !identifiers_1_1.done; identifiers_1_1 = identifiers_1.next()) {
86
+ var typeAnnotation = identifiers_1_1.value.typeAnnotation.typeAnnotation;
87
+ _loop_1(typeAnnotation);
88
+ }
89
+ }
90
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
91
+ finally {
92
+ try {
93
+ if (identifiers_1_1 && !identifiers_1_1.done && (_a = identifiers_1["return"])) _a.call(identifiers_1);
94
+ }
95
+ finally { if (e_1) throw e_1.error; }
96
+ }
97
+ }
98
+ };
99
+ }
100
+ });
101
+ //# sourceMappingURL=no-typed-global-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-typed-global-store.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-typed-global-store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA+D;AAElD,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAKzD,qBAAe,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,uCAAuC;YACpD,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,oBAAY,IACX,qEAAqE;YACvE,GAAC,2BAAmB,IAAG,8BAA8B;eACtD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;QACd,OAAO;YACL,OAAO;;gBACG,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mBAAG,EAAE,KAAA,CAA4B;wCAGhC,cAAc;oBAEhC,IACE,CAAC,IAAA,yBAAiB,EAAC,cAAc,CAAC;wBAClC,CAAC,cAAc,CAAC,cAAc,EAC9B;;qBAED;oBAEO,IAAA,cAAc,GAAK,cAAc,eAAnB,CAAoB;oBAE1C,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,cAAc;wBACpB,SAAS,EAAE,oBAAY;wBACvB,OAAO,EAAE;4BACP;gCACE,SAAS,EAAE,2BAAmB;gCAC9B,GAAG,EAAE,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,EAA5B,CAA4B;6BAC7C;yBACF;qBACF,CAAC,CAAC;;;oBArBL,KAEK,IAAA,gBAAA,SAAA,WAAW,CAAA,wCAAA;wBADI,IAAA,cAAc,sDAAA;gCAAd,cAAc;qBAqBjC;;;;;;;;;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getNgRxStores, isTSTypeReference } from '../../utils';\n\nexport const noTypedStore = 'noTypedStore';\nexport const noTypedStoreSuggest = 'noTypedStoreSuggest';\n\ntype MessageIds = typeof noTypedStore | typeof noTypedStoreSuggest;\ntype Options = readonly [];\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: 'The global store should not be typed.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [noTypedStore]:\n '`Store` should not be typed, use `Store` (without generic) instead.',\n [noTypedStoreSuggest]: 'Remove generic from `Store`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n Program() {\n const { identifiers = [] } = getNgRxStores(context);\n\n for (const {\n typeAnnotation: { typeAnnotation },\n } of identifiers) {\n if (\n !isTSTypeReference(typeAnnotation) ||\n !typeAnnotation.typeParameters\n ) {\n continue;\n }\n\n const { typeParameters } = typeAnnotation;\n\n context.report({\n node: typeParameters,\n messageId: noTypedStore,\n suggest: [\n {\n messageId: noTypedStoreSuggest,\n fix: (fixer) => fixer.remove(typeParameters),\n },\n ],\n });\n }\n },\n };\n },\n});\n"]}