@ngrx/eslint-plugin 15.4.0 → 16.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.
- package/jest.config.js +17 -14
- package/jest.config.js.map +1 -1
- package/package.json +1 -1
- package/schematics/ng-add/index.js +6 -6
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.js +1 -1
- package/scripts/generate-config.js +2 -2
- package/scripts/generate-docs.js +2 -2
- package/scripts/generate-overview.js +1 -1
- package/spec/utils/index.js +3 -3
- package/src/configs/all-requiring-type-checking.js +3 -3
- package/src/configs/all.js +2 -2
- package/src/configs/component-store-strict.js +1 -1
- package/src/configs/component-store.js +1 -1
- package/src/configs/effects-requiring-type-checking.js +3 -3
- package/src/configs/effects-strict-requiring-type-checking.js +3 -3
- package/src/configs/effects-strict.js +2 -2
- package/src/configs/effects.js +2 -2
- package/src/configs/index.js +3 -3
- package/src/configs/index.js.map +1 -1
- package/src/configs/recommended-requiring-type-checking.js +3 -3
- package/src/configs/recommended.js +2 -2
- package/src/configs/store-strict.js +2 -2
- package/src/configs/store.js +2 -2
- package/src/configs/strict-requiring-type-checking.js +3 -3
- package/src/configs/strict.js +2 -2
- package/src/index.js +1 -1
- package/src/rule-creator.js +1 -1
- package/src/rules/component-store/updater-explicit-return-type.js +6 -6
- package/src/rules/component-store/updater-explicit-return-type.js.map +1 -1
- package/src/rules/effects/avoid-cyclic-effects.js +8 -8
- package/src/rules/effects/avoid-cyclic-effects.js.map +1 -1
- package/src/rules/effects/no-dispatch-in-effects.js +7 -7
- package/src/rules/effects/no-dispatch-in-effects.js.map +1 -1
- package/src/rules/effects/no-effects-in-providers.js +7 -7
- package/src/rules/effects/no-effects-in-providers.js.map +1 -1
- package/src/rules/effects/no-multiple-actions-in-effects.js +6 -6
- package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -1
- package/src/rules/effects/prefer-action-creator-in-of-type.js +6 -6
- package/src/rules/effects/prefer-action-creator-in-of-type.js.map +1 -1
- package/src/rules/effects/prefer-concat-latest-from.js +13 -13
- package/src/rules/effects/prefer-concat-latest-from.js.map +1 -1
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js +6 -6
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -1
- package/src/rules/effects/use-effects-lifecycle-interface.js +9 -9
- package/src/rules/effects/use-effects-lifecycle-interface.js.map +1 -1
- package/src/rules/index.js +3 -3
- package/src/rules/index.js.map +1 -1
- package/src/rules/store/avoid-combining-selectors.js +7 -7
- package/src/rules/store/avoid-combining-selectors.js.map +1 -1
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js +7 -7
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -1
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js +10 -10
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -1
- package/src/rules/store/avoid-mapping-selectors.js +6 -6
- package/src/rules/store/avoid-mapping-selectors.js.map +1 -1
- package/src/rules/store/good-action-hygiene.js +7 -7
- package/src/rules/store/good-action-hygiene.js.map +1 -1
- package/src/rules/store/no-multiple-global-stores.js +10 -10
- package/src/rules/store/no-multiple-global-stores.js.map +1 -1
- package/src/rules/store/no-reducer-in-key-names.js +7 -7
- package/src/rules/store/no-reducer-in-key-names.js.map +1 -1
- package/src/rules/store/no-store-subscription.js +6 -6
- package/src/rules/store/no-store-subscription.js.map +1 -1
- package/src/rules/store/no-typed-global-store.js +9 -9
- package/src/rules/store/no-typed-global-store.js.map +1 -1
- package/src/rules/store/on-function-explicit-return-type.js +7 -7
- package/src/rules/store/on-function-explicit-return-type.js.map +1 -1
- package/src/rules/store/prefer-action-creator-in-dispatch.js +6 -6
- package/src/rules/store/prefer-action-creator-in-dispatch.js.map +1 -1
- package/src/rules/store/prefer-action-creator.js +6 -6
- package/src/rules/store/prefer-action-creator.js.map +1 -1
- package/src/rules/store/prefer-inline-action-props.js +7 -7
- package/src/rules/store/prefer-inline-action-props.js.map +1 -1
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js +7 -7
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js.map +1 -1
- package/src/rules/store/prefer-selector-in-select.js +7 -7
- package/src/rules/store/prefer-selector-in-select.js.map +1 -1
- package/src/rules/store/prefix-selectors-with-select.js +9 -9
- package/src/rules/store/prefix-selectors-with-select.js.map +1 -1
- package/src/rules/store/select-style.js +12 -12
- package/src/rules/store/select-style.js.map +1 -1
- package/src/rules/store/use-consistent-global-store-name.js +10 -10
- package/src/rules/store/use-consistent-global-store-name.js.map +1 -1
- package/src/utils/helper-functions/docs.js +1 -1
- package/src/utils/helper-functions/folder.js +4 -4
- package/src/utils/helper-functions/guards.js +1 -1
- package/src/utils/helper-functions/index.js +1 -1
- package/src/utils/helper-functions/ngrx-modules.js +1 -1
- package/src/utils/helper-functions/utils.js +3 -3
- package/src/utils/helper-functions/versions.js +1 -1
- package/src/utils/index.js +1 -1
- package/src/utils/selectors/index.js +1 -1
|
@@ -34,25 +34,25 @@ var __values = (this && this.__values) || function(o) {
|
|
|
34
34
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
35
35
|
};
|
|
36
36
|
var _a;
|
|
37
|
-
exports
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.messageId = void 0;
|
|
39
39
|
var path = __importStar(require("path"));
|
|
40
40
|
var rule_creator_1 = require("../../rule-creator");
|
|
41
41
|
var utils_1 = require("../../utils");
|
|
42
42
|
exports.messageId = 'avoidCombiningSelectors';
|
|
43
|
-
exports
|
|
43
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
44
44
|
name: path.parse(__filename).name,
|
|
45
45
|
meta: {
|
|
46
46
|
type: 'suggestion',
|
|
47
47
|
ngrxModule: 'store',
|
|
48
48
|
docs: {
|
|
49
49
|
description: 'Prefer combining selectors at the selector level.',
|
|
50
|
-
recommended: 'warn'
|
|
50
|
+
recommended: 'warn',
|
|
51
51
|
},
|
|
52
52
|
schema: [],
|
|
53
53
|
messages: (_a = {},
|
|
54
54
|
_a[exports.messageId] = 'Combine selectors at the selector level.',
|
|
55
|
-
_a)
|
|
55
|
+
_a),
|
|
56
56
|
},
|
|
57
57
|
defaultOptions: [],
|
|
58
58
|
create: function (context) {
|
|
@@ -75,20 +75,20 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
75
75
|
var node = selectsInArray_1_1.value;
|
|
76
76
|
context.report({
|
|
77
77
|
node: node,
|
|
78
|
-
messageId: exports.messageId
|
|
78
|
+
messageId: exports.messageId,
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
83
83
|
finally {
|
|
84
84
|
try {
|
|
85
|
-
if (selectsInArray_1_1 && !selectsInArray_1_1.done && (_a = selectsInArray_1
|
|
85
|
+
if (selectsInArray_1_1 && !selectsInArray_1_1.done && (_a = selectsInArray_1.return)) _a.call(selectsInArray_1);
|
|
86
86
|
}
|
|
87
87
|
finally { if (e_1) throw e_1.error; }
|
|
88
88
|
}
|
|
89
89
|
selectsInArray.length = 0;
|
|
90
90
|
},
|
|
91
91
|
_a;
|
|
92
|
-
}
|
|
92
|
+
},
|
|
93
93
|
});
|
|
94
94
|
//# sourceMappingURL=avoid-combining-selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-combining-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-combining-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAKqB;AAER,QAAA,SAAS,GAAG,yBAAyB,CAAC;AAKnD,
|
|
1
|
+
{"version":3,"file":"avoid-combining-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-combining-selectors.ts"],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,CAAC;4BACb,IAAI,MAAA;4BACJ,SAAS,mBAAA;yBACV,CAAC,CAAC;qBACJ;;;;;;;;;gBACD,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;YAC5B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n namedExpression,\n selectExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidCombiningSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Prefer combining selectors at the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Combine selectors at the selector level.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeableOrStoreSelect = `:matches(${namedExpression(\n storeNames\n )}[callee.property.name='pipe']:has(CallExpression[callee.name='select']), ${selectExpression(\n storeNames\n )})` as const;\n\n const selectsInArray: TSESTree.CallExpression[] = [];\n return {\n [`CallExpression[callee.name='combineLatest'] ${pipeableOrStoreSelect} ~ ${pipeableOrStoreSelect}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest']:exit`]() {\n for (const node of selectsInArray) {\n context.report({\n node,\n messageId,\n });\n }\n selectsInArray.length = 0;\n },\n };\n },\n});\n"]}
|
|
@@ -34,25 +34,25 @@ var __values = (this && this.__values) || function(o) {
|
|
|
34
34
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
35
35
|
};
|
|
36
36
|
var _a;
|
|
37
|
-
exports
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.messageId = void 0;
|
|
39
39
|
var path = __importStar(require("path"));
|
|
40
40
|
var rule_creator_1 = require("../../rule-creator");
|
|
41
41
|
var utils_1 = require("../../utils");
|
|
42
42
|
exports.messageId = 'avoidDispatchingMultipleActionsSequentially';
|
|
43
|
-
exports
|
|
43
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
44
44
|
name: path.parse(__filename).name,
|
|
45
45
|
meta: {
|
|
46
46
|
type: 'suggestion',
|
|
47
47
|
ngrxModule: 'store',
|
|
48
48
|
docs: {
|
|
49
49
|
description: 'It is recommended to only dispatch one `Action` at a time.',
|
|
50
|
-
recommended: 'warn'
|
|
50
|
+
recommended: 'warn',
|
|
51
51
|
},
|
|
52
52
|
schema: [],
|
|
53
53
|
messages: (_a = {},
|
|
54
54
|
_a[exports.messageId] = 'Avoid dispatching many actions in a row to accomplish a larger conceptual "transaction".',
|
|
55
|
-
_a)
|
|
55
|
+
_a),
|
|
56
56
|
},
|
|
57
57
|
defaultOptions: [],
|
|
58
58
|
create: function (context) {
|
|
@@ -78,14 +78,14 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
78
78
|
var node = withSameParent_1_1.value;
|
|
79
79
|
context.report({
|
|
80
80
|
node: node,
|
|
81
|
-
messageId: exports.messageId
|
|
81
|
+
messageId: exports.messageId,
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
86
86
|
finally {
|
|
87
87
|
try {
|
|
88
|
-
if (withSameParent_1_1 && !withSameParent_1_1.done && (_a = withSameParent_1
|
|
88
|
+
if (withSameParent_1_1 && !withSameParent_1_1.done && (_a = withSameParent_1.return)) _a.call(withSameParent_1);
|
|
89
89
|
}
|
|
90
90
|
finally { if (e_1) throw e_1.error; }
|
|
91
91
|
}
|
|
@@ -93,6 +93,6 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
93
93
|
collectedDispatches.length = 0;
|
|
94
94
|
},
|
|
95
95
|
_a;
|
|
96
|
-
}
|
|
96
|
+
},
|
|
97
97
|
});
|
|
98
98
|
//# sourceMappingURL=avoid-dispatching-multiple-actions-sequentially.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-dispatching-multiple-actions-sequentially.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-dispatching-multiple-actions-sequentially.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA2E;AAE9D,QAAA,SAAS,GAAG,6CAA6C,CAAC;AAKvE,
|
|
1
|
+
{"version":3,"file":"avoid-dispatching-multiple-actions-sequentially.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-dispatching-multiple-actions-sequentially.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA2E;AAE9D,QAAA,SAAS,GAAG,6CAA6C,CAAC;AAKvE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,4DAA4D;YACzE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IACR,0FAA0F;eAC7F;KACF;IACD,cAAc,EAAE,EAAE;IAClB,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"]}
|
|
@@ -59,14 +59,14 @@ var __values = (this && this.__values) || function(o) {
|
|
|
59
59
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
60
60
|
};
|
|
61
61
|
var _a;
|
|
62
|
-
exports
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
63
|
exports.avoidDuplicateActionsInReducerSuggest = exports.avoidDuplicateActionsInReducer = void 0;
|
|
64
64
|
var path = __importStar(require("path"));
|
|
65
65
|
var rule_creator_1 = require("../../rule-creator");
|
|
66
66
|
var utils_1 = require("../../utils");
|
|
67
67
|
exports.avoidDuplicateActionsInReducer = 'avoidDuplicateActionsInReducer';
|
|
68
68
|
exports.avoidDuplicateActionsInReducerSuggest = 'avoidDuplicateActionsInReducerSuggest';
|
|
69
|
-
exports
|
|
69
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
70
70
|
name: path.parse(__filename).name,
|
|
71
71
|
meta: {
|
|
72
72
|
type: 'suggestion',
|
|
@@ -75,13 +75,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
75
75
|
docs: {
|
|
76
76
|
description: 'A `Reducer` should handle an `Action` once.',
|
|
77
77
|
recommended: 'warn',
|
|
78
|
-
suggestion: true
|
|
78
|
+
suggestion: true,
|
|
79
79
|
},
|
|
80
80
|
schema: [],
|
|
81
81
|
messages: (_a = {},
|
|
82
82
|
_a[exports.avoidDuplicateActionsInReducer] = 'The `Reducer` handles a duplicate `Action` `{{ actionName }}`.',
|
|
83
83
|
_a[exports.avoidDuplicateActionsInReducerSuggest] = 'Remove this duplication.',
|
|
84
|
-
_a)
|
|
84
|
+
_a),
|
|
85
85
|
},
|
|
86
86
|
defaultOptions: [],
|
|
87
87
|
create: function (context) {
|
|
@@ -108,16 +108,16 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
108
108
|
node: node,
|
|
109
109
|
messageId: exports.avoidDuplicateActionsInReducer,
|
|
110
110
|
data: {
|
|
111
|
-
actionName: actionName
|
|
111
|
+
actionName: actionName,
|
|
112
112
|
},
|
|
113
113
|
suggest: [
|
|
114
114
|
{
|
|
115
115
|
messageId: exports.avoidDuplicateActionsInReducerSuggest,
|
|
116
116
|
fix: function (fixer) {
|
|
117
117
|
return (0, utils_1.getNodeToCommaRemoveFix)(sourceCode, fixer, node.parent);
|
|
118
|
-
}
|
|
118
|
+
},
|
|
119
119
|
},
|
|
120
|
-
]
|
|
120
|
+
],
|
|
121
121
|
});
|
|
122
122
|
};
|
|
123
123
|
try {
|
|
@@ -129,7 +129,7 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
129
129
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
130
130
|
finally {
|
|
131
131
|
try {
|
|
132
|
-
if (identifiers_1_1 && !identifiers_1_1.done && (_b = identifiers_1
|
|
132
|
+
if (identifiers_1_1 && !identifiers_1_1.done && (_b = identifiers_1.return)) _b.call(identifiers_1);
|
|
133
133
|
}
|
|
134
134
|
finally { if (e_2) throw e_2.error; }
|
|
135
135
|
}
|
|
@@ -138,13 +138,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
138
138
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
139
139
|
finally {
|
|
140
140
|
try {
|
|
141
|
-
if (collectedActions_1_1 && !collectedActions_1_1.done && (_a = collectedActions_1
|
|
141
|
+
if (collectedActions_1_1 && !collectedActions_1_1.done && (_a = collectedActions_1.return)) _a.call(collectedActions_1);
|
|
142
142
|
}
|
|
143
143
|
finally { if (e_1) throw e_1.error; }
|
|
144
144
|
}
|
|
145
145
|
collectedActions.clear();
|
|
146
146
|
},
|
|
147
147
|
_a;
|
|
148
|
-
}
|
|
148
|
+
},
|
|
149
149
|
});
|
|
150
150
|
//# sourceMappingURL=avoid-duplicate-actions-in-reducer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-duplicate-actions-in-reducer.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-duplicate-actions-in-reducer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAqE;AAExD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAClE,QAAA,qCAAqC,GAChD,uCAAuC,CAAC;AAQ1C,
|
|
1
|
+
{"version":3,"file":"avoid-duplicate-actions-in-reducer.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-duplicate-actions-in-reducer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAqE;AAExD,QAAA,8BAA8B,GAAG,gCAAgC,CAAC;AAClE,QAAA,qCAAqC,GAChD,uCAAuC,CAAC;AAQ1C,kBAAe,IAAA,yB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AAE;oCACP;wCACE,SAAS,EAAE,6CAAqC;wCAChD,GAAG,EAAE,UAAC,KAAK;4CACT,OAAA,IAAA,+BAAuB,EAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;wCAAvD,CAAuD;qCAC1D;iCACF;6BACF,CAAC,CAAC;;;4BAdL,KAAmB,IAAA,+BAAA,SAAA,WAAW,CAAA,CAAA,wCAAA;gCAAzB,IAAM,IAAI,wBAAA;wCAAJ,IAAI;6BAed;;;;;;;;;qBACF;;;;;;;;;gBAED,gBAAgB,CAAC,KAAK,EAAE,CAAC;YAC3B,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { createReducer, getNodeToCommaRemoveFix } from '../../utils';\n\nexport const avoidDuplicateActionsInReducer = 'avoidDuplicateActionsInReducer';\nexport const avoidDuplicateActionsInReducerSuggest =\n 'avoidDuplicateActionsInReducerSuggest';\n\ntype MessageIds =\n | typeof avoidDuplicateActionsInReducer\n | typeof avoidDuplicateActionsInReducerSuggest;\ntype Options = readonly [];\ntype Action = TSESTree.Identifier & { parent: TSESTree.CallExpression };\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'A `Reducer` should handle an `Action` once.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [avoidDuplicateActionsInReducer]:\n 'The `Reducer` handles a duplicate `Action` `{{ actionName }}`.',\n [avoidDuplicateActionsInReducerSuggest]: 'Remove this duplication.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const collectedActions = new Map<string, Action[]>();\n\n return {\n [`${createReducer} > CallExpression[callee.name='on'][arguments.0.type='Identifier']`]({\n arguments: [action],\n }: TSESTree.CallExpression & {\n arguments: Action[];\n }) {\n const actions = collectedActions.get(action.name) ?? [];\n collectedActions.set(action.name, [...actions, action]);\n },\n [`${createReducer}:exit`]() {\n for (const [actionName, identifiers] of collectedActions) {\n if (identifiers.length <= 1) {\n break;\n }\n\n for (const node of identifiers) {\n context.report({\n node,\n messageId: avoidDuplicateActionsInReducer,\n data: {\n actionName,\n },\n suggest: [\n {\n messageId: avoidDuplicateActionsInReducerSuggest,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(sourceCode, fixer, node.parent),\n },\n ],\n });\n }\n }\n\n collectedActions.clear();\n },\n };\n },\n});\n"]}
|
|
@@ -23,26 +23,26 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
var _a;
|
|
26
|
-
exports
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.messageId = void 0;
|
|
28
28
|
var eslint_etc_1 = require("eslint-etc");
|
|
29
29
|
var path = __importStar(require("path"));
|
|
30
30
|
var rule_creator_1 = require("../../rule-creator");
|
|
31
31
|
var utils_1 = require("../../utils");
|
|
32
32
|
exports.messageId = 'avoidMapppingSelectors';
|
|
33
|
-
exports
|
|
33
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
34
34
|
name: path.parse(__filename).name,
|
|
35
35
|
meta: {
|
|
36
36
|
type: 'suggestion',
|
|
37
37
|
ngrxModule: 'store',
|
|
38
38
|
docs: {
|
|
39
39
|
description: 'Avoid mapping logic outside the selector level.',
|
|
40
|
-
recommended: 'warn'
|
|
40
|
+
recommended: 'warn',
|
|
41
41
|
},
|
|
42
42
|
schema: [],
|
|
43
43
|
messages: (_a = {},
|
|
44
44
|
_a[exports.messageId] = 'Map logic at the selector level instead.',
|
|
45
|
-
_a)
|
|
45
|
+
_a),
|
|
46
46
|
},
|
|
47
47
|
defaultOptions: [],
|
|
48
48
|
create: function (context) {
|
|
@@ -89,11 +89,11 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
89
89
|
if (mapOperator) {
|
|
90
90
|
context.report({
|
|
91
91
|
node: mapOperator,
|
|
92
|
-
messageId: exports.messageId
|
|
92
|
+
messageId: exports.messageId,
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
_a;
|
|
97
|
-
}
|
|
97
|
+
},
|
|
98
98
|
});
|
|
99
99
|
//# sourceMappingURL=avoid-mapping-selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-mapping-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-mapping-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA4D;AAC5D,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,
|
|
1
|
+
{"version":3,"file":"avoid-mapping-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/avoid-mapping-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA4D;AAC5D,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAKlD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;YAC9D,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IAAG,0CAA0C;eACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACN,IAAA,KAAqB,IAAA,qBAAa,EAAC,OAAO,CAAC,YAA3B,EAAhB,WAAW,mB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AI,CAChC,UAAC,QAAQ;oBACP,OAAA,IAAA,6BAAgB,EAAC,QAAQ,CAAC;wBAC1B,IAAA,yBAAY,EAAC,QAAQ,CAAC,MAAM,CAAC;wBAC7B,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,KAAK;gBAF9B,CAE8B,CACjC,CAAC;gBACF,IAAI,WAAW,EAAE;oBACf,OAAO,CAAC,MAAM,CAAC;wBACb,IAAI,EAAE,WAAW;wBACjB,SAAS,mBAAA;qBACV,CAAC,CAAC;iBACJ;YACH,CAAC;eACD;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { isCallExpression, isIdentifier } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxStores,\n isMemberExpression,\n namedCallableExpression,\n pipeExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidMapppingSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description: 'Avoid mapping logic outside the selector level.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Map logic at the selector level instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n const pipeWithSelectAndMapSelector = `${pipeExpression(\n storeNames\n )}:has(CallExpression[callee.name='select'] ~ CallExpression[callee.name='map'])` as const;\n const selectSelector = `${namedCallableExpression(\n storeNames\n )}[callee.object.callee.property.name='select']` as const;\n\n function isInCreateEffect(node: TSESTree.CallExpression) {\n let parent = node.parent;\n while (parent) {\n if (\n isCallExpression(parent) &&\n isIdentifier(parent.callee) &&\n parent.callee.name === 'createEffect'\n ) {\n return true;\n }\n parent = parent.parent;\n }\n return false;\n }\n\n let pipeHasThisExpression = false;\n\n const selectorQuery = `:matches(${selectSelector}, ${pipeWithSelectAndMapSelector})`;\n return {\n [`${selectorQuery} > CallExpression:has(ThisExpression)`](\n node: TSESTree.CallExpression\n ) {\n pipeHasThisExpression = true;\n },\n [`${selectorQuery}[callee.property.name=pipe]:exit`](\n node: TSESTree.CallExpression\n ) {\n if (pipeHasThisExpression) {\n pipeHasThisExpression = false;\n return;\n }\n\n if (isInCreateEffect(node)) {\n return;\n }\n\n const operators = node.arguments;\n const mapOperator = operators.find(\n (operator) =>\n isCallExpression(operator) &&\n isIdentifier(operator.callee) &&\n operator.callee.name === 'map'\n );\n if (mapOperator) {\n context.report({\n node: mapOperator,\n messageId,\n });\n }\n },\n };\n },\n});\n"]}
|
|
@@ -39,25 +39,25 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
39
39
|
return ar;
|
|
40
40
|
};
|
|
41
41
|
var _a;
|
|
42
|
-
exports
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
exports.messageId = void 0;
|
|
44
44
|
var path = __importStar(require("path"));
|
|
45
45
|
var rule_creator_1 = require("../../rule-creator");
|
|
46
46
|
var utils_1 = require("../../utils");
|
|
47
47
|
exports.messageId = 'goodActionHygiene';
|
|
48
|
-
exports
|
|
48
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
49
49
|
name: path.parse(__filename).name,
|
|
50
50
|
meta: {
|
|
51
51
|
type: 'suggestion',
|
|
52
52
|
ngrxModule: 'store',
|
|
53
53
|
docs: {
|
|
54
54
|
description: 'Ensures the use of good action hygiene.',
|
|
55
|
-
recommended: 'warn'
|
|
55
|
+
recommended: 'warn',
|
|
56
56
|
},
|
|
57
57
|
schema: [],
|
|
58
58
|
messages: (_a = {},
|
|
59
59
|
_a[exports.messageId] = 'Action type `{{ actionType }}` does not follow the good action hygiene practice, use "[Source] {{ actionType }}" to define action types.',
|
|
60
|
-
_a)
|
|
60
|
+
_a),
|
|
61
61
|
},
|
|
62
62
|
defaultOptions: [],
|
|
63
63
|
create: function (context) {
|
|
@@ -74,11 +74,11 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
74
74
|
node: node,
|
|
75
75
|
messageId: exports.messageId,
|
|
76
76
|
data: {
|
|
77
|
-
actionType: actionType
|
|
78
|
-
}
|
|
77
|
+
actionType: actionType,
|
|
78
|
+
},
|
|
79
79
|
});
|
|
80
80
|
},
|
|
81
81
|
_a;
|
|
82
|
-
}
|
|
82
|
+
},
|
|
83
83
|
});
|
|
84
84
|
//# sourceMappingURL=good-action-hygiene.js.map
|
|
@@ -1 +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,
|
|
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,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,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"]}
|
|
@@ -59,14 +59,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
59
59
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
60
60
|
};
|
|
61
61
|
var _a;
|
|
62
|
-
exports
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
63
|
exports.noMultipleGlobalStoresSuggest = exports.noMultipleGlobalStores = void 0;
|
|
64
64
|
var path = __importStar(require("path"));
|
|
65
65
|
var rule_creator_1 = require("../../rule-creator");
|
|
66
66
|
var utils_1 = require("../../utils");
|
|
67
67
|
exports.noMultipleGlobalStores = 'noMultipleGlobalStores';
|
|
68
68
|
exports.noMultipleGlobalStoresSuggest = 'noMultipleGlobalStoresSuggest';
|
|
69
|
-
exports
|
|
69
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
70
70
|
name: path.parse(__filename).name,
|
|
71
71
|
meta: {
|
|
72
72
|
type: 'suggestion',
|
|
@@ -75,13 +75,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
75
75
|
docs: {
|
|
76
76
|
description: 'There should only be one global store injected.',
|
|
77
77
|
recommended: 'warn',
|
|
78
|
-
suggestion: true
|
|
78
|
+
suggestion: true,
|
|
79
79
|
},
|
|
80
80
|
schema: [],
|
|
81
81
|
messages: (_a = {},
|
|
82
82
|
_a[exports.noMultipleGlobalStores] = 'Global store should be injected only once.',
|
|
83
83
|
_a[exports.noMultipleGlobalStoresSuggest] = 'Remove this reference.',
|
|
84
|
-
_a)
|
|
84
|
+
_a),
|
|
85
85
|
},
|
|
86
86
|
defaultOptions: [],
|
|
87
87
|
create: function (context) {
|
|
@@ -104,9 +104,9 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
104
104
|
suggest: [
|
|
105
105
|
{
|
|
106
106
|
messageId: exports.noMultipleGlobalStoresSuggest,
|
|
107
|
-
fix: function (fixer) { return getFixes(sourceCode, fixer, nodeToReport); }
|
|
107
|
+
fix: function (fixer) { return getFixes(sourceCode, fixer, nodeToReport); },
|
|
108
108
|
},
|
|
109
|
-
]
|
|
109
|
+
],
|
|
110
110
|
});
|
|
111
111
|
};
|
|
112
112
|
try {
|
|
@@ -118,7 +118,7 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
118
118
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
119
119
|
finally {
|
|
120
120
|
try {
|
|
121
|
-
if (identifiers_1_1 && !identifiers_1_1.done && (_b = identifiers_1
|
|
121
|
+
if (identifiers_1_1 && !identifiers_1_1.done && (_b = identifiers_1.return)) _b.call(identifiers_1);
|
|
122
122
|
}
|
|
123
123
|
finally { if (e_2) throw e_2.error; }
|
|
124
124
|
}
|
|
@@ -127,13 +127,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
127
127
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
128
128
|
finally {
|
|
129
129
|
try {
|
|
130
|
-
if (flattenedIdentifiers_1_1 && !flattenedIdentifiers_1_1.done && (_a = flattenedIdentifiers_1
|
|
130
|
+
if (flattenedIdentifiers_1_1 && !flattenedIdentifiers_1_1.done && (_a = flattenedIdentifiers_1.return)) _a.call(flattenedIdentifiers_1);
|
|
131
131
|
}
|
|
132
132
|
finally { if (e_1) throw e_1.error; }
|
|
133
133
|
}
|
|
134
|
-
}
|
|
134
|
+
},
|
|
135
135
|
};
|
|
136
|
-
}
|
|
136
|
+
},
|
|
137
137
|
});
|
|
138
138
|
function getNodeToReport(node) {
|
|
139
139
|
return node.parent && (0, utils_1.isTSParameterProperty)(node.parent) ? node.parent : node;
|
|
@@ -1 +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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAIqB;AAER,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,6BAA6B,GAAG,+BAA+B,CAAC;AAO7E,
|
|
1
|
+
{"version":3,"file":"no-multiple-global-stores.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-multiple-global-stores.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAIqB;AAER,QAAA,sBAAsB,GAAG,wBAAwB,CAAC;AAClD,QAAA,6BAA6B,GAAG,+BAA+B,CAAC;AAO7E,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;YAC9D,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,8BAAsB,IAAG,4CAA4C;YACtE,GAAC,qCAA6B,IAAG,wBAAwB;eAC1D;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;QACd,OAAO;YACL,OAAO;;gBACC,IAAA,KAAmC,IAAA,qBAAa,EAAC,OAAO,CAAC,EAAvD,mBAAgB,EAAhB,WAAW,mBAAG,EAAE,KAAA,EAAE,UAAU,gBAA2B,CAAC;gBAChE,IAAM,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,EAAE,CAAC;;oBAE3D,KAA0B,IAAA,yBAAA,SAAA,oBAAoB,CAAA,0DAAA,4FAAE;wBAA3C,IAAM,aAAW,iCAAA;wBACpB,IAAI,aAAW,CAAC,MAAM,IAAI,CAAC,EAAE;4BAC3B,SAAS;yBACV;gDAEU,IAAI;4BACb,IAAM,YAAY,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;4BAC3C,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AAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrD,OAAO,WAAW,CAAC,GAAG,CAAC,MAAM,yCACxB,CAAC,oBAAoB,aAApB,oBAAoB,cAApB,oBAAoB,GAAI,EAAE,CAAC;YAC/B,UAAU;kBACV,CAAC;IACL,CAAC,EACD,IAAI,GAAG,EAAE,CACV,CAAC;AACJ,CAAC","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"]}
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
var _a;
|
|
26
|
-
exports
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.noReducerInKeyNamesSuggest = exports.noReducerInKeyNames = void 0;
|
|
28
28
|
var path = __importStar(require("path"));
|
|
29
29
|
var rule_creator_1 = require("../../rule-creator");
|
|
@@ -31,7 +31,7 @@ var utils_1 = require("../../utils");
|
|
|
31
31
|
exports.noReducerInKeyNames = 'noReducerInKeyNames';
|
|
32
32
|
exports.noReducerInKeyNamesSuggest = 'noReducerInKeyNamesSuggest';
|
|
33
33
|
var reducerKeyword = 'reducer';
|
|
34
|
-
exports
|
|
34
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
35
35
|
name: path.parse(__filename).name,
|
|
36
36
|
meta: {
|
|
37
37
|
type: 'suggestion',
|
|
@@ -40,13 +40,13 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
40
40
|
docs: {
|
|
41
41
|
description: "Avoid the word \"".concat(reducerKeyword, "\" in the key names."),
|
|
42
42
|
recommended: 'warn',
|
|
43
|
-
suggestion: true
|
|
43
|
+
suggestion: true,
|
|
44
44
|
},
|
|
45
45
|
schema: [],
|
|
46
46
|
messages: (_a = {},
|
|
47
47
|
_a[exports.noReducerInKeyNames] = "Avoid the word \"".concat(reducerKeyword, "\" in the key names to better represent the state."),
|
|
48
48
|
_a[exports.noReducerInKeyNamesSuggest] = "Remove the word \"".concat(reducerKeyword, "\"."),
|
|
49
|
-
_a)
|
|
49
|
+
_a),
|
|
50
50
|
},
|
|
51
51
|
defaultOptions: [],
|
|
52
52
|
create: function (context) {
|
|
@@ -65,12 +65,12 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
65
65
|
return null;
|
|
66
66
|
}
|
|
67
67
|
return fixer.replaceText(node, keyName.replace(new RegExp(reducerKeyword, 'i'), ''));
|
|
68
|
-
}
|
|
68
|
+
},
|
|
69
69
|
},
|
|
70
|
-
]
|
|
70
|
+
],
|
|
71
71
|
});
|
|
72
72
|
},
|
|
73
73
|
_a;
|
|
74
|
-
}
|
|
74
|
+
},
|
|
75
75
|
});
|
|
76
76
|
//# sourceMappingURL=no-reducer-in-key-names.js.map
|
|
@@ -1 +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,
|
|
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,q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,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"]}
|
|
@@ -23,25 +23,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
var _a;
|
|
26
|
-
exports
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
27
|
exports.messageId = void 0;
|
|
28
28
|
var path = __importStar(require("path"));
|
|
29
29
|
var rule_creator_1 = require("../../rule-creator");
|
|
30
30
|
var utils_1 = require("../../utils");
|
|
31
31
|
exports.messageId = 'noStoreSubscription';
|
|
32
|
-
exports
|
|
32
|
+
exports.default = (0, rule_creator_1.createRule)({
|
|
33
33
|
name: path.parse(__filename).name,
|
|
34
34
|
meta: {
|
|
35
35
|
type: 'suggestion',
|
|
36
36
|
ngrxModule: 'store',
|
|
37
37
|
docs: {
|
|
38
38
|
description: 'Using the `async` pipe is preferred over `store` subscription.',
|
|
39
|
-
recommended: 'warn'
|
|
39
|
+
recommended: 'warn',
|
|
40
40
|
},
|
|
41
41
|
schema: [],
|
|
42
42
|
messages: (_a = {},
|
|
43
43
|
_a[exports.messageId] = '`Store` subscription is forbidden. Use the `async` pipe instead.',
|
|
44
|
-
_a)
|
|
44
|
+
_a),
|
|
45
45
|
},
|
|
46
46
|
defaultOptions: [],
|
|
47
47
|
create: function (context) {
|
|
@@ -55,10 +55,10 @@ exports["default"] = (0, rule_creator_1.createRule)({
|
|
|
55
55
|
_a["".concat((0, utils_1.namedCallableExpression)(storeNames), " > MemberExpression > Identifier[name='subscribe']")] = function (node) {
|
|
56
56
|
context.report({
|
|
57
57
|
node: node,
|
|
58
|
-
messageId: exports.messageId
|
|
58
|
+
messageId: exports.messageId,
|
|
59
59
|
});
|
|
60
60
|
},
|
|
61
61
|
_a;
|
|
62
|
-
}
|
|
62
|
+
},
|
|
63
63
|
});
|
|
64
64
|
//# sourceMappingURL=no-store-subscription.js.map
|
|
@@ -1 +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,
|
|
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,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,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"]}
|