@ngrx/eslint-plugin 14.0.2 → 14.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ngrx/eslint-plugin",
3
- "version": "14.0.2",
3
+ "version": "14.1.0",
4
4
  "description": "NgRx ESLint Plugin",
5
5
  "repository": {
6
6
  "type": "git",
@@ -62,17 +62,20 @@ exports["default"] = (0, rule_creator_1.createRule)({
62
62
  if (!storeNames) {
63
63
  return {};
64
64
  }
65
- var collectedDispatches = new Set();
65
+ var collectedDispatches = [];
66
66
  return _a = {},
67
67
  _a["BlockStatement > ExpressionStatement > ".concat((0, utils_1.dispatchExpression)(storeNames))] = function (node) {
68
- collectedDispatches.add(node);
68
+ collectedDispatches.push(node);
69
69
  },
70
70
  _a['BlockStatement:exit'] = function () {
71
71
  var e_1, _a;
72
- if (collectedDispatches.size > 1) {
72
+ var withSameParent = collectedDispatches.filter(function (d1) {
73
+ return collectedDispatches.some(function (d2) { var _a, _b; return d2 !== d1 && ((_a = d2.parent) === null || _a === void 0 ? void 0 : _a.parent) === ((_b = d1.parent) === null || _b === void 0 ? void 0 : _b.parent); });
74
+ });
75
+ if (withSameParent.length > 1) {
73
76
  try {
74
- for (var collectedDispatches_1 = __values(collectedDispatches), collectedDispatches_1_1 = collectedDispatches_1.next(); !collectedDispatches_1_1.done; collectedDispatches_1_1 = collectedDispatches_1.next()) {
75
- var node = collectedDispatches_1_1.value;
77
+ for (var withSameParent_1 = __values(withSameParent), withSameParent_1_1 = withSameParent_1.next(); !withSameParent_1_1.done; withSameParent_1_1 = withSameParent_1.next()) {
78
+ var node = withSameParent_1_1.value;
76
79
  context.report({
77
80
  node: node,
78
81
  messageId: exports.messageId
@@ -82,12 +85,12 @@ exports["default"] = (0, rule_creator_1.createRule)({
82
85
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
83
86
  finally {
84
87
  try {
85
- if (collectedDispatches_1_1 && !collectedDispatches_1_1.done && (_a = collectedDispatches_1["return"])) _a.call(collectedDispatches_1);
88
+ if (withSameParent_1_1 && !withSameParent_1_1.done && (_a = withSameParent_1["return"])) _a.call(withSameParent_1);
86
89
  }
87
90
  finally { if (e_1) throw e_1.error; }
88
91
  }
89
92
  }
90
- collectedDispatches.clear();
93
+ collectedDispatches.length = 0;
91
94
  },
92
95
  _a;
93
96
  }
@@ -1 +1 @@
1
- {"version":3,"file":"avoid-dispatching-multiple-actions-sequentially.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-dispatching-multiple-actions-sequentially.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA2E;AAE9D,QAAA,SAAS,GAAG,6CAA6C,CAAC;AAKvE,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,4DAA4D;YACzE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0FAA0F;eAC7F;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,mBAAmB,GAAG,IAAI,GAAG,EAA2B,CAAC;QAE/D;YACE,GAAC,iDAA0C,IAAA,0BAAkB,EAC3D,UAAU,CACX,CAAE,IAFH,UAEK,IAA6B;gBAChC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAChC,CAAC;YACD,yBAAqB,GAArB;;gBACE,IAAI,mBAAmB,CAAC,IAAI,GAAG,CAAC,EAAE;;wBAChC,KAAmB,IAAA,wBAAA,SAAA,mBAAmB,CAAA,wDAAA,yFAAE;4BAAnC,IAAM,IAAI,gCAAA;4BACb,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI,MAAA;gCACJ,SAAS,mBAAA;6BACV,CAAC,CAAC;yBACJ;;;;;;;;;iBACF;gBAED,mBAAmB,CAAC,KAAK,EAAE,CAAC;YAC9B,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, dispatchExpression, getNgRxStores } from '../../utils';\n\nexport const messageId = 'avoidDispatchingMultipleActionsSequentially';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'It is recommended to only dispatch one `Action` at a time.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Avoid dispatching many actions in a row to accomplish a larger conceptual \"transaction\".',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const collectedDispatches = new Set<TSESTree.CallExpression>();\n\n return {\n [`BlockStatement > ExpressionStatement > ${dispatchExpression(\n storeNames\n )}`](node: TSESTree.CallExpression) {\n collectedDispatches.add(node);\n },\n 'BlockStatement:exit'() {\n if (collectedDispatches.size > 1) {\n for (const node of collectedDispatches) {\n context.report({\n node,\n messageId,\n });\n }\n }\n\n collectedDispatches.clear();\n },\n };\n },\n});\n"]}
1
+ {"version":3,"file":"avoid-dispatching-multiple-actions-sequentially.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-dispatching-multiple-actions-sequentially.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA2E;AAE9D,QAAA,SAAS,GAAG,6CAA6C,CAAC;AAKvE,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,4DAA4D;YACzE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0FAA0F;eAC7F;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,mBAAmB,GAA8B,EAAE,CAAC;QAE1D;YACE,GAAC,iDAA0C,IAAA,0BAAkB,EAC3D,UAAU,CACX,CAAE,IAFH,UAEK,IAA6B;gBAChC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACjC,CAAC;YACD,yBAAqB,GAArB;;gBACE,IAAM,cAAc,GAAG,mBAAmB,CAAC,MAAM,CAAC,UAAC,EAAE;oBACnD,OAAA,mBAAmB,CAAC,IAAI,CACtB,UAAC,EAAE,gBAAK,OAAA,EAAE,KAAK,EAAE,IAAI,CAAA,MAAA,EAAE,CAAC,MAAM,0CAAE,MAAM,OAAK,MAAA,EAAE,CAAC,MAAM,0CAAE,MAAM,CAAA,CAAA,EAAA,CAC7D;gBAFD,CAEC,CACF,CAAC;gBACF,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE;;wBAC7B,KAAmB,IAAA,mBAAA,SAAA,cAAc,CAAA,8CAAA,0EAAE;4BAA9B,IAAM,IAAI,2BAAA;4BACb,OAAO,CAAC,MAAM,CAAC;gCACb,IAAI,MAAA;gCACJ,SAAS,mBAAA;6BACV,CAAC,CAAC;yBACJ;;;;;;;;;iBACF;gBAED,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC;YACjC,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, dispatchExpression, getNgRxStores } from '../../utils';\n\nexport const messageId = 'avoidDispatchingMultipleActionsSequentially';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'It is recommended to only dispatch one `Action` at a time.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]:\n 'Avoid dispatching many actions in a row to accomplish a larger conceptual \"transaction\".',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const collectedDispatches: TSESTree.CallExpression[] = [];\n\n return {\n [`BlockStatement > ExpressionStatement > ${dispatchExpression(\n storeNames\n )}`](node: TSESTree.CallExpression) {\n collectedDispatches.push(node);\n },\n 'BlockStatement:exit'() {\n const withSameParent = collectedDispatches.filter((d1) =>\n collectedDispatches.some(\n (d2) => d2 !== d1 && d2.parent?.parent === d1.parent?.parent\n )\n );\n if (withSameParent.length > 1) {\n for (const node of withSameParent) {\n context.report({\n node,\n messageId,\n });\n }\n }\n\n collectedDispatches.length = 0;\n },\n };\n },\n});\n"]}
@@ -2,7 +2,7 @@
2
2
  exports.__esModule = true;
3
3
  exports.docsUrl = void 0;
4
4
  var docsUrl = function (ruleName) {
5
- return "https://ngrx.io/guide/eslint-plugin/rules/".concat(ruleName, ".md");
5
+ return "https://ngrx.io/guide/eslint-plugin/rules/".concat(ruleName);
6
6
  };
7
7
  exports.docsUrl = docsUrl;
8
8
  //# sourceMappingURL=docs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"docs.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/docs.ts"],"names":[],"mappings":";;;AAAO,IAAM,OAAO,GAAG,UAAC,QAAgB;IACtC,OAAA,oDAA6C,QAAQ,QAAK;AAA1D,CAA0D,CAAC;AADhD,QAAA,OAAO,WACyC","sourcesContent":["export const docsUrl = (ruleName: string) =>\n `https://ngrx.io/guide/eslint-plugin/rules/${ruleName}.md`;\n"]}
1
+ {"version":3,"file":"docs.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/docs.ts"],"names":[],"mappings":";;;AAAO,IAAM,OAAO,GAAG,UAAC,QAAgB;IACtC,OAAA,oDAA6C,QAAQ,CAAE;AAAvD,CAAuD,CAAC;AAD7C,QAAA,OAAO,WACsC","sourcesContent":["export const docsUrl = (ruleName: string) =>\n `https://ngrx.io/guide/eslint-plugin/rules/${ruleName}`;\n"]}