@ngrx/eslint-plugin 18.0.0-beta.1 → 18.0.0-rc.1
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 +4 -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 +18 -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 +13 -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 +153 -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 +35 -0
- package/src/rules/index.js +74 -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 +10 -11
- 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
package/src/rule-creator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rule-creator.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/src/rule-creator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rule-creator.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/src/rule-creator.ts"],"names":[],"mappings":";;;AACA,oDAAuD;AAEvD,mCAA2E;AAwB3E,SAAgB,UAAU,CAIxB,MAQE;IAEF,MAAM,eAAe,GAAG;QACtB,GAAG,MAAM;QACT,MAAM,EAAE,CACN,OAA8D,EAC9D,kBAAsC,EACtC,EAAE;YACF,MAAM,EACJ,IAAI,EAAE,EAAE,UAAU,EAAE,OAAO,EAAE,GAC9B,GAAG,MAAM,CAAC;YACX,IACE,OAAO,KAAK,SAAS;gBACrB,CAAC,IAAA,4BAAoB,EAAC,yBAAiB,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC,EAC7D,CAAC;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC;YAED,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;IAEF,KAAK,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1E,eAAe,CAAC,IAAI,CAAC,QAAgB,CAAC,GAAG,CAAC,GAAG,GAAG,OAAO,KAAK,IAAA,eAAO,EAClE,MAAM,CAAC,IAAI,CACZ,GAAG,CAAC;IACP,CAAC;IAED,OAAO,mBAAW,CAAC,WAAW,CAAC,eAAO,CAAC,CAAC,eAAe,CAAC,CAAC;AAC3D,CAAC;AAzCD,gCAyCC","sourcesContent":["import type { TSESLint } from '@typescript-eslint/utils';\nimport { ESLintUtils } from '@typescript-eslint/utils';\nimport type { NGRX_MODULE } from './utils';\nimport { docsUrl, ngrxVersionSatisfies, NGRX_MODULE_PATHS } from './utils';\n\ntype Meta<TMessageIds extends string, TOptions extends readonly unknown[]> =\n | TSESLint.RuleMetaData<TMessageIds, TOptions> & {\n ngrxModule: NGRX_MODULE;\n version?: string;\n docs: { requiresTypeChecking?: boolean };\n };\n\ntype CreateRuleMeta<\n TMessageIds extends string,\n TOptions extends readonly unknown[]\n> = {\n docs: Omit<TSESLint.RuleMetaDataDocs, 'url'> & {\n requiresTypeChecking?: boolean;\n };\n} & Omit<Meta<TMessageIds, TOptions>, 'docs'>;\nexport type NgRxRuleModule<\n TOptions extends readonly unknown[],\n TMessageIds extends string\n> = Omit<TSESLint.RuleModule<TMessageIds, TOptions>, 'meta'> & {\n meta: Meta<TMessageIds, TOptions>;\n};\n\nexport function createRule<\n TOptions extends readonly unknown[],\n TMessageIds extends string\n>(\n config: Readonly<{\n name: string;\n meta: CreateRuleMeta<TMessageIds, TOptions>;\n defaultOptions: Readonly<TOptions>;\n create: (\n context: Readonly<TSESLint.RuleContext<TMessageIds, TOptions>>,\n optionsWithDefault: Readonly<TOptions>\n ) => TSESLint.RuleListener;\n }>\n): TSESLint.RuleModule<TMessageIds, TOptions> {\n const configOverwrite = {\n ...config,\n create: (\n context: Readonly<TSESLint.RuleContext<TMessageIds, TOptions>>,\n optionsWithDefault: Readonly<TOptions>\n ) => {\n const {\n meta: { ngrxModule, version },\n } = config;\n if (\n version !== undefined &&\n !ngrxVersionSatisfies(NGRX_MODULE_PATHS[ngrxModule], version)\n ) {\n return {};\n }\n\n return config.create(context, optionsWithDefault);\n },\n };\n\n for (const [key, message] of Object.entries(configOverwrite.meta.messages)) {\n (configOverwrite.meta.messages as any)[key] = `${message} (${docsUrl(\n config.name\n )})`;\n }\n\n return ESLintUtils.RuleCreator(docsUrl)(configOverwrite);\n}\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const messageId = "avoidCombiningComponentStoreSelectors";
|
|
2
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidCombiningComponentStoreSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
3
|
+
export default _default;
|
|
@@ -22,23 +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 _a;
|
|
37
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
26
|
exports.messageId = void 0;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
const path = __importStar(require("path"));
|
|
28
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
29
|
+
const utils_1 = require("../../utils");
|
|
42
30
|
exports.messageId = 'avoidCombiningComponentStoreSelectors';
|
|
43
31
|
exports.default = (0, rule_creator_1.createRule)({
|
|
44
32
|
name: path.parse(__filename).name,
|
|
@@ -47,49 +35,36 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
47
35
|
ngrxModule: 'component-store',
|
|
48
36
|
docs: {
|
|
49
37
|
description: 'Prefer combining selectors at the selector level.',
|
|
50
|
-
recommended: 'warn',
|
|
51
38
|
},
|
|
52
39
|
schema: [],
|
|
53
|
-
messages:
|
|
54
|
-
|
|
55
|
-
|
|
40
|
+
messages: {
|
|
41
|
+
[exports.messageId]: 'Combine selectors at the selector level.',
|
|
42
|
+
},
|
|
56
43
|
},
|
|
57
44
|
defaultOptions: [],
|
|
58
|
-
create:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
_a["ClassDeclaration[superClass.name=/Store/] CallExpression[callee.name='combineLatest'] ".concat(thisSelects, " ~ ").concat(thisSelects)] = function (node) {
|
|
45
|
+
create: (context) => {
|
|
46
|
+
const { identifiers = [] } = (0, utils_1.getNgRxComponentStores)(context);
|
|
47
|
+
const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
48
|
+
const thisSelects = `CallExpression[callee.object.type='ThisExpression'][callee.property.name='select']`;
|
|
49
|
+
const storeSelects = storeNames ? (0, utils_1.namedExpression)(storeNames) : null;
|
|
50
|
+
const selectsInArray = [];
|
|
51
|
+
return {
|
|
52
|
+
[`ClassDeclaration[superClass.name=/Store/] CallExpression[callee.name='combineLatest'] ${thisSelects} ~ ${thisSelects}`](node) {
|
|
67
53
|
selectsInArray.push(node);
|
|
68
54
|
},
|
|
69
|
-
|
|
55
|
+
[`CallExpression[callee.name='combineLatest'] ${storeSelects} ~ ${storeSelects}`](node) {
|
|
70
56
|
selectsInArray.push(node);
|
|
71
57
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
node: node,
|
|
79
|
-
messageId: exports.messageId,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
84
|
-
finally {
|
|
85
|
-
try {
|
|
86
|
-
if (selectsInArray_1_1 && !selectsInArray_1_1.done && (_a = selectsInArray_1.return)) _a.call(selectsInArray_1);
|
|
87
|
-
}
|
|
88
|
-
finally { if (e_1) throw e_1.error; }
|
|
58
|
+
[`CallExpression[callee.name='combineLatest']:exit`]() {
|
|
59
|
+
for (const node of selectsInArray) {
|
|
60
|
+
context.report({
|
|
61
|
+
node,
|
|
62
|
+
messageId: exports.messageId,
|
|
63
|
+
});
|
|
89
64
|
}
|
|
90
65
|
selectsInArray.length = 0;
|
|
91
66
|
},
|
|
92
|
-
|
|
67
|
+
};
|
|
93
68
|
},
|
|
94
69
|
});
|
|
95
70
|
//# sourceMappingURL=avoid-combining-component-store-selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-combining-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-combining-component-store-selectors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"avoid-combining-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-combining-component-store-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAIqB;AACR,QAAA,SAAS,GAAG,uCAAuC,CAAC;AAIjE,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;I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SESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n getNgRxComponentStores,\n namedExpression,\n} from '../../utils';\nexport const messageId = 'avoidCombiningComponentStoreSelectors';\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: 'component-store',\n docs: {\n description: 'Prefer combining selectors at the selector level.',\n },\n schema: [],\n messages: {\n [messageId]: 'Combine selectors at the selector level.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxComponentStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n const thisSelects = `CallExpression[callee.object.type='ThisExpression'][callee.property.name='select']`;\n const storeSelects = storeNames ? namedExpression(storeNames) : null;\n\n const selectsInArray: TSESTree.CallExpression[] = [];\n return {\n [`ClassDeclaration[superClass.name=/Store/] CallExpression[callee.name='combineLatest'] ${thisSelects} ~ ${thisSelects}`](\n node: TSESTree.CallExpression\n ) {\n selectsInArray.push(node);\n },\n [`CallExpression[callee.name='combineLatest'] ${storeSelects} ~ ${storeSelects}`](\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"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const messageId = "avoidMappingComponentStoreSelectors";
|
|
2
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"avoidMappingComponentStoreSelectors", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
3
|
+
export default _default;
|
|
@@ -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 = 'avoidMappingComponentStoreSelectors';
|
|
32
31
|
exports.default = (0, rule_creator_1.createRule)({
|
|
33
32
|
name: path.parse(__filename).name,
|
|
@@ -36,34 +35,32 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
36
35
|
ngrxModule: 'component-store',
|
|
37
36
|
docs: {
|
|
38
37
|
description: 'Avoid mapping logic outside the selector level.',
|
|
39
|
-
recommended: 'warn',
|
|
40
38
|
},
|
|
41
39
|
schema: [],
|
|
42
|
-
messages:
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
messages: {
|
|
41
|
+
[exports.messageId]: 'Map logic at the selector level instead.',
|
|
42
|
+
},
|
|
45
43
|
},
|
|
46
44
|
defaultOptions: [],
|
|
47
|
-
create:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"ClassDeclaration[superClass.name=/Store/] CallExpression:has(CallExpression[callee.object.type='ThisExpression'][callee.property.name='select'])".concat(mapOperatorSelector),
|
|
45
|
+
create: (context) => {
|
|
46
|
+
const { identifiers = [] } = (0, utils_1.getNgRxComponentStores)(context);
|
|
47
|
+
const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
48
|
+
const mapOperatorSelector = `[callee.property.name=pipe] > CallExpression[callee.name=map]`;
|
|
49
|
+
const selectors = [
|
|
50
|
+
`ClassDeclaration[superClass.name=/Store/] CallExpression:has(CallExpression[callee.object.type='ThisExpression'][callee.property.name='select'])${mapOperatorSelector}`,
|
|
54
51
|
storeNames &&
|
|
55
|
-
|
|
52
|
+
`${(0, utils_1.namedCallableExpression)(storeNames)}${mapOperatorSelector}`,
|
|
56
53
|
]
|
|
57
54
|
.filter(Boolean)
|
|
58
55
|
.join(',');
|
|
59
|
-
return
|
|
60
|
-
|
|
56
|
+
return {
|
|
57
|
+
[selectors](node) {
|
|
61
58
|
context.report({
|
|
62
|
-
node
|
|
59
|
+
node,
|
|
63
60
|
messageId: exports.messageId,
|
|
64
61
|
});
|
|
65
62
|
},
|
|
66
|
-
|
|
63
|
+
};
|
|
67
64
|
},
|
|
68
65
|
});
|
|
69
66
|
//# sourceMappingURL=avoid-mapping-component-store-selectors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-mapping-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-mapping-component-store-selectors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"avoid-mapping-component-store-selectors.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/avoid-mapping-component-store-selectors.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAIqB;AAER,QAAA,SAAS,GAAG,qCAAqC,CAAC;AAK/D,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,iBAAiB;QAC7B,IAAI,EAAE;YACJ,WAAW,EAAE,iDAAiD;SAC/D;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EAAE,0CAA0C;SACxD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAE1E,MAAM,mBAAmB,GAAG,+DAA+D,CAAC;QAC5F,MAAM,SAAS,GAAG;YAChB,mJAAmJ,mBAAmB,EAAE;YACxK,UAAU;gBACR,GAAG,IAAA,+BAAuB,EAAC,UAAU,CAAC,GAAG,mBAAmB,EAAE;SACjE;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;QAEb,OAAO;YACL,CAAC,SAAS,CAAC,CAAC,IAAsC;gBAChD,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 {\n asPattern,\n getNgRxComponentStores,\n namedCallableExpression,\n} from '../../utils';\n\nexport const messageId = 'avoidMappingComponentStoreSelectors';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'component-store',\n docs: {\n description: 'Avoid mapping logic outside the selector level.',\n },\n schema: [],\n messages: {\n [messageId]: 'Map logic at the selector level instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxComponentStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n const mapOperatorSelector = `[callee.property.name=pipe] > CallExpression[callee.name=map]`;\n const selectors = [\n `ClassDeclaration[superClass.name=/Store/] CallExpression:has(CallExpression[callee.object.type='ThisExpression'][callee.property.name='select'])${mapOperatorSelector}`,\n storeNames &&\n `${namedCallableExpression(storeNames)}${mapOperatorSelector}`,\n ]\n .filter(Boolean)\n .join(',');\n\n return {\n [selectors](node: TSESTree.ArrowFunctionExpression) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const messageId = "updaterExplicitReturnType";
|
|
2
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"updaterExplicitReturnType", readonly [], unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
3
|
+
export default _default;
|
|
@@ -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 = 'updaterExplicitReturnType';
|
|
32
31
|
exports.default = (0, rule_creator_1.createRule)({
|
|
33
32
|
name: path.parse(__filename).name,
|
|
@@ -36,34 +35,32 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
36
35
|
ngrxModule: 'component-store',
|
|
37
36
|
docs: {
|
|
38
37
|
description: '`Updater` should have an explicit return type.',
|
|
39
|
-
recommended: 'warn',
|
|
40
38
|
},
|
|
41
39
|
schema: [],
|
|
42
|
-
messages:
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
messages: {
|
|
41
|
+
[exports.messageId]: '`Updater` should have an explicit return type when using arrow functions: `this.store.updater((state, value): State => {}`.',
|
|
42
|
+
},
|
|
45
43
|
},
|
|
46
44
|
defaultOptions: [],
|
|
47
|
-
create:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"ClassDeclaration[superClass.name=/Store/] CallExpression[callee.object.type='ThisExpression'][callee.property.name='updater'] > ".concat(withoutTypeAnnotation),
|
|
45
|
+
create: (context) => {
|
|
46
|
+
const { identifiers = [] } = (0, utils_1.getNgRxComponentStores)(context);
|
|
47
|
+
const storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
48
|
+
const withoutTypeAnnotation = `ArrowFunctionExpression:not([returnType.typeAnnotation])`;
|
|
49
|
+
const selectors = [
|
|
50
|
+
`ClassDeclaration[superClass.name=/Store/] CallExpression[callee.object.type='ThisExpression'][callee.property.name='updater'] > ${withoutTypeAnnotation}`,
|
|
54
51
|
storeNames &&
|
|
55
|
-
|
|
52
|
+
`${(0, utils_1.namedExpression)(storeNames)}[callee.property.name='updater'] > ${withoutTypeAnnotation}`,
|
|
56
53
|
]
|
|
57
54
|
.filter(Boolean)
|
|
58
55
|
.join(',');
|
|
59
|
-
return
|
|
60
|
-
|
|
56
|
+
return {
|
|
57
|
+
[selectors](node) {
|
|
61
58
|
context.report({
|
|
62
|
-
node
|
|
59
|
+
node,
|
|
63
60
|
messageId: exports.messageId,
|
|
64
61
|
});
|
|
65
62
|
},
|
|
66
|
-
|
|
63
|
+
};
|
|
67
64
|
},
|
|
68
65
|
});
|
|
69
66
|
//# sourceMappingURL=updater-explicit-return-type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updater-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/updater-explicit-return-type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"updater-explicit-return-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/component-store/updater-explicit-return-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAIqB;AAER,QAAA,SAAS,GAAG,2BAA2B,CAAC;AAKrD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,iBAAiB;QAC7B,IAAI,EAAE;YACJ,WAAW,EAAE,gDAAgD;SAC9D;QACD,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE;YACR,CAAC,iBAAS,CAAC,EACT,6HAA6H;SAChI;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE;QAClB,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,IAAA,8BAAsB,EAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAA,iBAAS,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC1E,MAAM,qBAAqB,GAAG,0DAA0D,CAAC;QACzF,MAAM,SAAS,GAAG;YAChB,mIAAmI,qBAAqB,EAAE;YAC1J,UAAU;gBACR,GAAG,IAAA,uBAAe,EAChB,UAAU,CACX,sCAAsC,qBAAqB,EAAE;SACjE;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;QAEb,OAAO;YACL,CAAC,SAAS,CAAC,CAAC,IAAsC;gBAChD,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 {\n asPattern,\n getNgRxComponentStores,\n namedExpression,\n} from '../../utils';\n\nexport const messageId = 'updaterExplicitReturnType';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'component-store',\n docs: {\n description: '`Updater` should have an explicit return type.',\n },\n schema: [],\n messages: {\n [messageId]:\n '`Updater` should have an explicit return type when using arrow functions: `this.store.updater((state, value): State => {}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxComponentStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n const withoutTypeAnnotation = `ArrowFunctionExpression:not([returnType.typeAnnotation])`;\n const selectors = [\n `ClassDeclaration[superClass.name=/Store/] CallExpression[callee.object.type='ThisExpression'][callee.property.name='updater'] > ${withoutTypeAnnotation}`,\n storeNames &&\n `${namedExpression(\n storeNames\n )}[callee.property.name='updater'] > ${withoutTypeAnnotation}`,\n ]\n .filter(Boolean)\n .join(',');\n\n return {\n [selectors](node: TSESTree.ArrowFunctionExpression) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
|
|
@@ -22,50 +22,13 @@ 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 __values = (this && this.__values) || function(o) {
|
|
42
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
43
|
-
if (m) return m.call(o);
|
|
44
|
-
if (o && typeof o.length === "number") return {
|
|
45
|
-
next: function () {
|
|
46
|
-
if (o && i >= o.length) o = void 0;
|
|
47
|
-
return { value: o && o[i++], done: !o };
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
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.messageId = void 0;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
27
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
28
|
+
const path = __importStar(require("path"));
|
|
29
|
+
const ts = __importStar(require("typescript"));
|
|
30
|
+
const rule_creator_1 = require("../../rule-creator");
|
|
31
|
+
const utils_2 = require("../../utils");
|
|
69
32
|
exports.messageId = 'avoidCyclicEffects';
|
|
70
33
|
// This rule is a modified version (to support dispatch: false) from the eslint-plugin-rxjs plugin.
|
|
71
34
|
// The original implementation can be found at https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-cyclic-action.ts
|
|
@@ -77,113 +40,88 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
77
40
|
ngrxModule: 'effects',
|
|
78
41
|
docs: {
|
|
79
42
|
description: 'Avoid `Effect` that re-emit filtered actions.',
|
|
80
|
-
recommended: 'warn',
|
|
81
43
|
requiresTypeChecking: true,
|
|
82
44
|
},
|
|
83
45
|
schema: [],
|
|
84
|
-
messages:
|
|
85
|
-
|
|
86
|
-
|
|
46
|
+
messages: {
|
|
47
|
+
[exports.messageId]: '`Effect` that re-emit filtered actions are forbidden.',
|
|
48
|
+
},
|
|
87
49
|
},
|
|
88
50
|
defaultOptions: [],
|
|
89
|
-
create:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var actionsNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
51
|
+
create: (context) => {
|
|
52
|
+
const { identifiers = [] } = (0, utils_2.getNgRxEffectActions)(context);
|
|
53
|
+
const actionsNames = identifiers.length > 0 ? (0, utils_2.asPattern)(identifiers) : null;
|
|
93
54
|
if (!actionsNames) {
|
|
94
55
|
return {};
|
|
95
56
|
}
|
|
96
|
-
|
|
57
|
+
const services = utils_1.ESLintUtils.getParserServices(context);
|
|
58
|
+
const typeChecker = services.program.getTypeChecker();
|
|
97
59
|
function checkNode(pipeCallExpression) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
(0, utils_1.isIdentifier)(arg.callee) &&
|
|
102
|
-
arg.callee.name === 'ofType';
|
|
103
|
-
});
|
|
60
|
+
const operatorCallExpression = pipeCallExpression.arguments.find((arg) => (0, utils_2.isCallExpression)(arg) &&
|
|
61
|
+
(0, utils_2.isIdentifier)(arg.callee) &&
|
|
62
|
+
arg.callee.name === 'ofType');
|
|
104
63
|
if (!operatorCallExpression) {
|
|
105
64
|
return;
|
|
106
65
|
}
|
|
107
|
-
|
|
108
|
-
|
|
66
|
+
const operatorType = services.getTypeAtLocation(operatorCallExpression);
|
|
67
|
+
const [signature] = typeChecker.getSignaturesOfType(operatorType, ts.SignatureKind.Call);
|
|
109
68
|
if (!signature) {
|
|
110
69
|
return;
|
|
111
70
|
}
|
|
112
|
-
|
|
113
|
-
if (!(0,
|
|
71
|
+
const operatorReturnType = typeChecker.getReturnTypeOfSignature(signature);
|
|
72
|
+
if (!(0, utils_2.isTypeReference)(operatorReturnType)) {
|
|
114
73
|
return;
|
|
115
74
|
}
|
|
116
|
-
|
|
75
|
+
const [operatorElementType] = typeChecker.getTypeArguments(operatorReturnType);
|
|
117
76
|
if (!operatorElementType) {
|
|
118
77
|
return;
|
|
119
78
|
}
|
|
120
|
-
|
|
121
|
-
if (!(0,
|
|
79
|
+
const pipeType = services.getTypeAtLocation(pipeCallExpression);
|
|
80
|
+
if (!(0, utils_2.isTypeReference)(pipeType)) {
|
|
122
81
|
return;
|
|
123
82
|
}
|
|
124
|
-
|
|
83
|
+
const [pipeElementType] = typeChecker.getTypeArguments(pipeType);
|
|
125
84
|
if (!pipeElementType) {
|
|
126
85
|
return;
|
|
127
86
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
});
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
143
|
-
finally {
|
|
144
|
-
try {
|
|
145
|
-
if (operatorActionTypes_1_1 && !operatorActionTypes_1_1.done && (_a = operatorActionTypes_1.return)) _a.call(operatorActionTypes_1);
|
|
87
|
+
const operatorActionTypes = getActionTypes(operatorElementType);
|
|
88
|
+
const pipeActionTypes = getActionTypes(pipeElementType);
|
|
89
|
+
for (const actionType of operatorActionTypes) {
|
|
90
|
+
if (pipeActionTypes.includes(actionType)) {
|
|
91
|
+
context.report({
|
|
92
|
+
node: pipeCallExpression.callee,
|
|
93
|
+
messageId: exports.messageId,
|
|
94
|
+
});
|
|
95
|
+
return;
|
|
146
96
|
}
|
|
147
|
-
finally { if (e_1) throw e_1.error; }
|
|
148
97
|
}
|
|
149
98
|
}
|
|
150
99
|
function getActionType(symbol) {
|
|
151
|
-
|
|
100
|
+
const { valueDeclaration } = symbol;
|
|
152
101
|
if (!valueDeclaration) {
|
|
153
102
|
return null;
|
|
154
103
|
}
|
|
155
104
|
if (valueDeclaration.kind === ts.SyntaxKind.PropertyDeclaration) {
|
|
156
|
-
|
|
157
|
-
return
|
|
158
|
-
? typeChecker.getTypeOfSymbolAtLocation(
|
|
105
|
+
const { parent } = symbol;
|
|
106
|
+
return parent.valueDeclaration
|
|
107
|
+
? typeChecker.getTypeOfSymbolAtLocation(parent, parent.valueDeclaration)
|
|
159
108
|
: null;
|
|
160
109
|
}
|
|
161
110
|
return typeChecker.getTypeOfSymbolAtLocation(symbol, valueDeclaration);
|
|
162
111
|
}
|
|
163
112
|
function getActionTypes(type) {
|
|
164
|
-
var e_2, _a;
|
|
165
113
|
if (type.isUnion()) {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var memberType = _c.value;
|
|
170
|
-
memberActionTypes.push.apply(memberActionTypes, __spreadArray([], __read(getActionTypes(memberType)), false));
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
174
|
-
finally {
|
|
175
|
-
try {
|
|
176
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
177
|
-
}
|
|
178
|
-
finally { if (e_2) throw e_2.error; }
|
|
114
|
+
const memberActionTypes = [];
|
|
115
|
+
for (const memberType of type.types) {
|
|
116
|
+
memberActionTypes.push(...getActionTypes(memberType));
|
|
179
117
|
}
|
|
180
118
|
return memberActionTypes;
|
|
181
119
|
}
|
|
182
|
-
|
|
120
|
+
const symbol = typeChecker.getPropertyOfType(type, 'type');
|
|
183
121
|
if (!symbol) {
|
|
184
122
|
return [];
|
|
185
123
|
}
|
|
186
|
-
|
|
124
|
+
const actionType = getActionType(symbol);
|
|
187
125
|
if (!actionType) {
|
|
188
126
|
return [];
|
|
189
127
|
}
|
|
@@ -194,19 +132,19 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
194
132
|
}
|
|
195
133
|
return [typeChecker.typeToString(actionType)];
|
|
196
134
|
}
|
|
197
|
-
|
|
198
|
-
return
|
|
199
|
-
|
|
135
|
+
let firstPipe = true;
|
|
136
|
+
return {
|
|
137
|
+
[`${utils_2.createEffectExpression}:not([arguments.1]:has(Property[key.name='dispatch'][value.value=false])) CallExpression[callee.property.name='pipe'][callee.object.property.name=${actionsNames}]`](node) {
|
|
200
138
|
if (firstPipe) {
|
|
201
139
|
checkNode(node);
|
|
202
140
|
firstPipe = false;
|
|
203
141
|
return;
|
|
204
142
|
}
|
|
205
143
|
},
|
|
206
|
-
|
|
144
|
+
[`${utils_2.createEffectExpression}:not([arguments.1]:has(Property[key.name='dispatch'][value.value=false])) CallExpression[callee.property.name='pipe']:exit`]() {
|
|
207
145
|
firstPipe = true;
|
|
208
146
|
},
|
|
209
|
-
|
|
147
|
+
};
|
|
210
148
|
},
|
|
211
149
|
});
|
|
212
150
|
//# sourceMappingURL=avoid-cyclic-effects.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avoid-cyclic-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/avoid-cyclic-effects.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"avoid-cyclic-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/avoid-cyclic-effects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAsE;AACtE,2CAA6B;AAC7B,+CAAiC;AACjC,qDAAgD;AAChD,uCAOqB;AAER,QAAA,SAAS,GAAG,oBAAoB,CAAC;AAK9C,mGAAmG;AACnG,uIAAuI;AACvI,0CAA0C;AAE1C,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,SAAS;QACf,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EAAE,+CAA+C;YAC5D,oBAAoB,EAAE,IAAI;SAC3B;QACD,MAAM,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AAC;oBAClB,OAAO;gBACT,CAAC;YACH,CAAC;YAED,CAAC,GAAG,8BAAsB,4HAA4H,CAAC;gBACrJ,SAAS,GAAG,IAAI,CAAC;YACnB,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { ESLintUtils, type TSESTree } from '@typescript-eslint/utils';\nimport * as path from 'path';\nimport * as ts from 'typescript';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n createEffectExpression,\n getNgRxEffectActions,\n isCallExpression,\n isIdentifier,\n isTypeReference,\n} from '../../utils';\n\nexport const messageId = 'avoidCyclicEffects';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\n\n// This rule is a modified version (to support dispatch: false) from the eslint-plugin-rxjs plugin.\n// The original implementation can be found at https://github.com/cartant/eslint-plugin-rxjs/blob/main/source/rules/no-cyclic-action.ts\n// Thank you Nicholas Jamieson (@cartant).\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n docs: {\n description: 'Avoid `Effect` that re-emit filtered actions.',\n requiresTypeChecking: true,\n },\n schema: [],\n messages: {\n [messageId]: '`Effect` that re-emit filtered actions are forbidden.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const { identifiers = [] } = getNgRxEffectActions(context);\n const actionsNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!actionsNames) {\n return {};\n }\n\n const services = ESLintUtils.getParserServices(context);\n const typeChecker = services.program.getTypeChecker();\n\n function checkNode(pipeCallExpression: TSESTree.CallExpression) {\n const operatorCallExpression = pipeCallExpression.arguments.find(\n (arg) =>\n isCallExpression(arg) &&\n isIdentifier(arg.callee) &&\n arg.callee.name === 'ofType'\n );\n if (!operatorCallExpression) {\n return;\n }\n const operatorType = services.getTypeAtLocation(operatorCallExpression);\n const [signature] = typeChecker.getSignaturesOfType(\n operatorType,\n ts.SignatureKind.Call\n );\n\n if (!signature) {\n return;\n }\n const operatorReturnType =\n typeChecker.getReturnTypeOfSignature(signature);\n if (!isTypeReference(operatorReturnType)) {\n return;\n }\n const [operatorElementType] =\n typeChecker.getTypeArguments(operatorReturnType);\n if (!operatorElementType) {\n return;\n }\n\n const pipeType = services.getTypeAtLocation(pipeCallExpression);\n if (!isTypeReference(pipeType)) {\n return;\n }\n const [pipeElementType] = typeChecker.getTypeArguments(pipeType);\n if (!pipeElementType) {\n return;\n }\n\n const operatorActionTypes = getActionTypes(operatorElementType);\n const pipeActionTypes = getActionTypes(pipeElementType);\n\n for (const actionType of operatorActionTypes) {\n if (pipeActionTypes.includes(actionType)) {\n context.report({\n node: pipeCallExpression.callee,\n messageId,\n });\n return;\n }\n }\n }\n\n function getActionType(symbol: ts.Symbol): ts.Type | null {\n const { valueDeclaration } = symbol;\n\n if (!valueDeclaration) {\n return null;\n }\n\n if (valueDeclaration.kind === ts.SyntaxKind.PropertyDeclaration) {\n const { parent } = symbol as typeof symbol & { parent: ts.Symbol };\n return parent.valueDeclaration\n ? typeChecker.getTypeOfSymbolAtLocation(\n parent,\n parent.valueDeclaration\n )\n : null;\n }\n\n return typeChecker.getTypeOfSymbolAtLocation(symbol, valueDeclaration);\n }\n\n function getActionTypes(type: ts.Type): string[] {\n if (type.isUnion()) {\n const memberActionTypes: string[] = [];\n for (const memberType of type.types) {\n memberActionTypes.push(...getActionTypes(memberType));\n }\n return memberActionTypes;\n }\n\n const symbol = typeChecker.getPropertyOfType(type, 'type');\n\n if (!symbol) {\n return [];\n }\n\n const actionType = getActionType(symbol);\n\n if (!actionType) {\n return [];\n }\n\n // TODO: support \"dynamic\" types\n // e.g. const genericFoo = createAction(`${subject} FOO`); (resolves to 'string')\n if (typeChecker.typeToString(actionType) === 'string') {\n return [];\n }\n return [typeChecker.typeToString(actionType)];\n }\n\n let firstPipe = true;\n return {\n [`${createEffectExpression}:not([arguments.1]:has(Property[key.name='dispatch'][value.value=false])) CallExpression[callee.property.name='pipe'][callee.object.property.name=${actionsNames}]`](\n node\n ) {\n if (firstPipe) {\n checkNode(node);\n firstPipe = false;\n return;\n }\n },\n\n [`${createEffectExpression}:not([arguments.1]:has(Property[key.name='dispatch'][value.value=false])) CallExpression[callee.property.name='pipe']:exit`]() {\n firstPipe = true;\n },\n };\n },\n});\n"]}
|