@ngrx/eslint-plugin 18.0.0-beta.1 → 18.0.0-rc.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.d.ts +15 -0
- package/package.json +3 -5
- package/schematics/ng-add/index.d.ts +3 -0
- package/schematics/ng-add/index.js +32 -20
- package/schematics/ng-add/index.js.map +1 -1
- package/schematics/ng-add/schema.d.ts +3 -0
- package/schematics/ng-add/schema.js.map +1 -1
- package/schematics/ng-add/schema.json +16 -51
- package/scripts/generate-config.d.ts +1 -0
- package/scripts/generate-config.js +73 -73
- package/scripts/generate-config.js.map +1 -1
- package/scripts/generate-docs.d.ts +1 -0
- package/scripts/generate-docs.js +33 -65
- package/scripts/generate-docs.js.map +1 -1
- package/scripts/generate-overview.d.ts +1 -0
- package/scripts/generate-overview.js +43 -75
- package/scripts/generate-overview.js.map +1 -1
- package/spec/utils/from-fixture.d.ts +8 -0
- package/spec/utils/from-fixture.js +62 -0
- package/spec/utils/from-fixture.js.map +1 -0
- package/spec/utils/index.d.ts +2 -0
- package/spec/utils/index.js +16 -19
- package/spec/utils/index.js.map +1 -1
- package/spec/utils/rule-tester.d.ts +5 -0
- package/spec/utils/rule-tester.js +23 -0
- package/spec/utils/rule-tester.js.map +1 -0
- package/src/configs/all.d.ts +7 -0
- package/src/configs/all.js +56 -32
- package/src/configs/all.js.map +1 -1
- package/src/configs/all.json +42 -0
- package/src/configs/component-store.d.ts +7 -0
- package/src/configs/component-store.js +23 -8
- package/src/configs/component-store.js.map +1 -1
- package/src/configs/component-store.json +9 -0
- package/src/configs/effects.d.ts +7 -0
- package/src/configs/effects.js +32 -11
- package/src/configs/effects.js.map +1 -1
- package/src/configs/effects.json +13 -0
- package/src/configs/operators.d.ts +7 -0
- package/src/configs/operators.js +28 -0
- package/src/configs/operators.js.map +1 -0
- package/src/configs/operators.json +7 -0
- package/src/configs/signals.d.ts +7 -0
- package/src/configs/signals.js +34 -0
- package/src/configs/signals.js.map +1 -0
- package/src/configs/signals.json +8 -0
- package/src/configs/store.d.ts +7 -0
- package/src/configs/store.js +38 -23
- package/src/configs/store.js.map +1 -1
- package/src/configs/store.json +24 -0
- package/src/index.d.ts +141 -0
- package/src/index.js +18 -3
- package/src/index.js.map +1 -1
- package/src/rule-creator.d.ts +24 -0
- package/src/rule-creator.js +12 -58
- package/src/rule-creator.js.map +1 -1
- package/src/rules/component-store/avoid-combining-component-store-selectors.d.ts +3 -0
- package/src/rules/component-store/avoid-combining-component-store-selectors.js +22 -47
- package/src/rules/component-store/avoid-combining-component-store-selectors.js.map +1 -1
- package/src/rules/component-store/avoid-mapping-component-store-selectors.d.ts +3 -0
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js +17 -20
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js.map +1 -1
- package/src/rules/component-store/updater-explicit-return-type.d.ts +3 -0
- package/src/rules/component-store/updater-explicit-return-type.js +17 -20
- package/src/rules/component-store/updater-explicit-return-type.js.map +1 -1
- package/src/rules/effects/avoid-cyclic-effects.d.ts +4 -0
- package/src/rules/effects/avoid-cyclic-effects.js +47 -109
- package/src/rules/effects/avoid-cyclic-effects.js.map +1 -1
- package/src/rules/effects/no-dispatch-in-effects.d.ts +5 -0
- package/src/rules/effects/no-dispatch-in-effects.js +17 -21
- package/src/rules/effects/no-dispatch-in-effects.js.map +1 -1
- package/src/rules/effects/no-effects-in-providers.d.ts +3 -0
- package/src/rules/effects/no-effects-in-providers.js +18 -49
- package/src/rules/effects/no-effects-in-providers.js.map +1 -1
- package/src/rules/effects/no-multiple-actions-in-effects.d.ts +5 -0
- package/src/rules/effects/no-multiple-actions-in-effects.js +31 -24
- package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -1
- package/src/rules/effects/prefer-action-creator-in-of-type.d.ts +3 -0
- package/src/rules/effects/prefer-action-creator-in-of-type.js +10 -13
- package/src/rules/effects/prefer-action-creator-in-of-type.js.map +1 -1
- package/src/rules/effects/prefer-effect-callback-in-block-statement.d.ts +4 -0
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js +24 -43
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -1
- package/src/rules/effects/use-effects-lifecycle-interface.d.ts +3 -0
- package/src/rules/effects/use-effects-lifecycle-interface.js +21 -24
- package/src/rules/effects/use-effects-lifecycle-interface.js.map +1 -1
- package/src/rules/index.d.ts +33 -0
- package/src/rules/index.js +69 -53
- package/src/rules/index.js.map +1 -1
- package/src/rules/operators/prefer-concat-latest-from.d.ts +7 -0
- package/src/rules/operators/prefer-concat-latest-from.js +123 -0
- package/src/rules/operators/prefer-concat-latest-from.js.map +1 -0
- package/src/rules/signals/signal-state-no-arrays-at-root-level.d.ts +3 -0
- package/src/rules/signals/signal-state-no-arrays-at-root-level.js +59 -0
- package/src/rules/signals/signal-state-no-arrays-at-root-level.js.map +1 -0
- package/src/rules/signals/with-state-no-arrays-at-root-level.d.ts +4 -0
- package/src/rules/signals/with-state-no-arrays-at-root-level.js +72 -0
- package/src/rules/signals/with-state-no-arrays-at-root-level.js.map +1 -0
- package/src/rules/store/avoid-combining-selectors.d.ts +3 -0
- package/src/rules/store/avoid-combining-selectors.js +20 -45
- package/src/rules/store/avoid-combining-selectors.js.map +1 -1
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.d.ts +3 -0
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js +20 -47
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -1
- package/src/rules/store/avoid-duplicate-actions-in-reducer.d.ts +5 -0
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js +33 -101
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -1
- package/src/rules/store/avoid-mapping-selectors.d.ts +3 -0
- package/src/rules/store/avoid-mapping-selectors.js +24 -30
- package/src/rules/store/avoid-mapping-selectors.js.map +1 -1
- package/src/rules/store/good-action-hygiene.d.ts +3 -0
- package/src/rules/store/good-action-hygiene.js +14 -34
- package/src/rules/store/good-action-hygiene.js.map +1 -1
- package/src/rules/store/no-multiple-global-stores.d.ts +6 -0
- package/src/rules/store/no-multiple-global-stores.js +34 -96
- package/src/rules/store/no-multiple-global-stores.js.map +1 -1
- package/src/rules/store/no-reducer-in-key-names.d.ts +5 -0
- package/src/rules/store/no-reducer-in-key-names.js +16 -20
- package/src/rules/store/no-reducer-in-key-names.js.map +1 -1
- package/src/rules/store/no-store-subscription.d.ts +3 -0
- package/src/rules/store/no-store-subscription.js +13 -16
- package/src/rules/store/no-store-subscription.js.map +1 -1
- package/src/rules/store/no-typed-global-store.d.ts +5 -0
- package/src/rules/store/no-typed-global-store.js +29 -70
- package/src/rules/store/no-typed-global-store.js.map +1 -1
- package/src/rules/store/on-function-explicit-return-type.d.ts +6 -0
- package/src/rules/store/on-function-explicit-return-type.js +23 -43
- package/src/rules/store/on-function-explicit-return-type.js.map +1 -1
- package/src/rules/store/prefer-action-creator-in-dispatch.d.ts +3 -0
- package/src/rules/store/prefer-action-creator-in-dispatch.js +15 -18
- package/src/rules/store/prefer-action-creator-in-dispatch.js.map +1 -1
- package/src/rules/store/prefer-action-creator.d.ts +3 -0
- package/src/rules/store/prefer-action-creator.js +10 -13
- package/src/rules/store/prefer-action-creator.js.map +1 -1
- package/src/rules/store/prefer-inline-action-props.d.ts +5 -0
- package/src/rules/store/prefer-inline-action-props.js +14 -18
- package/src/rules/store/prefer-inline-action-props.js.map +1 -1
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.d.ts +5 -0
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js +16 -37
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js.map +1 -1
- package/src/rules/store/prefer-selector-in-select.d.ts +3 -0
- package/src/rules/store/prefer-selector-in-select.js +21 -46
- package/src/rules/store/prefer-selector-in-select.js.map +1 -1
- package/src/rules/store/prefix-selectors-with-select.d.ts +5 -0
- package/src/rules/store/prefix-selectors-with-select.js +26 -39
- package/src/rules/store/prefix-selectors-with-select.js.map +1 -1
- package/src/rules/store/select-style.d.ts +11 -0
- package/src/rules/store/select-style.js +53 -108
- package/src/rules/store/select-style.js.map +1 -1
- package/src/rules/store/use-consistent-global-store-name.d.ts +6 -0
- package/src/rules/store/use-consistent-global-store-name.js +24 -80
- package/src/rules/store/use-consistent-global-store-name.js.map +1 -1
- package/src/utils/helper-functions/docs.d.ts +1 -0
- package/src/utils/helper-functions/docs.js +1 -3
- package/src/utils/helper-functions/docs.js.map +1 -1
- package/src/utils/helper-functions/folder.d.ts +5 -0
- package/src/utils/helper-functions/folder.js +16 -88
- package/src/utils/helper-functions/folder.js.map +1 -1
- package/src/utils/helper-functions/guards.d.ts +97 -0
- package/src/utils/helper-functions/guards.js +27 -31
- package/src/utils/helper-functions/guards.js.map +1 -1
- package/src/utils/helper-functions/index.d.ts +6 -0
- package/src/utils/helper-functions/ngrx-modules.d.ts +8 -0
- package/src/utils/helper-functions/ngrx-modules.js +7 -6
- package/src/utils/helper-functions/ngrx-modules.js.map +1 -1
- package/src/utils/helper-functions/rules.d.ts +3 -0
- package/src/utils/helper-functions/rules.js +47 -0
- package/src/utils/helper-functions/rules.js.map +1 -0
- package/src/utils/helper-functions/utils.d.ts +48 -0
- package/src/utils/helper-functions/utils.js +68 -143
- package/src/utils/helper-functions/utils.js.map +1 -1
- package/src/utils/helper-functions/versions.d.ts +1 -0
- package/src/utils/helper-functions/versions.js +9 -10
- package/src/utils/helper-functions/versions.js.map +1 -1
- package/src/utils/index.d.ts +2 -0
- package/src/utils/selectors/index.d.ts +29 -0
- package/src/utils/selectors/index.js +30 -44
- package/src/utils/selectors/index.js.map +1 -1
- package/v9/index.d.ts +29 -0
- package/v9/index.js +38 -0
- package/v9/index.js.map +1 -0
- package/src/configs/all-requiring-type-checking.js +0 -46
- package/src/configs/all-requiring-type-checking.js.map +0 -1
- package/src/configs/component-store-strict.js +0 -15
- package/src/configs/component-store-strict.js.map +0 -1
- package/src/configs/effects-requiring-type-checking.js +0 -25
- package/src/configs/effects-requiring-type-checking.js.map +0 -1
- package/src/configs/effects-strict-requiring-type-checking.js +0 -25
- package/src/configs/effects-strict-requiring-type-checking.js.map +0 -1
- package/src/configs/effects-strict.js +0 -18
- package/src/configs/effects-strict.js.map +0 -1
- package/src/configs/index.js +0 -33
- package/src/configs/index.js.map +0 -1
- package/src/configs/recommended-requiring-type-checking.js +0 -46
- package/src/configs/recommended-requiring-type-checking.js.map +0 -1
- package/src/configs/recommended.js +0 -39
- package/src/configs/recommended.js.map +0 -1
- package/src/configs/store-strict.js +0 -30
- package/src/configs/store-strict.js.map +0 -1
- package/src/configs/strict-requiring-type-checking.js +0 -46
- package/src/configs/strict-requiring-type-checking.js.map +0 -1
- package/src/configs/strict.js +0 -39
- package/src/configs/strict.js.map +0 -1
- package/src/rules/effects/prefer-concat-latest-from.js +0 -153
- package/src/rules/effects/prefer-concat-latest-from.js.map +0 -1
|
@@ -22,28 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
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
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
26
|
exports.messageId = void 0;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
47
30
|
exports.messageId = 'goodActionHygiene';
|
|
48
31
|
exports.default = (0, rule_creator_1.createRule)({
|
|
49
32
|
name: path.parse(__filename).name,
|
|
@@ -52,33 +35,30 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
52
35
|
ngrxModule: 'store',
|
|
53
36
|
docs: {
|
|
54
37
|
description: 'Ensures the use of good action hygiene.',
|
|
55
|
-
recommended: 'warn',
|
|
56
38
|
},
|
|
57
39
|
schema: [],
|
|
58
|
-
messages:
|
|
59
|
-
|
|
60
|
-
|
|
40
|
+
messages: {
|
|
41
|
+
[exports.messageId]: 'Action type `{{ actionType }}` does not follow the good action hygiene practice, use "[Source] {{ actionType }}" to define action types.',
|
|
42
|
+
},
|
|
61
43
|
},
|
|
62
44
|
defaultOptions: [],
|
|
63
|
-
create:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var _b = __read(_a.arguments, 1), node = _b[0];
|
|
69
|
-
var actionType = node.value;
|
|
45
|
+
create: (context) => {
|
|
46
|
+
const sourceEventPattern = /[[].*[\]]\s.*/;
|
|
47
|
+
return {
|
|
48
|
+
[utils_1.actionCreatorWithLiteral]({ arguments: [node], }) {
|
|
49
|
+
const { value: actionType } = node;
|
|
70
50
|
if (sourceEventPattern.test(actionType)) {
|
|
71
51
|
return;
|
|
72
52
|
}
|
|
73
53
|
context.report({
|
|
74
|
-
node
|
|
54
|
+
node,
|
|
75
55
|
messageId: exports.messageId,
|
|
76
56
|
data: {
|
|
77
|
-
actionType
|
|
57
|
+
actionType,
|
|
78
58
|
},
|
|
79
59
|
});
|
|
80
60
|
},
|
|
81
|
-
|
|
61
|
+
};
|
|
82
62
|
},
|
|
83
63
|
});
|
|
84
64
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"good-action-hygiene.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/good-action-hygiene.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAuD;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;SACvD;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,0IAA0I;SAC7I;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,kBAAkB,GAAG,eAAe,CAAC;QAE3C,OAAO;YACL,CAAC,gCAAwB,CAAC,CAAC,EACzB,SAAS,EAAE,CAAC,IAAI,CAAC,GAGlB;gBACC,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;gBAEnC,IAAI,kBAAkB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;oBACxC,OAAO;gBACT,CAAC;gBAED,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAT,iBAAS;oBACT,IAAI,EAAE;wBACJ,UAAU;qBACX;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { 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 },\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,6 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
export declare const noMultipleGlobalStores = "noMultipleGlobalStores";
|
|
3
|
+
export declare const noMultipleGlobalStoresSuggest = "noMultipleGlobalStoresSuggest";
|
|
4
|
+
type MessageIds = typeof noMultipleGlobalStores | typeof noMultipleGlobalStoresSuggest;
|
|
5
|
+
declare const _default: TSESLint.RuleModule<MessageIds, readonly [], TSESLint.RuleListener>;
|
|
6
|
+
export default _default;
|
|
@@ -22,48 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
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
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
26
|
exports.noMultipleGlobalStoresSuggest = exports.noMultipleGlobalStores = void 0;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
67
30
|
exports.noMultipleGlobalStores = 'noMultipleGlobalStores';
|
|
68
31
|
exports.noMultipleGlobalStoresSuggest = 'noMultipleGlobalStoresSuggest';
|
|
69
32
|
exports.default = (0, rule_creator_1.createRule)({
|
|
@@ -74,62 +37,36 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
74
37
|
ngrxModule: 'store',
|
|
75
38
|
docs: {
|
|
76
39
|
description: 'There should only be one global store injected.',
|
|
77
|
-
recommended: 'warn',
|
|
78
|
-
suggestion: true,
|
|
79
40
|
},
|
|
80
41
|
schema: [],
|
|
81
|
-
messages:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
42
|
+
messages: {
|
|
43
|
+
[exports.noMultipleGlobalStores]: 'Global store should be injected only once.',
|
|
44
|
+
[exports.noMultipleGlobalStoresSuggest]: 'Remove this reference.',
|
|
45
|
+
},
|
|
85
46
|
},
|
|
86
47
|
defaultOptions: [],
|
|
87
|
-
create:
|
|
48
|
+
create: (context) => {
|
|
88
49
|
return {
|
|
89
|
-
Program
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
}
|
|
50
|
+
Program() {
|
|
51
|
+
const { identifiers = [], sourceCode } = (0, utils_1.getNgRxStores)(context);
|
|
52
|
+
const flattenedIdentifiers = groupBy(identifiers).values();
|
|
53
|
+
for (const identifiers of flattenedIdentifiers) {
|
|
54
|
+
if (identifiers.length <= 1) {
|
|
55
|
+
continue;
|
|
125
56
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
57
|
+
for (const node of identifiers) {
|
|
58
|
+
const nodeToReport = getNodeToReport(node);
|
|
59
|
+
context.report({
|
|
60
|
+
node: nodeToReport,
|
|
61
|
+
messageId: exports.noMultipleGlobalStores,
|
|
62
|
+
suggest: [
|
|
63
|
+
{
|
|
64
|
+
messageId: exports.noMultipleGlobalStoresSuggest,
|
|
65
|
+
fix: (fixer) => getFixes(sourceCode, fixer, nodeToReport),
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
});
|
|
131
69
|
}
|
|
132
|
-
finally { if (e_1) throw e_1.error; }
|
|
133
70
|
}
|
|
134
71
|
},
|
|
135
72
|
};
|
|
@@ -139,19 +76,20 @@ function getNodeToReport(node) {
|
|
|
139
76
|
return node.parent && (0, utils_1.isTSParameterProperty)(node.parent) ? node.parent : node;
|
|
140
77
|
}
|
|
141
78
|
function getFixes(sourceCode, fixer, node) {
|
|
142
|
-
|
|
143
|
-
|
|
79
|
+
const { parent } = node;
|
|
80
|
+
const nodeToRemove = parent && (0, utils_1.isTSParameterProperty)(parent) ? parent : node;
|
|
144
81
|
return (0, utils_1.getNodeToCommaRemoveFix)(sourceCode, fixer, nodeToRemove);
|
|
145
82
|
}
|
|
146
83
|
function groupBy(identifiers) {
|
|
147
|
-
return identifiers.reduce(
|
|
148
|
-
|
|
84
|
+
return identifiers.reduce((accumulator, identifier) => {
|
|
85
|
+
const parent = (0, utils_1.isTSParameterProperty)(identifier.parent)
|
|
149
86
|
? identifier.parent.parent
|
|
150
87
|
: identifier.parent;
|
|
151
|
-
|
|
152
|
-
return accumulator.set(parent,
|
|
88
|
+
const collectedIdentifiers = accumulator.get(parent);
|
|
89
|
+
return accumulator.set(parent, [
|
|
90
|
+
...(collectedIdentifiers ?? []),
|
|
153
91
|
identifier,
|
|
154
|
-
]
|
|
92
|
+
]);
|
|
155
93
|
}, new Map());
|
|
156
94
|
}
|
|
157
95
|
//# sourceMappingURL=no-multiple-global-stores.js.map
|
|
@@ -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":"
|
|
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/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 },\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,5 @@
|
|
|
1
|
+
export declare const noReducerInKeyNames = "noReducerInKeyNames";
|
|
2
|
+
export declare const noReducerInKeyNamesSuggest = "noReducerInKeyNamesSuggest";
|
|
3
|
+
type MessageIds = typeof noReducerInKeyNames | typeof noReducerInKeyNamesSuggest;
|
|
4
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
|
+
export default _default;
|
|
@@ -22,15 +22,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var _a;
|
|
26
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
26
|
exports.noReducerInKeyNamesSuggest = exports.noReducerInKeyNames = void 0;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
31
30
|
exports.noReducerInKeyNames = 'noReducerInKeyNames';
|
|
32
31
|
exports.noReducerInKeyNamesSuggest = 'noReducerInKeyNamesSuggest';
|
|
33
|
-
|
|
32
|
+
const reducerKeyword = 'reducer';
|
|
34
33
|
exports.default = (0, rule_creator_1.createRule)({
|
|
35
34
|
name: path.parse(__filename).name,
|
|
36
35
|
meta: {
|
|
@@ -38,29 +37,26 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
38
37
|
hasSuggestions: true,
|
|
39
38
|
ngrxModule: 'store',
|
|
40
39
|
docs: {
|
|
41
|
-
description:
|
|
42
|
-
recommended: 'warn',
|
|
43
|
-
suggestion: true,
|
|
40
|
+
description: `Avoid the word "${reducerKeyword}" in the key names.`,
|
|
44
41
|
},
|
|
45
42
|
schema: [],
|
|
46
|
-
messages:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
messages: {
|
|
44
|
+
[exports.noReducerInKeyNames]: `Avoid the word "${reducerKeyword}" in the key names to better represent the state.`,
|
|
45
|
+
[exports.noReducerInKeyNamesSuggest]: `Remove the word "${reducerKeyword}".`,
|
|
46
|
+
},
|
|
50
47
|
},
|
|
51
48
|
defaultOptions: [],
|
|
52
|
-
create:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
_a[":matches(".concat(utils_1.storeActionReducerMap, ", ").concat(utils_1.actionReducerMap, ") > ").concat((0, utils_1.metadataProperty)(/reducer/i), " > .key")] = function (node) {
|
|
49
|
+
create: (context) => {
|
|
50
|
+
return {
|
|
51
|
+
[`:matches(${utils_1.storeActionReducerMap}, ${utils_1.actionReducerMap}) > ${(0, utils_1.metadataProperty)(/reducer/i)} > .key`](node) {
|
|
56
52
|
context.report({
|
|
57
|
-
node
|
|
53
|
+
node,
|
|
58
54
|
messageId: exports.noReducerInKeyNames,
|
|
59
55
|
suggest: [
|
|
60
56
|
{
|
|
61
57
|
messageId: exports.noReducerInKeyNamesSuggest,
|
|
62
|
-
fix:
|
|
63
|
-
|
|
58
|
+
fix: (fixer) => {
|
|
59
|
+
const keyName = (0, utils_1.getRawText)(node);
|
|
64
60
|
if (!keyName) {
|
|
65
61
|
return null;
|
|
66
62
|
}
|
|
@@ -70,7 +66,7 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
70
66
|
],
|
|
71
67
|
});
|
|
72
68
|
},
|
|
73
|
-
|
|
69
|
+
};
|
|
74
70
|
},
|
|
75
71
|
});
|
|
76
72
|
//# 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":"
|
|
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,2CAA6B;AAC7B,qDAAgD;AAChD,uCAKqB;AAER,QAAA,mBAAmB,GAAG,qBAAqB,CAAC;AAC5C,QAAA,0BAA0B,GAAG,4BAA4B,CAAC;AAOvE,MAAM,cAAc,GAAG,SAAS,CAAC;AAEjC,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,mBAAmB,cAAc,qBAAqB;SACpE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,2BAAmB,CAAC,EAAE,mBAAmB,cAAc,mDAAmD;YAC3G,CAAC,kCAA0B,CAAC,EAAE,oBAAoB,cAAc,IAAI;SACrE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,OAAO;YACL,CAAC,YAAY,6BAAqB,KAAK,wBAAgB,OAAO,IAAA,wBAAgB,EAC5E,UAAU,CACX,SAAS,CAAC,CAAC,IAA8B;gBACxC,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAE,2BAAmB;oBAC9B,OAAO,EAAE;wBACP;4BACE,SAAS,EAAE,kCAA0B;4BACrC,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE;gCACb,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAC;gCAEjC,IAAI,CAAC,OAAO,EAAE,CAAC;oCACb,OAAO,IAAI,CAAC;gCACd,CAAC;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;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n 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 },\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"]}
|
|
@@ -22,12 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var _a;
|
|
26
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
26
|
exports.messageId = void 0;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
31
30
|
exports.messageId = 'noStoreSubscription';
|
|
32
31
|
exports.default = (0, rule_creator_1.createRule)({
|
|
33
32
|
name: path.parse(__filename).name,
|
|
@@ -36,29 +35,27 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
36
35
|
ngrxModule: 'store',
|
|
37
36
|
docs: {
|
|
38
37
|
description: 'Using the `async` pipe is preferred over `store` subscription.',
|
|
39
|
-
recommended: 'warn',
|
|
40
38
|
},
|
|
41
39
|
schema: [],
|
|
42
|
-
messages:
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
messages: {
|
|
41
|
+
[exports.messageId]: '`Store` subscription is forbidden. Use the `async` pipe instead.',
|
|
42
|
+
},
|
|
45
43
|
},
|
|
46
44
|
defaultOptions: [],
|
|
47
|
-
create:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
var storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
45
|
+
create: (context) => {
|
|
46
|
+
const { identifiers = [] } = (0, utils_1.getNgRxStores)(context);
|
|
47
|
+
const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
51
48
|
if (!storeNames) {
|
|
52
49
|
return {};
|
|
53
50
|
}
|
|
54
|
-
return
|
|
55
|
-
|
|
51
|
+
return {
|
|
52
|
+
[`${(0, utils_1.namedCallableExpression)(storeNames)} > MemberExpression > Identifier[name='subscribe']`](node) {
|
|
56
53
|
context.report({
|
|
57
|
-
node
|
|
54
|
+
node,
|
|
58
55
|
messageId: exports.messageId,
|
|
59
56
|
});
|
|
60
57
|
},
|
|
61
|
-
|
|
58
|
+
};
|
|
62
59
|
},
|
|
63
60
|
});
|
|
64
61
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"no-store-subscription.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/no-store-subscription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAgF;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;SACnE;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,kEAAkE;SACrE;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;QACpD,MAAM,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,CAAC;YAChB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO;YACL,CAAC,GAAG,IAAA,+BAAuB,EACzB,UAAU,CACX,oDAAoD,CAAC,CACpD,IAAyB;gBAEzB,OAAO,CAAC,MAAM,CAAC;oBACb,IAAI;oBACJ,SAAS,EAAT,iBAAS;iBACV,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { 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 },\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,5 @@
|
|
|
1
|
+
export declare const noTypedStore = "noTypedStore";
|
|
2
|
+
export declare const noTypedStoreSuggest = "noTypedStoreSuggest";
|
|
3
|
+
type MessageIds = typeof noTypedStore | typeof noTypedStoreSuggest;
|
|
4
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, readonly [], import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
|
+
export default _default;
|
|
@@ -22,39 +22,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
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 _a;
|
|
53
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
26
|
exports.noTypedStoreSuggest = exports.noTypedStore = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
58
30
|
exports.noTypedStore = 'noTypedStore';
|
|
59
31
|
exports.noTypedStoreSuggest = 'noTypedStoreSuggest';
|
|
60
32
|
exports.default = (0, rule_creator_1.createRule)({
|
|
@@ -65,62 +37,49 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
65
37
|
ngrxModule: 'store',
|
|
66
38
|
docs: {
|
|
67
39
|
description: 'The global store should not be typed.',
|
|
68
|
-
recommended: 'warn',
|
|
69
|
-
suggestion: true,
|
|
70
40
|
},
|
|
71
41
|
schema: [],
|
|
72
|
-
messages:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
42
|
+
messages: {
|
|
43
|
+
[exports.noTypedStore]: '`Store` should not be typed, use `Store` (without generic) instead.',
|
|
44
|
+
[exports.noTypedStoreSuggest]: 'Remove generic from `Store`.',
|
|
45
|
+
},
|
|
76
46
|
},
|
|
77
47
|
defaultOptions: [],
|
|
78
|
-
create:
|
|
48
|
+
create: (context) => {
|
|
79
49
|
return {
|
|
80
|
-
Program
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
var _c = __read(parent_1.value.arguments, 1), storeArgument = _c[0];
|
|
94
|
-
if ((0, utils_1.isTSInstantiationExpression)(storeArgument)) {
|
|
95
|
-
report(storeArgument.typeParameters);
|
|
96
|
-
}
|
|
50
|
+
Program() {
|
|
51
|
+
const { identifiers = [] } = (0, utils_1.getNgRxStores)(context);
|
|
52
|
+
for (const identifier of identifiers) {
|
|
53
|
+
// using inject()
|
|
54
|
+
if (!identifier.typeAnnotation) {
|
|
55
|
+
const { parent } = identifier;
|
|
56
|
+
if ((0, utils_1.isPropertyDefinition)(parent) &&
|
|
57
|
+
parent.value &&
|
|
58
|
+
(0, utils_1.isCallExpression)(parent.value) &&
|
|
59
|
+
parent.value.arguments.length) {
|
|
60
|
+
const [storeArgument] = parent.value.arguments;
|
|
61
|
+
if ((0, utils_1.isTSInstantiationExpression)(storeArgument)) {
|
|
62
|
+
report(storeArgument.typeArguments);
|
|
97
63
|
}
|
|
98
|
-
continue;
|
|
99
64
|
}
|
|
100
|
-
|
|
101
|
-
!identifier.typeAnnotation.typeAnnotation.typeParameters) {
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
report(identifier.typeAnnotation.typeAnnotation.typeParameters);
|
|
65
|
+
continue;
|
|
105
66
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
if (identifiers_1_1 && !identifiers_1_1.done && (_a = identifiers_1.return)) _a.call(identifiers_1);
|
|
67
|
+
if (!(0, utils_1.isTSTypeReference)(identifier.typeAnnotation.typeAnnotation) ||
|
|
68
|
+
!identifier.typeAnnotation.typeAnnotation.typeArguments) {
|
|
69
|
+
continue;
|
|
111
70
|
}
|
|
112
|
-
|
|
71
|
+
report(identifier.typeAnnotation.typeAnnotation.typeArguments);
|
|
113
72
|
}
|
|
114
73
|
},
|
|
115
74
|
};
|
|
116
|
-
function report(
|
|
75
|
+
function report(typeArguments) {
|
|
117
76
|
context.report({
|
|
118
|
-
node:
|
|
77
|
+
node: typeArguments,
|
|
119
78
|
messageId: exports.noTypedStore,
|
|
120
79
|
suggest: [
|
|
121
80
|
{
|
|
122
81
|
messageId: exports.noTypedStoreSuggest,
|
|
123
|
-
fix:
|
|
82
|
+
fix: (fixer) => fixer.remove(typeArguments),
|
|
124
83
|
},
|
|
125
84
|
],
|
|
126
85
|
});
|