@ngrx/eslint-plugin 14.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 +22 -0
- package/jest.config.js.map +1 -0
- package/migrations/migration.json +3 -0
- package/package.json +51 -0
- package/schematics/collection.json +10 -0
- package/schematics/ng-add/index.js +51 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.js.map +1 -0
- package/schematics/ng-add/schema.json +87 -0
- package/scripts/generate-config.js +85 -0
- package/scripts/generate-config.js.map +1 -0
- package/scripts/generate-docs.js +90 -0
- package/scripts/generate-docs.js.map +1 -0
- package/scripts/generate-overview.js +98 -0
- package/scripts/generate-overview.js.map +1 -0
- package/spec/utils/index.js +22 -0
- package/spec/utils/index.js.map +1 -0
- package/src/configs/all-requiring-type-checking.js +46 -0
- package/src/configs/all-requiring-type-checking.js.map +1 -0
- package/src/configs/all.js +39 -0
- package/src/configs/all.js.map +1 -0
- package/src/configs/component-store-strict.js +11 -0
- package/src/configs/component-store-strict.js.map +1 -0
- package/src/configs/component-store.js +11 -0
- package/src/configs/component-store.js.map +1 -0
- package/src/configs/effects-requiring-type-checking.js +27 -0
- package/src/configs/effects-requiring-type-checking.js.map +1 -0
- package/src/configs/effects-strict-requiring-type-checking.js +27 -0
- package/src/configs/effects-strict-requiring-type-checking.js.map +1 -0
- package/src/configs/effects-strict.js +20 -0
- package/src/configs/effects-strict.js.map +1 -0
- package/src/configs/effects.js +20 -0
- package/src/configs/effects.js.map +1 -0
- package/src/configs/index.js +33 -0
- package/src/configs/index.js.map +1 -0
- package/src/configs/recommended-requiring-type-checking.js +46 -0
- package/src/configs/recommended-requiring-type-checking.js.map +1 -0
- package/src/configs/recommended.js +39 -0
- package/src/configs/recommended.js.map +1 -0
- package/src/configs/store-strict.js +30 -0
- package/src/configs/store-strict.js.map +1 -0
- package/src/configs/store.js +30 -0
- package/src/configs/store.js.map +1 -0
- package/src/configs/strict-requiring-type-checking.js +46 -0
- package/src/configs/strict-requiring-type-checking.js.map +1 -0
- package/src/configs/strict.js +39 -0
- package/src/configs/strict.js.map +1 -0
- package/src/index.js +8 -0
- package/src/index.js.map +1 -0
- package/src/rule-creator.js +29 -0
- package/src/rule-creator.js.map +1 -0
- package/src/rules/component-store/updater-explicit-return-type.js +69 -0
- package/src/rules/component-store/updater-explicit-return-type.js.map +1 -0
- package/src/rules/effects/avoid-cyclic-effects.js +202 -0
- package/src/rules/effects/avoid-cyclic-effects.js.map +1 -0
- package/src/rules/effects/no-dispatch-in-effects.js +83 -0
- package/src/rules/effects/no-dispatch-in-effects.js.map +1 -0
- package/src/rules/effects/no-effect-decorator-and-creator.js +107 -0
- package/src/rules/effects/no-effect-decorator-and-creator.js.map +1 -0
- package/src/rules/effects/no-effect-decorator.js +124 -0
- package/src/rules/effects/no-effect-decorator.js.map +1 -0
- package/src/rules/effects/no-effects-in-providers.js +105 -0
- package/src/rules/effects/no-effects-in-providers.js.map +1 -0
- package/src/rules/effects/no-multiple-actions-in-effects.js +77 -0
- package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -0
- package/src/rules/effects/prefer-action-creator-in-of-type.js +58 -0
- package/src/rules/effects/prefer-action-creator-in-of-type.js.map +1 -0
- package/src/rules/effects/prefer-concat-latest-from.js +153 -0
- package/src/rules/effects/prefer-concat-latest-from.js.map +1 -0
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js +99 -0
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -0
- package/src/rules/effects/use-effects-lifecycle-interface.js +88 -0
- package/src/rules/effects/use-effects-lifecycle-interface.js.map +1 -0
- package/src/rules/index.js +59 -0
- package/src/rules/index.js.map +1 -0
- package/src/rules/store/avoid-combining-selectors.js +65 -0
- package/src/rules/store/avoid-combining-selectors.js.map +1 -0
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js +95 -0
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -0
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js +150 -0
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -0
- package/src/rules/store/avoid-mapping-selectors.js +82 -0
- package/src/rules/store/avoid-mapping-selectors.js.map +1 -0
- package/src/rules/store/good-action-hygiene.js +84 -0
- package/src/rules/store/good-action-hygiene.js.map +1 -0
- package/src/rules/store/no-multiple-global-stores.js +157 -0
- package/src/rules/store/no-multiple-global-stores.js.map +1 -0
- package/src/rules/store/no-reducer-in-key-names.js +76 -0
- package/src/rules/store/no-reducer-in-key-names.js.map +1 -0
- package/src/rules/store/no-store-subscription.js +64 -0
- package/src/rules/store/no-store-subscription.js.map +1 -0
- package/src/rules/store/no-typed-global-store.js +101 -0
- package/src/rules/store/no-typed-global-store.js.map +1 -0
- package/src/rules/store/on-function-explicit-return-type.js +106 -0
- package/src/rules/store/on-function-explicit-return-type.js.map +1 -0
- package/src/rules/store/prefer-action-creator-in-dispatch.js +70 -0
- package/src/rules/store/prefer-action-creator-in-dispatch.js.map +1 -0
- package/src/rules/store/prefer-action-creator.js +58 -0
- package/src/rules/store/prefer-action-creator.js.map +1 -0
- package/src/rules/store/prefer-inline-action-props.js +72 -0
- package/src/rules/store/prefer-inline-action-props.js.map +1 -0
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js +93 -0
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js.map +1 -0
- package/src/rules/store/prefer-selector-in-select.js +93 -0
- package/src/rules/store/prefer-selector-in-select.js.map +1 -0
- package/src/rules/store/prefix-selectors-with-select.js +107 -0
- package/src/rules/store/prefix-selectors-with-select.js.map +1 -0
- package/src/rules/store/select-style.js +196 -0
- package/src/rules/store/select-style.js.map +1 -0
- package/src/rules/store/use-consistent-global-store-name.js +139 -0
- package/src/rules/store/use-consistent-global-store-name.js.map +1 -0
- package/src/utils/helper-functions/docs.js +8 -0
- package/src/utils/helper-functions/docs.js.map +1 -0
- package/src/utils/helper-functions/folder.js +118 -0
- package/src/utils/helper-functions/folder.js.map +1 -0
- package/src/utils/helper-functions/guards.js +56 -0
- package/src/utils/helper-functions/guards.js.map +1 -0
- package/src/utils/helper-functions/index.js +23 -0
- package/src/utils/helper-functions/index.js.map +1 -0
- package/src/utils/helper-functions/ngrx-modules.js +10 -0
- package/src/utils/helper-functions/ngrx-modules.js.map +1 -0
- package/src/utils/helper-functions/utils.js +302 -0
- package/src/utils/helper-functions/utils.js.map +1 -0
- package/src/utils/helper-functions/versions.js +70 -0
- package/src/utils/helper-functions/versions.js.map +1 -0
- package/src/utils/index.js +19 -0
- package/src/utils/index.js.map +1 -0
- package/src/utils/selectors/index.js +58 -0
- package/src/utils/selectors/index.js.map +1 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
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
|
+
exports.__esModule = true;
|
|
43
|
+
exports.noEffectDecoratorSuggest = exports.noEffectDecorator = void 0;
|
|
44
|
+
var path = __importStar(require("path"));
|
|
45
|
+
var rule_creator_1 = require("../../rule-creator");
|
|
46
|
+
var utils_1 = require("../../utils");
|
|
47
|
+
exports.noEffectDecorator = 'noEffectDecorator';
|
|
48
|
+
exports.noEffectDecoratorSuggest = 'noEffectDecoratorSuggest';
|
|
49
|
+
var createEffectKeyword = 'createEffect';
|
|
50
|
+
exports["default"] = (0, rule_creator_1.createRule)({
|
|
51
|
+
name: path.parse(__filename).name,
|
|
52
|
+
meta: {
|
|
53
|
+
type: 'suggestion',
|
|
54
|
+
hasSuggestions: true,
|
|
55
|
+
ngrxModule: 'effects',
|
|
56
|
+
docs: {
|
|
57
|
+
description: "The `".concat(createEffectKeyword, "` is preferred as the `@Effect` decorator is deprecated."),
|
|
58
|
+
recommended: 'warn',
|
|
59
|
+
suggestion: true
|
|
60
|
+
},
|
|
61
|
+
fixable: 'code',
|
|
62
|
+
schema: [],
|
|
63
|
+
messages: (_a = {},
|
|
64
|
+
_a[exports.noEffectDecorator] = "The `@Effect` decorator is deprecated. Use `".concat(createEffectKeyword, "` instead."),
|
|
65
|
+
_a[exports.noEffectDecoratorSuggest] = "Remove the `@Effect` decorator.",
|
|
66
|
+
_a)
|
|
67
|
+
},
|
|
68
|
+
defaultOptions: [],
|
|
69
|
+
create: function (context) {
|
|
70
|
+
var _a;
|
|
71
|
+
var sourceCode = context.getSourceCode();
|
|
72
|
+
return _a = {},
|
|
73
|
+
_a[utils_1.propertyDefinitionWithEffectDecorator] = function (node) {
|
|
74
|
+
var isUsingEffectCreator = (0, utils_1.isIdentifier)(node.parent.value.callee) &&
|
|
75
|
+
node.parent.value.callee.name === createEffectKeyword;
|
|
76
|
+
if (isUsingEffectCreator) {
|
|
77
|
+
context.report({
|
|
78
|
+
node: node,
|
|
79
|
+
messageId: exports.noEffectDecorator,
|
|
80
|
+
suggest: [
|
|
81
|
+
{
|
|
82
|
+
messageId: exports.noEffectDecoratorSuggest,
|
|
83
|
+
fix: function (fixer) { return fixer.remove(node); }
|
|
84
|
+
},
|
|
85
|
+
]
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
context.report({
|
|
90
|
+
node: node,
|
|
91
|
+
messageId: exports.noEffectDecorator,
|
|
92
|
+
fix: function (fixer) { return getFixes(node, sourceCode, fixer); }
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
_a;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
function getCreateEffectFix(fixer, propertyValueExpression) {
|
|
100
|
+
return fixer.insertTextBefore(propertyValueExpression, "".concat(createEffectKeyword, "(() => { return "));
|
|
101
|
+
}
|
|
102
|
+
function getCreateEffectConfigFix(fixer, propertyValueExpression, configText) {
|
|
103
|
+
var append = configText ? ", ".concat(configText) : '';
|
|
104
|
+
return fixer.insertTextAfter(propertyValueExpression, "}".concat(append, ")"));
|
|
105
|
+
}
|
|
106
|
+
function getFixes(node, sourceCode, fixer) {
|
|
107
|
+
var classDeclaration = node.parent.parent.parent;
|
|
108
|
+
var propertyValueExpression = node.parent.value;
|
|
109
|
+
var _a = __read((0, utils_1.getDecoratorArguments)(node), 1), decoratorArgument = _a[0];
|
|
110
|
+
var configText = decoratorArgument
|
|
111
|
+
? sourceCode.getText(decoratorArgument)
|
|
112
|
+
: undefined;
|
|
113
|
+
return [
|
|
114
|
+
fixer.remove(node),
|
|
115
|
+
getCreateEffectFix(fixer, propertyValueExpression),
|
|
116
|
+
getCreateEffectConfigFix(fixer, propertyValueExpression, configText),
|
|
117
|
+
].concat((0, utils_1.getImportAddFix)({
|
|
118
|
+
fixer: fixer,
|
|
119
|
+
importName: createEffectKeyword,
|
|
120
|
+
moduleName: utils_1.NGRX_MODULE_PATHS.effects,
|
|
121
|
+
node: classDeclaration
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=no-effect-decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-effect-decorator.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-effect-decorator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAMqB;AAER,QAAA,iBAAiB,GAAG,mBAAmB,CAAC;AACxC,QAAA,wBAAwB,GAAG,0BAA0B,CAAC;AAWnE,IAAM,mBAAmB,GAAG,cAAc,CAAC;AAE3C,qBAAe,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,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EAAE,eAAS,mBAAmB,6DAA6D;YACtG,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,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M,GAAG,UAAU,CAAC,CAAC,CAAC,YAAK,UAAU,CAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnD,OAAO,KAAK,CAAC,eAAe,CAAC,uBAAuB,EAAE,WAAI,MAAM,MAAG,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,QAAQ,CACf,IAAqB,EACrB,UAAyC,EACzC,KAAyB;IAEzB,IAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IAEvC,IAAO,uBAAuB,GACtC,IAAI,aADkC,CACjC;IAEH,IAAA,KAAA,OAAsB,IAAA,6BAAqB,EAAC,IAAI,CAAC,IAAA,EAAhD,iBAAiB,QAA+B,CAAC;IACxD,IAAM,UAAU,GAAG,iBAAiB;QAClC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACvC,CAAC,CAAC,SAAS,CAAC;IAEd,OAAO;QACL,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;QAClB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,CAAC;QAClD,wBAAwB,CAAC,KAAK,EAAE,uBAAuB,EAAE,UAAU,CAAC;KACrE,CAAC,MAAM,CACN,IAAA,uBAAe,EAAC;QACd,KAAK,OAAA;QACL,UAAU,EAAE,mBAAmB;QAC/B,UAAU,EAAE,yBAAiB,CAAC,OAAO;QACrC,IAAI,EAAE,gBAAgB;KACvB,CAAC,CACH,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 getDecoratorArguments,\n getImportAddFix,\n isIdentifier,\n NGRX_MODULE_PATHS,\n propertyDefinitionWithEffectDecorator,\n} from '../../utils';\n\nexport const noEffectDecorator = 'noEffectDecorator';\nexport const noEffectDecoratorSuggest = 'noEffectDecoratorSuggest';\n\ntype MessageIds = typeof noEffectDecorator | typeof noEffectDecoratorSuggest;\ntype Options = readonly [];\ntype EffectDecorator = TSESTree.Decorator & {\n parent: TSESTree.PropertyDefinition & {\n parent: TSESTree.ClassBody & { parent: TSESTree.ClassDeclaration };\n value: TSESTree.CallExpression;\n };\n};\n\nconst createEffectKeyword = 'createEffect';\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'effects',\n docs: {\n description: `The \\`${createEffectKeyword}\\` is preferred as the \\`@Effect\\` decorator is deprecated.`,\n recommended: 'warn',\n suggestion: true,\n },\n fixable: 'code',\n schema: [],\n messages: {\n [noEffectDecorator]: `The \\`@Effect\\` decorator is deprecated. Use \\`${createEffectKeyword}\\` instead.`,\n [noEffectDecoratorSuggest]: `Remove the \\`@Effect\\` decorator.`,\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n\n return {\n [propertyDefinitionWithEffectDecorator](node: EffectDecorator) {\n const isUsingEffectCreator =\n isIdentifier(node.parent.value.callee) &&\n node.parent.value.callee.name === createEffectKeyword;\n\n if (isUsingEffectCreator) {\n context.report({\n node,\n messageId: noEffectDecorator,\n suggest: [\n {\n messageId: noEffectDecoratorSuggest,\n fix: (fixer) => fixer.remove(node),\n },\n ],\n });\n } else {\n context.report({\n node,\n messageId: noEffectDecorator,\n fix: (fixer) => getFixes(node, sourceCode, fixer),\n });\n }\n },\n };\n },\n});\n\nfunction getCreateEffectFix(\n fixer: TSESLint.RuleFixer,\n propertyValueExpression: TSESTree.CallExpression\n): TSESLint.RuleFix {\n return fixer.insertTextBefore(\n propertyValueExpression,\n `${createEffectKeyword}(() => { return `\n );\n}\n\nfunction getCreateEffectConfigFix(\n fixer: TSESLint.RuleFixer,\n propertyValueExpression: TSESTree.CallExpression,\n configText?: string\n): TSESLint.RuleFix {\n const append = configText ? `, ${configText}` : '';\n return fixer.insertTextAfter(propertyValueExpression, `}${append})`);\n}\n\nfunction getFixes(\n node: EffectDecorator,\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer\n): readonly TSESLint.RuleFix[] {\n const classDeclaration = node.parent.parent.parent;\n const {\n parent: { value: propertyValueExpression },\n } = node;\n\n const [decoratorArgument] = getDecoratorArguments(node);\n const configText = decoratorArgument\n ? sourceCode.getText(decoratorArgument)\n : undefined;\n\n return [\n fixer.remove(node),\n getCreateEffectFix(fixer, propertyValueExpression),\n getCreateEffectConfigFix(fixer, propertyValueExpression, configText),\n ].concat(\n getImportAddFix({\n fixer,\n importName: createEffectKeyword,\n moduleName: NGRX_MODULE_PATHS.effects,\n node: classDeclaration,\n })\n );\n}\n"]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
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
|
+
exports.__esModule = true;
|
|
38
|
+
exports.messageId = void 0;
|
|
39
|
+
var path = __importStar(require("path"));
|
|
40
|
+
var rule_creator_1 = require("../../rule-creator");
|
|
41
|
+
var utils_1 = require("../../utils");
|
|
42
|
+
exports.messageId = 'noEffectsInProviders';
|
|
43
|
+
exports["default"] = (0, rule_creator_1.createRule)({
|
|
44
|
+
name: path.parse(__filename).name,
|
|
45
|
+
meta: {
|
|
46
|
+
type: 'problem',
|
|
47
|
+
ngrxModule: 'effects',
|
|
48
|
+
docs: {
|
|
49
|
+
description: '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',
|
|
50
|
+
recommended: 'error'
|
|
51
|
+
},
|
|
52
|
+
fixable: 'code',
|
|
53
|
+
schema: [],
|
|
54
|
+
messages: (_a = {},
|
|
55
|
+
_a[exports.messageId] = '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',
|
|
56
|
+
_a)
|
|
57
|
+
},
|
|
58
|
+
defaultOptions: [],
|
|
59
|
+
create: function (context) {
|
|
60
|
+
var _a;
|
|
61
|
+
var sourceCode = context.getSourceCode();
|
|
62
|
+
var effectsInProviders = new Set();
|
|
63
|
+
var effectsInImports = new Set();
|
|
64
|
+
return _a = {},
|
|
65
|
+
_a[utils_1.effectsInNgModuleProviders] = function (node) {
|
|
66
|
+
effectsInProviders.add(node);
|
|
67
|
+
},
|
|
68
|
+
_a[utils_1.effectsInNgModuleImports] = function (_a) {
|
|
69
|
+
var name = _a.name;
|
|
70
|
+
effectsInImports.add(name);
|
|
71
|
+
},
|
|
72
|
+
_a["".concat(utils_1.ngModuleDecorator, ":exit")] = function () {
|
|
73
|
+
var e_1, _a;
|
|
74
|
+
var _loop_1 = function (effectInProvider) {
|
|
75
|
+
if (!effectsInImports.has(effectInProvider.name)) {
|
|
76
|
+
return "continue";
|
|
77
|
+
}
|
|
78
|
+
context.report({
|
|
79
|
+
node: effectInProvider,
|
|
80
|
+
messageId: exports.messageId,
|
|
81
|
+
fix: function (fixer) {
|
|
82
|
+
return (0, utils_1.getNodeToCommaRemoveFix)(sourceCode, fixer, effectInProvider);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
try {
|
|
87
|
+
for (var effectsInProviders_1 = __values(effectsInProviders), effectsInProviders_1_1 = effectsInProviders_1.next(); !effectsInProviders_1_1.done; effectsInProviders_1_1 = effectsInProviders_1.next()) {
|
|
88
|
+
var effectInProvider = effectsInProviders_1_1.value;
|
|
89
|
+
_loop_1(effectInProvider);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
93
|
+
finally {
|
|
94
|
+
try {
|
|
95
|
+
if (effectsInProviders_1_1 && !effectsInProviders_1_1.done && (_a = effectsInProviders_1["return"])) _a.call(effectsInProviders_1);
|
|
96
|
+
}
|
|
97
|
+
finally { if (e_1) throw e_1.error; }
|
|
98
|
+
}
|
|
99
|
+
effectsInImports.clear();
|
|
100
|
+
effectsInProviders.clear();
|
|
101
|
+
},
|
|
102
|
+
_a;
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
//# sourceMappingURL=no-effects-in-providers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-effects-in-providers.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-effects-in-providers.ts"],"names":[],"mappings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B,CAAC;wBAA5D,CAA4D;qBAC/D,CAAC,CAAC;;;oBAVL,KAA+B,IAAA,uBAAA,SAAA,kBAAkB,CAAA,sDAAA;wBAA5C,IAAM,gBAAgB,+BAAA;gCAAhB,gBAAgB;qBAW1B;;;;;;;;;gBAED,gBAAgB,CAAC,KAAK,EAAE,CAAC;gBACzB,kBAAkB,CAAC,KAAK,EAAE,CAAC;YAC7B,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 effectsInNgModuleImports,\n effectsInNgModuleProviders,\n getNodeToCommaRemoveFix,\n ngModuleDecorator,\n} from '../../utils';\n\nexport const messageId = 'noEffectsInProviders';\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: 'effects',\n docs: {\n description:\n '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',\n recommended: 'error',\n },\n fixable: 'code',\n schema: [],\n messages: {\n [messageId]:\n '`Effect` should not be listed as a provider if it is added to the `EffectsModule`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n const sourceCode = context.getSourceCode();\n const effectsInProviders = new Set<TSESTree.Identifier>();\n const effectsInImports = new Set<string>();\n\n return {\n [effectsInNgModuleProviders](node: TSESTree.Identifier) {\n effectsInProviders.add(node);\n },\n [effectsInNgModuleImports]({ name }: TSESTree.Identifier) {\n effectsInImports.add(name);\n },\n [`${ngModuleDecorator}:exit`]() {\n for (const effectInProvider of effectsInProviders) {\n if (!effectsInImports.has(effectInProvider.name)) {\n continue;\n }\n\n context.report({\n node: effectInProvider,\n messageId,\n fix: (fixer) =>\n getNodeToCommaRemoveFix(sourceCode, fixer, effectInProvider),\n });\n }\n\n effectsInImports.clear();\n effectsInProviders.clear();\n },\n };\n },\n});\n"]}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var _a;
|
|
26
|
+
exports.__esModule = true;
|
|
27
|
+
exports.messageId = void 0;
|
|
28
|
+
var experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|
29
|
+
var eslint_etc_1 = require("eslint-etc");
|
|
30
|
+
var path = __importStar(require("path"));
|
|
31
|
+
var rule_creator_1 = require("../../rule-creator");
|
|
32
|
+
var utils_1 = require("../../utils");
|
|
33
|
+
exports.messageId = 'noMultipleActionsInEffects';
|
|
34
|
+
exports["default"] = (0, rule_creator_1.createRule)({
|
|
35
|
+
name: path.parse(__filename).name,
|
|
36
|
+
meta: {
|
|
37
|
+
type: 'problem',
|
|
38
|
+
ngrxModule: 'effects',
|
|
39
|
+
docs: {
|
|
40
|
+
description: '`Effect` should not return multiple actions.',
|
|
41
|
+
recommended: 'warn',
|
|
42
|
+
requiresTypeChecking: true
|
|
43
|
+
},
|
|
44
|
+
schema: [],
|
|
45
|
+
messages: (_a = {},
|
|
46
|
+
_a[exports.messageId] = '`Effect` should return a single action.',
|
|
47
|
+
_a)
|
|
48
|
+
},
|
|
49
|
+
defaultOptions: [],
|
|
50
|
+
create: function (context) {
|
|
51
|
+
var _a;
|
|
52
|
+
return _a = {},
|
|
53
|
+
_a["".concat(utils_1.createEffectExpression, " :matches(").concat(utils_1.mapLikeOperatorsImplicitReturn, ", ").concat(utils_1.mapLikeOperatorsExplicitReturn, ")")] = function (node) {
|
|
54
|
+
var nodeToReport = getNodeToReport(node);
|
|
55
|
+
if (!nodeToReport ||
|
|
56
|
+
!(0, eslint_etc_1.getTypeServices)(context).couldBeType(nodeToReport, 'Array')) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
context.report({
|
|
60
|
+
node: nodeToReport,
|
|
61
|
+
messageId: exports.messageId
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
_a;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
function getNodeToReport(node) {
|
|
68
|
+
switch (node.type) {
|
|
69
|
+
case experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression:
|
|
70
|
+
return node.body;
|
|
71
|
+
case experimental_utils_1.AST_NODE_TYPES.CallExpression:
|
|
72
|
+
return node.arguments[0];
|
|
73
|
+
default:
|
|
74
|
+
return node.argument;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=no-multiple-actions-in-effects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-multiple-actions-in-effects.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/no-multiple-actions-in-effects.ts"],"names":[],"mappings":";;;;;;;;;;;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sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils';\nimport { getTypeServices } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n createEffectExpression,\n mapLikeOperatorsExplicitReturn,\n mapLikeOperatorsImplicitReturn,\n} from '../../utils';\n\nexport const messageId = 'noMultipleActionsInEffects';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [];\ntype EffectsMapLikeOperatorsReturn =\n | TSESTree.ArrowFunctionExpression\n | TSESTree.CallExpression\n | TSESTree.ReturnStatement;\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n docs: {\n description: '`Effect` should not return multiple actions.',\n recommended: 'warn',\n requiresTypeChecking: true,\n },\n schema: [],\n messages: {\n [messageId]: '`Effect` should return a single action.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`${createEffectExpression} :matches(${mapLikeOperatorsImplicitReturn}, ${mapLikeOperatorsExplicitReturn})`](\n node: EffectsMapLikeOperatorsReturn\n ) {\n const nodeToReport = getNodeToReport(node);\n\n if (\n !nodeToReport ||\n !getTypeServices(context).couldBeType(nodeToReport, 'Array')\n ) {\n return;\n }\n\n context.report({\n node: nodeToReport,\n messageId,\n });\n },\n };\n },\n});\n\nfunction getNodeToReport(node: EffectsMapLikeOperatorsReturn) {\n switch (node.type) {\n case AST_NODE_TYPES.ArrowFunctionExpression:\n return node.body;\n case AST_NODE_TYPES.CallExpression:\n return node.arguments[0];\n default:\n return node.argument;\n }\n}\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var _a;
|
|
26
|
+
exports.__esModule = true;
|
|
27
|
+
exports.messageId = void 0;
|
|
28
|
+
var path = __importStar(require("path"));
|
|
29
|
+
var rule_creator_1 = require("../../rule-creator");
|
|
30
|
+
exports.messageId = 'preferActionCreatorInOfType';
|
|
31
|
+
exports["default"] = (0, rule_creator_1.createRule)({
|
|
32
|
+
name: path.parse(__filename).name,
|
|
33
|
+
meta: {
|
|
34
|
+
type: 'suggestion',
|
|
35
|
+
ngrxModule: 'effects',
|
|
36
|
+
docs: {
|
|
37
|
+
description: 'Using `action creator` in `ofType` is preferred over `string`.',
|
|
38
|
+
recommended: 'warn'
|
|
39
|
+
},
|
|
40
|
+
schema: [],
|
|
41
|
+
messages: (_a = {},
|
|
42
|
+
_a[exports.messageId] = 'Using `string` is forbidden. Use `action creator` instead.',
|
|
43
|
+
_a)
|
|
44
|
+
},
|
|
45
|
+
defaultOptions: [],
|
|
46
|
+
create: function (context) {
|
|
47
|
+
var _a;
|
|
48
|
+
return _a = {},
|
|
49
|
+
_a["CallExpression[callee.name='ofType'] Literal"] = function (node) {
|
|
50
|
+
context.report({
|
|
51
|
+
node: node,
|
|
52
|
+
messageId: exports.messageId
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
_a;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=prefer-action-creator-in-of-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-action-creator-in-of-type.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/prefer-action-creator-in-of-type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAEnC,QAAA,SAAS,GAAG,6BAA6B,CAAC;AAKvD,qBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,SAAS;QACrB,IAAI,EAAE;YACJ,WAAW,EACT,gEAAgE;YAClE,WAAW,EAAE,MAAM;SACpB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iBAAS,IAAG,4DAA4D;eAC1E;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;;QACd;YACE,GAAC,8CAA8C,IAA/C,UAAiD,IAAsB;gBACrE,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';\n\nexport const messageId = 'preferActionCreatorInOfType';\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: 'effects',\n docs: {\n description:\n 'Using `action creator` in `ofType` is preferred over `string`.',\n recommended: 'warn',\n },\n schema: [],\n messages: {\n [messageId]: 'Using `string` is forbidden. Use `action creator` instead.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n [`CallExpression[callee.name='ofType'] Literal`](node: TSESTree.Literal) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n"]}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
42
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
43
|
+
if (ar || !(i in from)) {
|
|
44
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
45
|
+
ar[i] = from[i];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
49
|
+
};
|
|
50
|
+
var _a;
|
|
51
|
+
exports.__esModule = true;
|
|
52
|
+
exports.messageId = void 0;
|
|
53
|
+
var eslint_etc_1 = require("eslint-etc");
|
|
54
|
+
var path = __importStar(require("path"));
|
|
55
|
+
var rule_creator_1 = require("../../rule-creator");
|
|
56
|
+
var utils_1 = require("../../utils");
|
|
57
|
+
exports.messageId = 'preferConcatLatestFrom';
|
|
58
|
+
var defaultOptions = { strict: false };
|
|
59
|
+
var concatLatestFromKeyword = 'concatLatestFrom';
|
|
60
|
+
var withLatestFromKeyword = 'withLatestFrom';
|
|
61
|
+
exports["default"] = (0, rule_creator_1.createRule)({
|
|
62
|
+
name: path.parse(__filename).name,
|
|
63
|
+
meta: {
|
|
64
|
+
type: 'problem',
|
|
65
|
+
ngrxModule: 'effects',
|
|
66
|
+
version: '>=12.0.0',
|
|
67
|
+
docs: {
|
|
68
|
+
description: "Use `".concat(concatLatestFromKeyword, "` instead of `").concat(withLatestFromKeyword, "` to prevent the selector from firing until the correct `Action` is dispatched."),
|
|
69
|
+
recommended: 'warn'
|
|
70
|
+
},
|
|
71
|
+
fixable: 'code',
|
|
72
|
+
schema: [
|
|
73
|
+
{
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {
|
|
76
|
+
strict: {
|
|
77
|
+
type: 'boolean',
|
|
78
|
+
"default": defaultOptions.strict
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
additionalProperties: false
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
messages: (_a = {},
|
|
85
|
+
_a[exports.messageId] = "Use `".concat(concatLatestFromKeyword, "` instead of `").concat(withLatestFromKeyword, "`."),
|
|
86
|
+
_a)
|
|
87
|
+
},
|
|
88
|
+
defaultOptions: [defaultOptions],
|
|
89
|
+
create: function (context, _a) {
|
|
90
|
+
var _b, _c;
|
|
91
|
+
var _d = __read(_a, 1), options = _d[0];
|
|
92
|
+
if (options.strict) {
|
|
93
|
+
return _b = {},
|
|
94
|
+
_b["".concat(utils_1.createEffectExpression, " CallExpression > Identifier[name='withLatestFrom']")] = function (node) {
|
|
95
|
+
context.report({
|
|
96
|
+
node: node,
|
|
97
|
+
messageId: exports.messageId,
|
|
98
|
+
fix: function (fixer) { return getFixes(context.getSourceCode(), fixer, node); }
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
_b;
|
|
102
|
+
}
|
|
103
|
+
var _e = (0, utils_1.getNgRxEffectActions)(context), _f = _e.identifiers, identifiers = _f === void 0 ? [] : _f, sourceCode = _e.sourceCode;
|
|
104
|
+
var actionsNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
105
|
+
if (!actionsNames) {
|
|
106
|
+
return {};
|
|
107
|
+
}
|
|
108
|
+
return _c = {},
|
|
109
|
+
_c["".concat(utils_1.createEffectExpression, " ").concat((0, utils_1.namedExpression)(actionsNames), " > CallExpression[arguments.length=1] > Identifier[name='").concat(withLatestFromKeyword, "']")] = function (node) {
|
|
110
|
+
context.report({
|
|
111
|
+
node: node,
|
|
112
|
+
messageId: exports.messageId,
|
|
113
|
+
fix: function (fixer) { return getFixes(sourceCode, fixer, node); }
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
_c["".concat(utils_1.createEffectExpression, " ").concat((0, utils_1.namedExpression)(actionsNames), " > CallExpression[arguments.length>1] > Identifier[name='").concat(withLatestFromKeyword, "']")] = function (node) {
|
|
117
|
+
context.report({
|
|
118
|
+
node: node,
|
|
119
|
+
messageId: exports.messageId
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
_c;
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
function getFixes(sourceCode, fixer, node) {
|
|
126
|
+
var _a;
|
|
127
|
+
var parent = node.parent;
|
|
128
|
+
var isUsingDeprecatedProjectorArgument = parent.arguments.length > 1;
|
|
129
|
+
var _b = __read(parent.arguments, 1), firstArgument = _b[0];
|
|
130
|
+
var nextToken = isUsingDeprecatedProjectorArgument &&
|
|
131
|
+
sourceCode.getTokenAfter(firstArgument);
|
|
132
|
+
return (_a = __spreadArray([
|
|
133
|
+
fixer.replaceText(node, concatLatestFromKeyword)
|
|
134
|
+
], __read(((0, eslint_etc_1.isArrowFunctionExpression)(firstArgument)
|
|
135
|
+
? []
|
|
136
|
+
: [fixer.insertTextBefore(firstArgument, '() => ')])), false)).concat.apply(_a, __spreadArray([(0, utils_1.getImportAddFix)({
|
|
137
|
+
fixer: fixer,
|
|
138
|
+
importName: concatLatestFromKeyword,
|
|
139
|
+
moduleName: utils_1.NGRX_MODULE_PATHS.effects,
|
|
140
|
+
node: node
|
|
141
|
+
})], __read((isUsingDeprecatedProjectorArgument && nextToken
|
|
142
|
+
? [
|
|
143
|
+
(0, utils_1.getImportAddFix)({
|
|
144
|
+
fixer: fixer,
|
|
145
|
+
importName: 'map',
|
|
146
|
+
moduleName: 'rxjs/operators',
|
|
147
|
+
node: node
|
|
148
|
+
}),
|
|
149
|
+
fixer.insertTextAfterRange(nextToken.range, '), map('),
|
|
150
|
+
]
|
|
151
|
+
: [])), false));
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=prefer-concat-latest-from.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefer-concat-latest-from.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/effects/prefer-concat-latest-from.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAAuD;AACvD,yCAA6B;AAC7B,mDAAgD;AAChD,qCAOqB;AAER,QAAA,SAAS,GAAG,wBAAwB,CAAC;AAQlD,IAAM,cAAc,GAAoB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AAC1D,IAAM,uBAAuB,GAAG,kBAAkB,CAAC;AACnD,IAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C,qBAAe,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,OAAO,EAAE,UAAU;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,eAAS,uBAAuB,2BAAmB,qBAAqB,oFAAoF;YACzK,WAAW,EAAE,MAAM;SACpB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,MAAM,EAAE;wBACN,IAAI,EAAE,SAAS;wBACf,SAAO,EAAE,cAAc,CAAC,MAAM;qBAC/B;iBACF;gBACD,oBAAoB,EAAE,KAAK;aAC5B;SACF;QACD,QAAQ;YACN,GAAC,iBAAS,IAAG,eAAS,uBAAuB,2BAAmB,qBAAqB,OAAK;eAC3F;KACF;IACD,cAAc,EAAE,CAAC,cAAc,CAAC;IAChC,MAAM,EAAE,UAAC,OAAO,EAAE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,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,QAAQ,CACf,UAAyC,EACzC,KAAyB,EACzB,IAA8B;;IAEtB,IAAA,MAAM,GAAK,IAAI,OAAT,CAAU;IACxB,IAAM,kCAAkC,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACjE,IAAA,KAAA,OAAkB,MAAM,CAAC,SAAS,IAAA,EAAjC,aAAa,QAAoB,CAAC;IACzC,IAAM,SAAS,GACb,kCAAkC;QAClC,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;IAC1C,OAAO,CAAA;QACL,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,uBAAuB,CAAC;cAC7C,CAAC,IAAA,sCAAyB,EAAC,aAAa,CAAC;QAC1C,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC,CAAC,SACvD,CAAA,CAAC,MAAM,0BACN,IAAA,uBAAe,EAAC;YACd,KAAK,OAAA;YACL,UAAU,EAAE,uBAAuB;YACnC,UAAU,EAAE,yBAAiB,CAAC,OAAO;YACrC,IAAI,MAAA;SACL,CAAC,UACC,CAAC,kCAAkC,IAAI,SAAS;QACjD,CAAC,CAAC;YACE,IAAA,uBAAe,EAAC;gBACd,KAAK,OAAA;gBACL,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,gBAAgB;gBAC5B,IAAI,MAAA;aACL,CAAC;YACF,KAAK,CAAC,oBAAoB,CAAC,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC;SACvD;QACH,CAAC,CAAC,EAAE,CAAC,WACP;AACJ,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { isArrowFunctionExpression } from 'eslint-etc';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport {\n asPattern,\n createEffectExpression,\n getImportAddFix,\n getNgRxEffectActions,\n namedExpression,\n NGRX_MODULE_PATHS,\n} from '../../utils';\n\nexport const messageId = 'preferConcatLatestFrom';\n\ntype MessageIds = typeof messageId;\ntype Options = readonly [{ readonly strict: boolean }];\ntype WithLatestFromIdentifier = TSESTree.Identifier & {\n parent: TSESTree.CallExpression;\n};\n\nconst defaultOptions: Options[number] = { strict: false };\nconst concatLatestFromKeyword = 'concatLatestFrom';\nconst withLatestFromKeyword = 'withLatestFrom';\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'problem',\n ngrxModule: 'effects',\n version: '>=12.0.0',\n docs: {\n description: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\` to prevent the selector from firing until the correct \\`Action\\` is dispatched.`,\n recommended: 'warn',\n },\n fixable: 'code',\n schema: [\n {\n type: 'object',\n properties: {\n strict: {\n type: 'boolean',\n default: defaultOptions.strict,\n },\n },\n additionalProperties: false,\n },\n ],\n messages: {\n [messageId]: `Use \\`${concatLatestFromKeyword}\\` instead of \\`${withLatestFromKeyword}\\`.`,\n },\n },\n defaultOptions: [defaultOptions],\n create: (context, [options]) => {\n if (options.strict) {\n return {\n [`${createEffectExpression} CallExpression > Identifier[name='withLatestFrom']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(context.getSourceCode(), fixer, node),\n });\n },\n };\n }\n\n const { identifiers = [], sourceCode } = getNgRxEffectActions(context);\n const actionsNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!actionsNames) {\n return {};\n }\n\n return {\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length=1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n fix: (fixer) => getFixes(sourceCode, fixer, node),\n });\n },\n [`${createEffectExpression} ${namedExpression(\n actionsNames\n )} > CallExpression[arguments.length>1] > Identifier[name='${withLatestFromKeyword}']`](\n node: WithLatestFromIdentifier\n ) {\n context.report({\n node,\n messageId,\n });\n },\n };\n },\n});\n\nfunction getFixes(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: WithLatestFromIdentifier\n) {\n const { parent } = node;\n const isUsingDeprecatedProjectorArgument = parent.arguments.length > 1;\n const [firstArgument] = parent.arguments;\n const nextToken =\n isUsingDeprecatedProjectorArgument &&\n sourceCode.getTokenAfter(firstArgument);\n return [\n fixer.replaceText(node, concatLatestFromKeyword),\n ...(isArrowFunctionExpression(firstArgument)\n ? []\n : [fixer.insertTextBefore(firstArgument, '() => ')]),\n ].concat(\n getImportAddFix({\n fixer,\n importName: concatLatestFromKeyword,\n moduleName: NGRX_MODULE_PATHS.effects,\n node,\n }),\n ...(isUsingDeprecatedProjectorArgument && nextToken\n ? [\n getImportAddFix({\n fixer,\n importName: 'map',\n moduleName: 'rxjs/operators',\n node,\n }),\n fixer.insertTextAfterRange(nextToken.range, '), map('),\n ]\n : [])\n );\n}\n"]}
|