@ngrx/eslint-plugin 14.0.1 → 14.2.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 +1 -1
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.js.map +1 -1
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js +10 -7
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -1
- package/src/utils/helper-functions/docs.js +1 -1
- package/src/utils/helper-functions/docs.js.map +1 -1
package/package.json
CHANGED
|
@@ -30,7 +30,7 @@ function addNgRxESLintPlugin(schema) {
|
|
|
30
30
|
json.overrides = [configurePlugin(schema.config)];
|
|
31
31
|
}
|
|
32
32
|
host.overwrite(eslintConfigPath, JSON.stringify(json, null, 2));
|
|
33
|
-
context.logger.info("\n The NgRx ESLint Plugin is installed and configured with the '".concat(schema.config, "' config.\n\n
|
|
33
|
+
context.logger.info("\n The NgRx ESLint Plugin is installed and configured with the '".concat(schema.config, "' config.\n\n Take a look at the docs at ").concat(docs, " if you want to change the default configuration.\n "));
|
|
34
34
|
return host;
|
|
35
35
|
}
|
|
36
36
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;AACA,4EAAoD;AAGpD,SAAwB,mBAAmB,CAAC,MAAc;IACxD,OAAO,UAAC,IAAU,EAAE,OAAyB;;QAC3C,IAAM,gBAAgB,GAAG,gBAAgB,CAAC;QAC1C,IAAM,IAAI,GAAG,qCAAqC,CAAC;QAEnD,IAAM,MAAM,GAAG,MAAA,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC9D,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,iDACc,gBAAgB,uFAG3C,IAAI,4CAChB,CAAC,CAAC;YACG,OAAO,IAAI,CAAC;SACb;QAED,IAAI;YACF,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,gCAAiB,EAAC,MAAM,CAAC,CAAC,CAAC;YACnD,IAAI,IAAI,CAAC,SAAS,EAAE;gBAClB,IACE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAC,QAAa;;oBACjC,OAAA,MAAA,QAAQ,CAAC,SAAO,CAAA,0CAAE,IAAI,CAAC,UAAC,MAAW;wBACjC,OAAA,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC;oBAAjC,CAAiC,CAClC,CAAA;iBAAA,CACF,EACD;oBACA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;iBACrD;aACF;iBAAM,IACL,CAAC,CAAA,MAAA,IAAI,CAAC,SAAO,CAAA,0CAAE,IAAI,CAAC,UAAC,MAAW,IAAK,OAAA,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,EAAjC,CAAiC,CAAC,CAAA,EACvE;gBACA,IAAI,CAAC,SAAS,GAAG,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;aACnD;YAED,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAEhE,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,2EACuC,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/schematics/ng-add/index.ts"],"names":[],"mappings":";;;;;AACA,4EAAoD;AAGpD,SAAwB,mBAAmB,CAAC,MAAc;IACxD,OAAO,UAAC,IAAU,EAAE,OAAyB;;QAC3C,IAAM,gBAAgB,GAAG,gBAAgB,CAAC;QAC1C,IAAM,IAAI,GAAG,qCAAqC,C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AC;SACb;QAAC,OAAO,GAAG,EAAE;YACZ,IAAM,cAAc,GAClB,GAAG,YAAY,KAAK;gBAClB,CAAC,CAAC,sBAEV,GAAG,CAAC,OAAO,OACZ;gBACS,CAAC,CAAC,EAAE,CAAC;YACT,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,6IAIb,IAAI,oDACf,cAAc,OACf,CAAC,CAAC;SACE;IACH,CAAC,CAAC;IACF,SAAS,eAAe,CAAC,MAAwB;QAC/C,OAAO;YACL,KAAK,EAAE,CAAC,MAAM,CAAC;YACf,SAAO,EAAE,CAAC,uBAAgB,MAAM,CAAE,CAAC;SACpC,CAAC;IACJ,CAAC;AACH,CAAC;AAjED,yCAiEC","sourcesContent":["import type { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';\nimport stripJsonComments from 'strip-json-comments';\nimport type { Schema } from './schema';\n\nexport default function addNgRxESLintPlugin(schema: Schema): Rule {\n return (host: Tree, context: SchematicContext) => {\n const eslintConfigPath = '.eslintrc.json';\n const docs = 'https://ngrx.io/guide/eslint-plugin';\n\n const eslint = host.read(eslintConfigPath)?.toString('utf-8');\n if (!eslint) {\n context.logger.warn(`\nCould not find the ESLint config at \\`${eslintConfigPath}\\`.\nThe NgRx ESLint Plugin is installed but not configured.\n\nPlease see ${docs} to configure the NgRx ESLint Plugin.\n`);\n return host;\n }\n\n try {\n const json = JSON.parse(stripJsonComments(eslint));\n if (json.overrides) {\n if (\n !json.overrides.some((override: any) =>\n override.extends?.some((extend: any) =>\n extend.startsWith('plugin:@ngrx')\n )\n )\n ) {\n json.overrides.push(configurePlugin(schema.config));\n }\n } else if (\n !json.extends?.some((extend: any) => extend.startsWith('plugin:@ngrx'))\n ) {\n json.overrides = [configurePlugin(schema.config)];\n }\n\n host.overwrite(eslintConfigPath, JSON.stringify(json, null, 2));\n\n context.logger.info(`\n The NgRx ESLint Plugin is installed and configured with the '${schema.config}' config.\n\n Take a look at the docs at ${docs} if you want to change the default configuration.\n `);\n return host;\n } catch (err) {\n const detailsContent =\n err instanceof Error\n ? `\nDetails:\n${err.message}\n`\n : '';\n context.logger.warn(`\nSomething went wrong while adding the NgRx ESLint Plugin.\nThe NgRx ESLint Plugin is installed but not configured.\n\nPlease see ${docs} to configure the NgRx ESLint Plugin.\n${detailsContent}\n`);\n }\n };\n function configurePlugin(config: Schema['config']): Record<string, unknown> {\n return {\n files: ['*.ts'],\n extends: [`plugin:@ngrx/${config}`],\n };\n }\n}\n"]}
|
|
@@ -62,17 +62,20 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
62
62
|
if (!storeNames) {
|
|
63
63
|
return {};
|
|
64
64
|
}
|
|
65
|
-
var collectedDispatches =
|
|
65
|
+
var collectedDispatches = [];
|
|
66
66
|
return _a = {},
|
|
67
67
|
_a["BlockStatement > ExpressionStatement > ".concat((0, utils_1.dispatchExpression)(storeNames))] = function (node) {
|
|
68
|
-
collectedDispatches.
|
|
68
|
+
collectedDispatches.push(node);
|
|
69
69
|
},
|
|
70
70
|
_a['BlockStatement:exit'] = function () {
|
|
71
71
|
var e_1, _a;
|
|
72
|
-
|
|
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
|
|
75
|
-
var node =
|
|
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 (
|
|
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.
|
|
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,
|
|
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
|
|
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,
|
|
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"]}
|