@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,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __values = (this && this.__values) || function(o) {
|
|
3
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
+
if (m) return m.call(o);
|
|
5
|
+
if (o && typeof o.length === "number") return {
|
|
6
|
+
next: function () {
|
|
7
|
+
if (o && i >= o.length) o = void 0;
|
|
8
|
+
return { value: o && o[i++], done: !o };
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
+
};
|
|
13
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
14
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
15
|
+
if (!m) return o;
|
|
16
|
+
var i = m.call(o), r, ar = [], e;
|
|
17
|
+
try {
|
|
18
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
19
|
+
}
|
|
20
|
+
catch (error) { e = { error: error }; }
|
|
21
|
+
finally {
|
|
22
|
+
try {
|
|
23
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
24
|
+
}
|
|
25
|
+
finally { if (e) throw e.error; }
|
|
26
|
+
}
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
30
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
31
|
+
if (ar || !(i in from)) {
|
|
32
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
33
|
+
ar[i] = from[i];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
37
|
+
};
|
|
38
|
+
exports.__esModule = true;
|
|
39
|
+
exports.asPattern = exports.escapeText = exports.getNgRxStores = exports.getNgRxComponentStores = exports.getNgRxEffectActions = exports.capitalize = exports.getRawText = exports.getDecorator = exports.getDecoratorName = exports.getDecoratorArguments = exports.getLast = exports.getImplementsSchemaFixer = exports.getInterface = exports.getInterfaces = exports.getInterfaceName = exports.getNodeToCommaRemoveFix = exports.getImportRemoveFix = exports.getImportAddFix = exports.getImportDeclarations = exports.getImportDeclarationSpecifier = exports.getNearestUpperNodeFrom = void 0;
|
|
40
|
+
var experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|
41
|
+
var guards_1 = require("./guards");
|
|
42
|
+
var ngrx_modules_1 = require("./ngrx-modules");
|
|
43
|
+
function getNearestUpperNodeFrom(_a, predicate) {
|
|
44
|
+
var parent = _a.parent;
|
|
45
|
+
while (parent && !(0, guards_1.isProgram)(parent)) {
|
|
46
|
+
if (predicate(parent)) {
|
|
47
|
+
return parent;
|
|
48
|
+
}
|
|
49
|
+
parent = parent.parent;
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
exports.getNearestUpperNodeFrom = getNearestUpperNodeFrom;
|
|
54
|
+
function getImportDeclarationSpecifier(importDeclarations, importName) {
|
|
55
|
+
var e_1, _a;
|
|
56
|
+
try {
|
|
57
|
+
for (var importDeclarations_1 = __values(importDeclarations), importDeclarations_1_1 = importDeclarations_1.next(); !importDeclarations_1_1.done; importDeclarations_1_1 = importDeclarations_1.next()) {
|
|
58
|
+
var importDeclaration = importDeclarations_1_1.value;
|
|
59
|
+
var importSpecifier = importDeclaration.specifiers.find(function (importClause) {
|
|
60
|
+
return ((0, guards_1.isImportSpecifier)(importClause) &&
|
|
61
|
+
importClause.imported.name === importName);
|
|
62
|
+
});
|
|
63
|
+
if (importSpecifier) {
|
|
64
|
+
return { importDeclaration: importDeclaration, importSpecifier: importSpecifier };
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
69
|
+
finally {
|
|
70
|
+
try {
|
|
71
|
+
if (importDeclarations_1_1 && !importDeclarations_1_1.done && (_a = importDeclarations_1["return"])) _a.call(importDeclarations_1);
|
|
72
|
+
}
|
|
73
|
+
finally { if (e_1) throw e_1.error; }
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
exports.getImportDeclarationSpecifier = getImportDeclarationSpecifier;
|
|
78
|
+
function getImportDeclarations(node, moduleName) {
|
|
79
|
+
var parentNode = node;
|
|
80
|
+
while (parentNode && !(0, guards_1.isProgram)(parentNode)) {
|
|
81
|
+
parentNode = parentNode.parent;
|
|
82
|
+
}
|
|
83
|
+
return parentNode === null || parentNode === void 0 ? void 0 : parentNode.body.filter(function (node) {
|
|
84
|
+
return (0, guards_1.isImportDeclaration)(node) && node.source.value === moduleName;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
exports.getImportDeclarations = getImportDeclarations;
|
|
88
|
+
function getCorrespondentImportClause(importDeclarations, compatibleWithTypeOnlyImport) {
|
|
89
|
+
var e_2, _a;
|
|
90
|
+
if (compatibleWithTypeOnlyImport === void 0) { compatibleWithTypeOnlyImport = false; }
|
|
91
|
+
var importClause;
|
|
92
|
+
try {
|
|
93
|
+
for (var importDeclarations_2 = __values(importDeclarations), importDeclarations_2_1 = importDeclarations_2.next(); !importDeclarations_2_1.done; importDeclarations_2_1 = importDeclarations_2.next()) {
|
|
94
|
+
var _b = importDeclarations_2_1.value, importKind = _b.importKind, specifiers = _b.specifiers;
|
|
95
|
+
var lastImportSpecifier = getLast(specifiers);
|
|
96
|
+
if ((!compatibleWithTypeOnlyImport && importKind === 'type') ||
|
|
97
|
+
(0, guards_1.isImportNamespaceSpecifier)(lastImportSpecifier)) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
importClause = lastImportSpecifier;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
104
|
+
finally {
|
|
105
|
+
try {
|
|
106
|
+
if (importDeclarations_2_1 && !importDeclarations_2_1.done && (_a = importDeclarations_2["return"])) _a.call(importDeclarations_2);
|
|
107
|
+
}
|
|
108
|
+
finally { if (e_2) throw e_2.error; }
|
|
109
|
+
}
|
|
110
|
+
return importClause;
|
|
111
|
+
}
|
|
112
|
+
function getImportAddFix(_a) {
|
|
113
|
+
var _b = _a.compatibleWithTypeOnlyImport, compatibleWithTypeOnlyImport = _b === void 0 ? false : _b, fixer = _a.fixer, importName = _a.importName, moduleName = _a.moduleName, node = _a.node;
|
|
114
|
+
var fullImport = "import { ".concat(importName, " } from '").concat(moduleName, "';\n");
|
|
115
|
+
var importDeclarations = getImportDeclarations(node, moduleName);
|
|
116
|
+
if (!(importDeclarations === null || importDeclarations === void 0 ? void 0 : importDeclarations.length)) {
|
|
117
|
+
return fixer.insertTextAfterRange([0, 0], fullImport);
|
|
118
|
+
}
|
|
119
|
+
var importDeclarationSpecifier = getImportDeclarationSpecifier(importDeclarations, importName);
|
|
120
|
+
if (importDeclarationSpecifier) {
|
|
121
|
+
return [];
|
|
122
|
+
}
|
|
123
|
+
var importClause = getCorrespondentImportClause(importDeclarations, compatibleWithTypeOnlyImport);
|
|
124
|
+
if (!importClause) {
|
|
125
|
+
return fixer.insertTextAfterRange([0, 0], fullImport);
|
|
126
|
+
}
|
|
127
|
+
var replacementText = (0, guards_1.isImportDefaultSpecifier)(importClause)
|
|
128
|
+
? ", { ".concat(importName, " }")
|
|
129
|
+
: ", ".concat(importName);
|
|
130
|
+
return fixer.insertTextAfter(importClause, replacementText);
|
|
131
|
+
}
|
|
132
|
+
exports.getImportAddFix = getImportAddFix;
|
|
133
|
+
function getImportRemoveFix(sourceCode, importDeclarations, importedName, fixer) {
|
|
134
|
+
var _a;
|
|
135
|
+
var _b = (_a = getImportDeclarationSpecifier(importDeclarations, importedName)) !== null && _a !== void 0 ? _a : {}, importDeclaration = _b.importDeclaration, importSpecifier = _b.importSpecifier;
|
|
136
|
+
if (!importDeclaration || !importSpecifier) {
|
|
137
|
+
return [];
|
|
138
|
+
}
|
|
139
|
+
var isFirstImportSpecifier = importDeclaration.specifiers[0] === importSpecifier;
|
|
140
|
+
var isLastImportSpecifier = getLast(importDeclaration.specifiers) === importSpecifier;
|
|
141
|
+
var isSingleImportSpecifier = isFirstImportSpecifier && isLastImportSpecifier;
|
|
142
|
+
if (isSingleImportSpecifier) {
|
|
143
|
+
return fixer.remove(importDeclaration);
|
|
144
|
+
}
|
|
145
|
+
var tokenAfterImportSpecifier = sourceCode.getTokenAfter(importSpecifier);
|
|
146
|
+
if (isFirstImportSpecifier && tokenAfterImportSpecifier) {
|
|
147
|
+
return fixer.removeRange([
|
|
148
|
+
importSpecifier.range[0],
|
|
149
|
+
tokenAfterImportSpecifier.range[1],
|
|
150
|
+
]);
|
|
151
|
+
}
|
|
152
|
+
var tokenBeforeImportSpecifier = sourceCode.getTokenBefore(importSpecifier);
|
|
153
|
+
if (!tokenBeforeImportSpecifier) {
|
|
154
|
+
return [];
|
|
155
|
+
}
|
|
156
|
+
return fixer.removeRange([
|
|
157
|
+
tokenBeforeImportSpecifier.range[0],
|
|
158
|
+
importSpecifier.range[1],
|
|
159
|
+
]);
|
|
160
|
+
}
|
|
161
|
+
exports.getImportRemoveFix = getImportRemoveFix;
|
|
162
|
+
function getNodeToCommaRemoveFix(sourceCode, fixer, node) {
|
|
163
|
+
var nextToken = sourceCode.getTokenAfter(node);
|
|
164
|
+
var isNextTokenComma = nextToken && experimental_utils_1.ASTUtils.isCommaToken(nextToken);
|
|
165
|
+
return __spreadArray([
|
|
166
|
+
fixer.remove(node)
|
|
167
|
+
], __read((isNextTokenComma ? [fixer.remove(nextToken)] : [])), false);
|
|
168
|
+
}
|
|
169
|
+
exports.getNodeToCommaRemoveFix = getNodeToCommaRemoveFix;
|
|
170
|
+
function getInterfaceName(interfaceMember) {
|
|
171
|
+
if ((0, guards_1.isIdentifier)(interfaceMember)) {
|
|
172
|
+
return interfaceMember.name;
|
|
173
|
+
}
|
|
174
|
+
return (0, guards_1.isIdentifier)(interfaceMember.property)
|
|
175
|
+
? interfaceMember.property.name
|
|
176
|
+
: undefined;
|
|
177
|
+
}
|
|
178
|
+
exports.getInterfaceName = getInterfaceName;
|
|
179
|
+
function getInterfaces(_a) {
|
|
180
|
+
var classImplements = _a.implements;
|
|
181
|
+
return (classImplements !== null && classImplements !== void 0 ? classImplements : [])
|
|
182
|
+
.map(function (_a) {
|
|
183
|
+
var expression = _a.expression;
|
|
184
|
+
return expression;
|
|
185
|
+
})
|
|
186
|
+
.filter(guards_1.isIdentifierOrMemberExpression);
|
|
187
|
+
}
|
|
188
|
+
exports.getInterfaces = getInterfaces;
|
|
189
|
+
function getInterface(node, interfaceName) {
|
|
190
|
+
return getInterfaces(node).find(function (interfaceMember) { return getInterfaceName(interfaceMember) === interfaceName; });
|
|
191
|
+
}
|
|
192
|
+
exports.getInterface = getInterface;
|
|
193
|
+
function getImplementsSchemaFixer(_a, interfaceName) {
|
|
194
|
+
var id = _a.id, classImplements = _a.implements;
|
|
195
|
+
var _b = __read(classImplements
|
|
196
|
+
? [getLast(classImplements), ", ".concat(interfaceName)]
|
|
197
|
+
: [id, " implements ".concat(interfaceName)], 2), implementsNodeReplace = _b[0], implementsTextReplace = _b[1];
|
|
198
|
+
return { implementsNodeReplace: implementsNodeReplace, implementsTextReplace: implementsTextReplace };
|
|
199
|
+
}
|
|
200
|
+
exports.getImplementsSchemaFixer = getImplementsSchemaFixer;
|
|
201
|
+
function getLast(items) {
|
|
202
|
+
return items.slice(-1)[0];
|
|
203
|
+
}
|
|
204
|
+
exports.getLast = getLast;
|
|
205
|
+
function getDecoratorArguments(_a) {
|
|
206
|
+
var expression = _a.expression;
|
|
207
|
+
return (0, guards_1.isCallExpression)(expression) ? expression.arguments : [];
|
|
208
|
+
}
|
|
209
|
+
exports.getDecoratorArguments = getDecoratorArguments;
|
|
210
|
+
function getDecoratorName(_a) {
|
|
211
|
+
var expression = _a.expression;
|
|
212
|
+
if ((0, guards_1.isIdentifier)(expression)) {
|
|
213
|
+
return expression.name;
|
|
214
|
+
}
|
|
215
|
+
return (0, guards_1.isCallExpression)(expression) && (0, guards_1.isIdentifier)(expression.callee)
|
|
216
|
+
? expression.callee.name
|
|
217
|
+
: undefined;
|
|
218
|
+
}
|
|
219
|
+
exports.getDecoratorName = getDecoratorName;
|
|
220
|
+
function getDecorator(_a, decoratorName) {
|
|
221
|
+
var decorators = _a.decorators;
|
|
222
|
+
return decorators === null || decorators === void 0 ? void 0 : decorators.find(function (decorator) { return getDecoratorName(decorator) === decoratorName; });
|
|
223
|
+
}
|
|
224
|
+
exports.getDecorator = getDecorator;
|
|
225
|
+
function getRawText(node) {
|
|
226
|
+
if ((0, guards_1.isIdentifier)(node)) {
|
|
227
|
+
return node.name;
|
|
228
|
+
}
|
|
229
|
+
if ((0, guards_1.isPropertyDefinition)(node) ||
|
|
230
|
+
(0, guards_1.isMethodDefinition)(node) ||
|
|
231
|
+
(0, guards_1.isProperty)(node)) {
|
|
232
|
+
return getRawText(node.key);
|
|
233
|
+
}
|
|
234
|
+
if ((0, guards_1.isLiteral)(node)) {
|
|
235
|
+
return node.raw;
|
|
236
|
+
}
|
|
237
|
+
if ((0, guards_1.isTemplateElement)(node)) {
|
|
238
|
+
return "`".concat(node.value.raw, "`");
|
|
239
|
+
}
|
|
240
|
+
if ((0, guards_1.isTemplateLiteral)(node)) {
|
|
241
|
+
return "`".concat(node.quasis[0].value.raw, "`");
|
|
242
|
+
}
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
exports.getRawText = getRawText;
|
|
246
|
+
function capitalize(text) {
|
|
247
|
+
return "".concat(text[0].toUpperCase()).concat(text.slice(1));
|
|
248
|
+
}
|
|
249
|
+
exports.capitalize = capitalize;
|
|
250
|
+
function getInjectedParametersWithSourceCode(context, moduleName, importName) {
|
|
251
|
+
var _a, _b, _c;
|
|
252
|
+
var sourceCode = context.getSourceCode();
|
|
253
|
+
var importDeclarations = (_a = getImportDeclarations(sourceCode.ast, moduleName)) !== null && _a !== void 0 ? _a : [];
|
|
254
|
+
var importSpecifier = ((_b = getImportDeclarationSpecifier(importDeclarations, importName)) !== null && _b !== void 0 ? _b : {}).importSpecifier;
|
|
255
|
+
if (!importSpecifier) {
|
|
256
|
+
return { sourceCode: sourceCode };
|
|
257
|
+
}
|
|
258
|
+
var variables = context.getDeclaredVariables(importSpecifier);
|
|
259
|
+
var typedVariable = variables.find(function (_a) {
|
|
260
|
+
var name = _a.name;
|
|
261
|
+
return name === importName;
|
|
262
|
+
});
|
|
263
|
+
var identifiers = (_c = typedVariable === null || typedVariable === void 0 ? void 0 : typedVariable.references) === null || _c === void 0 ? void 0 : _c.reduce(function (identifiers, _a) {
|
|
264
|
+
var parent = _a.identifier.parent;
|
|
265
|
+
if (parent &&
|
|
266
|
+
(0, guards_1.isTSTypeReference)(parent) &&
|
|
267
|
+
parent.parent &&
|
|
268
|
+
(0, guards_1.isTSTypeAnnotation)(parent.parent) &&
|
|
269
|
+
parent.parent.parent &&
|
|
270
|
+
(0, guards_1.isIdentifier)(parent.parent.parent)) {
|
|
271
|
+
return identifiers.concat(parent.parent.parent);
|
|
272
|
+
}
|
|
273
|
+
return identifiers;
|
|
274
|
+
}, []);
|
|
275
|
+
return { identifiers: identifiers, sourceCode: sourceCode };
|
|
276
|
+
}
|
|
277
|
+
function getNgRxEffectActions(context) {
|
|
278
|
+
return getInjectedParametersWithSourceCode(context, ngrx_modules_1.NGRX_MODULE_PATHS.effects, 'Actions');
|
|
279
|
+
}
|
|
280
|
+
exports.getNgRxEffectActions = getNgRxEffectActions;
|
|
281
|
+
function getNgRxComponentStores(context) {
|
|
282
|
+
return getInjectedParametersWithSourceCode(context, ngrx_modules_1.NGRX_MODULE_PATHS['component-store'], 'ComponentStore');
|
|
283
|
+
}
|
|
284
|
+
exports.getNgRxComponentStores = getNgRxComponentStores;
|
|
285
|
+
function getNgRxStores(context) {
|
|
286
|
+
return getInjectedParametersWithSourceCode(context, ngrx_modules_1.NGRX_MODULE_PATHS.store, 'Store');
|
|
287
|
+
}
|
|
288
|
+
exports.getNgRxStores = getNgRxStores;
|
|
289
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
|
|
290
|
+
function escapeText(text) {
|
|
291
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
292
|
+
}
|
|
293
|
+
exports.escapeText = escapeText;
|
|
294
|
+
function asPattern(identifiers) {
|
|
295
|
+
var escapedNames = identifiers.map(function (_a) {
|
|
296
|
+
var name = _a.name;
|
|
297
|
+
return escapeText(name);
|
|
298
|
+
});
|
|
299
|
+
return new RegExp("^(".concat(escapedNames.join('|'), ")$"));
|
|
300
|
+
}
|
|
301
|
+
exports.asPattern = asPattern;
|
|
302
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,4EAAiE;AACjE,mCAiBkB;AAClB,+CAAmD;AAmBnD,SAAgB,uBAAuB,CACrC,EAAyB,EACzB,SAAiD;QAD/C,MAAM,YAAA;IAGR,OAAO,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D,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,iBAAiB,CAAC,EACpC,gBAAgB,CACjB,CAAC;AACJ,CAAC;AARD,wDAQC;AAED,SAAgB,aAAa,CAC3B,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,KAAK,EACvB,OAAO,CACR,CAAC;AACJ,CAAC;AARD,sCAQC;AAED,6FAA6F;AAC7F,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAFD,gCAEC;AAED,SAAgB,SAAS,CAAC,WAAyC;IACjE,IAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,UAAC,EAAQ;YAAN,IAAI,UAAA;QAAO,OAAA,UAAU,CAAC,IAAI,CAAC;IAAhB,CAAgB,CAAC,CAAC;IACrE,OAAO,IAAI,MAAM,CAAC,YAAK,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,OAAI,CAAC,CAAC;AACrD,CAAC;AAHD,8BAGC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/experimental-utils';\nimport { ASTUtils } from '@typescript-eslint/experimental-utils';\nimport {\n isCallExpression,\n isIdentifier,\n isIdentifierOrMemberExpression,\n isImportDeclaration,\n isImportDefaultSpecifier,\n isImportNamespaceSpecifier,\n isImportSpecifier,\n isLiteral,\n isMethodDefinition,\n isProgram,\n isProperty,\n isPropertyDefinition,\n isTemplateElement,\n isTemplateLiteral,\n isTSTypeAnnotation,\n isTSTypeReference,\n} from './guards';\nimport { NGRX_MODULE_PATHS } from './ngrx-modules';\n\ntype ConstructorFunctionExpression = TSESTree.FunctionExpression & {\n parent: TSESTree.MethodDefinition & { kind: 'constructor' };\n};\ntype InjectedParameter =\n | TSESTree.Identifier & {\n typeAnnotation: TSESTree.TSTypeAnnotation;\n parent:\n | ConstructorFunctionExpression\n | (TSESTree.TSParameterProperty & {\n parent: ConstructorFunctionExpression;\n });\n };\ntype InjectedParameterWithSourceCode = Readonly<{\n identifiers?: readonly InjectedParameter[];\n sourceCode: Readonly<TSESLint.SourceCode>;\n}>;\n\nexport function getNearestUpperNodeFrom<T extends TSESTree.Node>(\n { parent }: TSESTree.Node,\n predicate: (parent: TSESTree.Node) => parent is T\n): T | undefined {\n while (parent && !isProgram(parent)) {\n if (predicate(parent)) {\n return parent;\n }\n\n parent = parent.parent;\n }\n\n return undefined;\n}\n\nexport function getImportDeclarationSpecifier(\n importDeclarations: readonly TSESTree.ImportDeclaration[],\n importName: string\n) {\n for (const importDeclaration of importDeclarations) {\n const importSpecifier = importDeclaration.specifiers.find(\n (importClause): importClause is TSESTree.ImportSpecifier => {\n return (\n isImportSpecifier(importClause) &&\n importClause.imported.name === importName\n );\n }\n );\n\n if (importSpecifier) {\n return { importDeclaration, importSpecifier } as const;\n }\n }\n\n return undefined;\n}\n\nexport function getImportDeclarations(\n node: TSESTree.Node,\n moduleName: string\n): readonly TSESTree.ImportDeclaration[] | undefined {\n let parentNode: TSESTree.Node | undefined = node;\n\n while (parentNode && !isProgram(parentNode)) {\n parentNode = parentNode.parent;\n }\n\n return parentNode?.body.filter((node): node is TSESTree.ImportDeclaration => {\n return isImportDeclaration(node) && node.source.value === moduleName;\n });\n}\n\nfunction getCorrespondentImportClause(\n importDeclarations: readonly TSESTree.ImportDeclaration[],\n compatibleWithTypeOnlyImport = false\n) {\n let importClause: TSESTree.ImportClause | undefined;\n\n for (const { importKind, specifiers } of importDeclarations) {\n const lastImportSpecifier = getLast(specifiers);\n\n if (\n (!compatibleWithTypeOnlyImport && importKind === 'type') ||\n isImportNamespaceSpecifier(lastImportSpecifier)\n ) {\n continue;\n }\n\n importClause = lastImportSpecifier;\n }\n\n return importClause;\n}\n\nexport function getImportAddFix({\n compatibleWithTypeOnlyImport = false,\n fixer,\n importName,\n moduleName,\n node,\n}: {\n compatibleWithTypeOnlyImport?: boolean;\n fixer: TSESLint.RuleFixer;\n importName: string;\n moduleName: string;\n node: TSESTree.Node;\n}): TSESLint.RuleFix | TSESLint.RuleFix[] {\n const fullImport = `import { ${importName} } from '${moduleName}';\\n`;\n const importDeclarations = getImportDeclarations(node, moduleName);\n\n if (!importDeclarations?.length) {\n return fixer.insertTextAfterRange([0, 0], fullImport);\n }\n\n const importDeclarationSpecifier = getImportDeclarationSpecifier(\n importDeclarations,\n importName\n );\n\n if (importDeclarationSpecifier) {\n return [];\n }\n\n const importClause = getCorrespondentImportClause(\n importDeclarations,\n compatibleWithTypeOnlyImport\n );\n\n if (!importClause) {\n return fixer.insertTextAfterRange([0, 0], fullImport);\n }\n\n const replacementText = isImportDefaultSpecifier(importClause)\n ? `, { ${importName} }`\n : `, ${importName}`;\n return fixer.insertTextAfter(importClause, replacementText);\n}\n\nexport function getImportRemoveFix(\n sourceCode: Readonly<TSESLint.SourceCode>,\n importDeclarations: readonly TSESTree.ImportDeclaration[],\n importedName: string,\n fixer: TSESLint.RuleFixer\n): TSESLint.RuleFix | TSESLint.RuleFix[] {\n const { importDeclaration, importSpecifier } =\n getImportDeclarationSpecifier(importDeclarations, importedName) ?? {};\n\n if (!importDeclaration || !importSpecifier) {\n return [];\n }\n\n const isFirstImportSpecifier =\n importDeclaration.specifiers[0] === importSpecifier;\n const isLastImportSpecifier =\n getLast(importDeclaration.specifiers) === importSpecifier;\n const isSingleImportSpecifier =\n isFirstImportSpecifier && isLastImportSpecifier;\n\n if (isSingleImportSpecifier) {\n return fixer.remove(importDeclaration);\n }\n\n const tokenAfterImportSpecifier = sourceCode.getTokenAfter(importSpecifier);\n\n if (isFirstImportSpecifier && tokenAfterImportSpecifier) {\n return fixer.removeRange([\n importSpecifier.range[0],\n tokenAfterImportSpecifier.range[1],\n ]);\n }\n\n const tokenBeforeImportSpecifier = sourceCode.getTokenBefore(importSpecifier);\n\n if (!tokenBeforeImportSpecifier) {\n return [];\n }\n\n return fixer.removeRange([\n tokenBeforeImportSpecifier.range[0],\n importSpecifier.range[1],\n ]);\n}\n\nexport function getNodeToCommaRemoveFix(\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer,\n node: TSESTree.Node\n) {\n const nextToken = sourceCode.getTokenAfter(node);\n const isNextTokenComma = nextToken && ASTUtils.isCommaToken(nextToken);\n return [\n fixer.remove(node),\n ...(isNextTokenComma ? [fixer.remove(nextToken)] : []),\n ] as const;\n}\n\nexport function getInterfaceName(\n interfaceMember: TSESTree.Identifier | TSESTree.MemberExpression\n): string | undefined {\n if (isIdentifier(interfaceMember)) {\n return interfaceMember.name;\n }\n\n return isIdentifier(interfaceMember.property)\n ? interfaceMember.property.name\n : undefined;\n}\n\nexport function getInterfaces({\n implements: classImplements,\n}: TSESTree.ClassDeclaration): readonly (\n | TSESTree.Identifier\n | TSESTree.MemberExpression\n)[] {\n return (classImplements ?? [])\n .map(({ expression }) => expression)\n .filter(isIdentifierOrMemberExpression);\n}\n\nexport function getInterface(\n node: TSESTree.ClassDeclaration,\n interfaceName: string\n): TSESTree.Identifier | TSESTree.MemberExpression | undefined {\n return getInterfaces(node).find(\n (interfaceMember) => getInterfaceName(interfaceMember) === interfaceName\n );\n}\n\nexport function getImplementsSchemaFixer(\n { id, implements: classImplements }: TSESTree.ClassDeclaration,\n interfaceName: string\n) {\n const [implementsNodeReplace, implementsTextReplace] = classImplements\n ? [getLast(classImplements), `, ${interfaceName}`]\n : [id as TSESTree.Identifier, ` implements ${interfaceName}`];\n\n return { implementsNodeReplace, implementsTextReplace } as const;\n}\n\nexport function getLast<T extends readonly unknown[]>(items: T): T[number] {\n return items.slice(-1)[0];\n}\n\nexport function getDecoratorArguments({ expression }: TSESTree.Decorator) {\n return isCallExpression(expression) ? expression.arguments : [];\n}\n\nexport function getDecoratorName({\n expression,\n}: TSESTree.Decorator): string | undefined {\n if (isIdentifier(expression)) {\n return expression.name;\n }\n\n return isCallExpression(expression) && isIdentifier(expression.callee)\n ? expression.callee.name\n : undefined;\n}\n\nexport function getDecorator(\n {\n decorators,\n }:\n | TSESTree.PropertyDefinition\n | TSESTree.ClassDeclaration\n | TSESTree.MethodDefinition,\n decoratorName: string\n): TSESTree.Decorator | undefined {\n return decorators?.find(\n (decorator) => getDecoratorName(decorator) === decoratorName\n );\n}\n\nexport function getRawText(node: TSESTree.Node): string | null {\n if (isIdentifier(node)) {\n return node.name;\n }\n\n if (\n isPropertyDefinition(node) ||\n isMethodDefinition(node) ||\n isProperty(node)\n ) {\n return getRawText(node.key);\n }\n\n if (isLiteral(node)) {\n return node.raw;\n }\n\n if (isTemplateElement(node)) {\n return `\\`${node.value.raw}\\``;\n }\n\n if (isTemplateLiteral(node)) {\n return `\\`${node.quasis[0].value.raw}\\``;\n }\n\n return null;\n}\n\nexport function capitalize<T extends string>(text: T): Capitalize<T> {\n return `${text[0].toUpperCase()}${text.slice(1)}` as Capitalize<T>;\n}\n\nfunction getInjectedParametersWithSourceCode(\n context: TSESLint.RuleContext<string, readonly unknown[]>,\n moduleName: string,\n importName: string\n): InjectedParameterWithSourceCode {\n const sourceCode = context.getSourceCode();\n const importDeclarations =\n getImportDeclarations(sourceCode.ast, moduleName) ?? [];\n const { importSpecifier } =\n getImportDeclarationSpecifier(importDeclarations, importName) ?? {};\n\n if (!importSpecifier) {\n return { sourceCode };\n }\n\n const variables = context.getDeclaredVariables(importSpecifier);\n const typedVariable = variables.find(({ name }) => name === importName);\n const identifiers = typedVariable?.references?.reduce<\n readonly InjectedParameter[]\n >((identifiers, { identifier: { parent } }) => {\n if (\n parent &&\n isTSTypeReference(parent) &&\n parent.parent &&\n isTSTypeAnnotation(parent.parent) &&\n parent.parent.parent &&\n isIdentifier(parent.parent.parent)\n ) {\n return identifiers.concat(parent.parent.parent as InjectedParameter);\n }\n\n return identifiers;\n }, []);\n return { identifiers, sourceCode };\n}\n\nexport function getNgRxEffectActions(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): InjectedParameterWithSourceCode {\n return getInjectedParametersWithSourceCode(\n context,\n NGRX_MODULE_PATHS.effects,\n 'Actions'\n );\n}\n\nexport function getNgRxComponentStores(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): InjectedParameterWithSourceCode {\n return getInjectedParametersWithSourceCode(\n context,\n NGRX_MODULE_PATHS['component-store'],\n 'ComponentStore'\n );\n}\n\nexport function getNgRxStores(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): InjectedParameterWithSourceCode {\n return getInjectedParametersWithSourceCode(\n context,\n NGRX_MODULE_PATHS.store,\n 'Store'\n );\n}\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping\nexport function escapeText(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\nexport function asPattern(identifiers: readonly InjectedParameter[]): RegExp {\n const escapedNames = identifiers.map(({ name }) => escapeText(name));\n return new RegExp(`^(${escapedNames.join('|')})$`);\n}\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
exports.__esModule = true;
|
|
26
|
+
exports.ngrxVersionSatisfies = exports.clearCache = exports.setNgrxVersion = void 0;
|
|
27
|
+
var semver = __importStar(require("semver"));
|
|
28
|
+
var noopVersion = '0.0.0';
|
|
29
|
+
var versionsCache = new Map();
|
|
30
|
+
var satisfiesCache = new Map();
|
|
31
|
+
function getNgrxVersion(pkg) {
|
|
32
|
+
if (!versionsCache.has(pkg)) {
|
|
33
|
+
var version = readPlatformVersion(pkg);
|
|
34
|
+
versionsCache.set(pkg, version !== null && version !== void 0 ? version : noopVersion);
|
|
35
|
+
}
|
|
36
|
+
return versionsCache.get(pkg);
|
|
37
|
+
}
|
|
38
|
+
function readPlatformVersion(pkg) {
|
|
39
|
+
var _a;
|
|
40
|
+
try {
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
42
|
+
var ngrxVersion = require("".concat(pkg, "/package.json"));
|
|
43
|
+
return (_a = ngrxVersion.version) === null || _a === void 0 ? void 0 : _a.replace(/[^\d.]/g, '');
|
|
44
|
+
}
|
|
45
|
+
catch (_b) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// @internal for testing purposes
|
|
50
|
+
function setNgrxVersion(pkg, version) {
|
|
51
|
+
versionsCache.set(pkg, version);
|
|
52
|
+
}
|
|
53
|
+
exports.setNgrxVersion = setNgrxVersion;
|
|
54
|
+
// @internal for testing purposes
|
|
55
|
+
function clearCache() {
|
|
56
|
+
versionsCache.clear();
|
|
57
|
+
satisfiesCache.clear();
|
|
58
|
+
}
|
|
59
|
+
exports.clearCache = clearCache;
|
|
60
|
+
function versionSatisfies(pkg, version) {
|
|
61
|
+
if (!satisfiesCache.has(pkg)) {
|
|
62
|
+
satisfiesCache.set(pkg, semver.satisfies(getNgrxVersion(pkg), version));
|
|
63
|
+
}
|
|
64
|
+
return satisfiesCache.get(pkg);
|
|
65
|
+
}
|
|
66
|
+
function ngrxVersionSatisfies(pkg, version) {
|
|
67
|
+
return versionSatisfies(pkg, version);
|
|
68
|
+
}
|
|
69
|
+
exports.ngrxVersionSatisfies = ngrxVersionSatisfies;
|
|
70
|
+
//# sourceMappingURL=versions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versions.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/versions.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAiC;AAEjC,IAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,IAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;AAChD,IAAM,cAAc,GAAG,IAAI,GAAG,EAAmB,CAAC;AAElD,SAAS,cAAc,CAAC,GAAW;IACjC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAC3B,IAAM,OAAO,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACzC,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,WAAW,CAAC,CAAC;KAChD;IAED,OAAO,aAAa,CAAC,GAAG,CAAC,GAAG,CAAW,CAAC;AAC1C,CAAC;AAED,SAAS,mBAAmB,CAAC,GAAW;;IACtC,IAAI;QACF,8DAA8D;QAC9D,IAAM,WAAW,GAAG,OAAO,CAAC,UAAG,GAAG,kBAAe,CAEhD,CAAC;QACF,OAAO,MAAA,WAAW,CAAC,OAAO,0CAAE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;KACpD;IAAC,WAAM;QACN,OAAO,IAAI,CAAC;KACb;AACH,CAAC;AAED,iCAAiC;AACjC,SAAgB,cAAc,CAAC,GAAW,EAAE,OAAe;IACzD,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAClC,CAAC;AAFD,wCAEC;AAED,iCAAiC;AACjC,SAAgB,UAAU;IACxB,aAAa,CAAC,KAAK,EAAE,CAAC;IACtB,cAAc,CAAC,KAAK,EAAE,CAAC;AACzB,CAAC;AAHD,gCAGC;AAED,SAAS,gBAAgB,CAAC,GAAW,EAAE,OAAe;IACpD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;QAC5B,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;KACzE;IAED,OAAO,cAAc,CAAC,GAAG,CAAC,GAAG,CAAY,CAAC;AAC5C,CAAC;AAED,SAAgB,oBAAoB,CAAC,GAAW,EAAE,OAAe;IAC/D,OAAO,gBAAgB,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAFD,oDAEC","sourcesContent":["import * as semver from 'semver';\n\nconst noopVersion = '0.0.0';\nconst versionsCache = new Map<string, string>();\nconst satisfiesCache = new Map<string, boolean>();\n\nfunction getNgrxVersion(pkg: string): string {\n if (!versionsCache.has(pkg)) {\n const version = readPlatformVersion(pkg);\n versionsCache.set(pkg, version ?? noopVersion);\n }\n\n return versionsCache.get(pkg) as string;\n}\n\nfunction readPlatformVersion(pkg: string) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const ngrxVersion = require(`${pkg}/package.json`) as {\n version?: string;\n };\n return ngrxVersion.version?.replace(/[^\\d.]/g, '');\n } catch {\n return null;\n }\n}\n\n// @internal for testing purposes\nexport function setNgrxVersion(pkg: string, version: string): void {\n versionsCache.set(pkg, version);\n}\n\n// @internal for testing purposes\nexport function clearCache() {\n versionsCache.clear();\n satisfiesCache.clear();\n}\n\nfunction versionSatisfies(pkg: string, version: string) {\n if (!satisfiesCache.has(pkg)) {\n satisfiesCache.set(pkg, semver.satisfies(getNgrxVersion(pkg), version));\n }\n\n return satisfiesCache.get(pkg) as boolean;\n}\n\nexport function ngrxVersionSatisfies(pkg: string, version: string): boolean {\n return versionSatisfies(pkg, version);\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
exports.__esModule = true;
|
|
17
|
+
__exportStar(require("./helper-functions"), exports);
|
|
18
|
+
__exportStar(require("./selectors"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../modules/eslint-plugin/src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,8CAA4B","sourcesContent":["export * from './helper-functions';\nexport * from './selectors';\n"]}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.mapLikeOperatorsImplicitReturn = exports.mapLikeOperatorsExplicitReturn = exports.actionReducerMap = exports.storeActionReducerMap = exports.onFunctionWithoutType = exports.createReducer = exports.dispatchInEffects = exports.dispatchExpression = exports.selectExpression = exports.pipeableSelect = exports.pipeExpression = exports.namedCallableExpression = exports.namedExpression = exports.effectsInNgModuleProviders = exports.effectsInNgModuleImports = exports.ngModuleProviders = exports.ngModuleImports = exports.ngModuleDecorator = exports.metadataProperty = exports.constructorDefinition = exports.actionCreatorPropsComputed = exports.actionCreatorProps = exports.actionCreatorWithLiteral = exports.actionCreator = exports.propertyDefinitionWithEffectDecorator = exports.effectDecorator = exports.createEffectExpression = exports.effectCreator = void 0;
|
|
4
|
+
exports.effectCreator = "PropertyDefinition[value.callee.name='createEffect']";
|
|
5
|
+
exports.createEffectExpression = "CallExpression[callee.name='createEffect']";
|
|
6
|
+
exports.effectDecorator = "Decorator[expression.callee.name='Effect']";
|
|
7
|
+
exports.propertyDefinitionWithEffectDecorator = "ClassDeclaration > ClassBody > PropertyDefinition > ".concat(exports.effectDecorator);
|
|
8
|
+
exports.actionCreator = "CallExpression[callee.name='createAction']";
|
|
9
|
+
exports.actionCreatorWithLiteral = "".concat(exports.actionCreator, "[arguments.0.type='Literal'][arguments.0.raw=/^'/]");
|
|
10
|
+
exports.actionCreatorProps = "".concat(exports.actionCreator, " > CallExpression[callee.name='props']");
|
|
11
|
+
exports.actionCreatorPropsComputed = "".concat(exports.actionCreatorProps, " > TSTypeParameterInstantiation > :matches(TSTypeReference[typeName.name!='Readonly'], [type=/^TS(.*)(Keyword|Type)$/])");
|
|
12
|
+
exports.constructorDefinition = "MethodDefinition[kind='constructor']";
|
|
13
|
+
function metadataProperty(key) {
|
|
14
|
+
return "Property:matches([key.name=".concat(key, "][computed=false], [key.value=").concat(key, "], [key.quasis.0.value.raw=").concat(key, "])");
|
|
15
|
+
}
|
|
16
|
+
exports.metadataProperty = metadataProperty;
|
|
17
|
+
exports.ngModuleDecorator = "ClassDeclaration > Decorator > CallExpression[callee.name='NgModule']";
|
|
18
|
+
exports.ngModuleImports = "".concat(exports.ngModuleDecorator, " ObjectExpression ").concat(metadataProperty('imports'), " > ArrayExpression");
|
|
19
|
+
exports.ngModuleProviders = "".concat(exports.ngModuleDecorator, " ObjectExpression ").concat(metadataProperty('providers'), " > ArrayExpression");
|
|
20
|
+
exports.effectsInNgModuleImports = "".concat(exports.ngModuleImports, " CallExpression[callee.object.name='EffectsModule'][callee.property.name=/^for(Root|Feature)$/] ArrayExpression > Identifier");
|
|
21
|
+
exports.effectsInNgModuleProviders = "".concat(exports.ngModuleProviders, " Identifier");
|
|
22
|
+
var namedExpression = function (name) {
|
|
23
|
+
return ":matches(".concat(exports.constructorDefinition, " CallExpression[callee.object.name=").concat(name, "], CallExpression[callee.object.object.type='ThisExpression'][callee.object.property.name=").concat(name, "])");
|
|
24
|
+
};
|
|
25
|
+
exports.namedExpression = namedExpression;
|
|
26
|
+
var namedCallableExpression = function (name) {
|
|
27
|
+
return ":matches(".concat((0, exports.namedExpression)(name), ", ").concat(exports.constructorDefinition, " CallExpression[callee.object.callee.object.name=").concat(name, "], CallExpression[callee.object.callee.object.object.type='ThisExpression'][callee.object.callee.object.property.name=").concat(name, "])");
|
|
28
|
+
};
|
|
29
|
+
exports.namedCallableExpression = namedCallableExpression;
|
|
30
|
+
var pipeExpression = function (name) {
|
|
31
|
+
return "".concat((0, exports.namedExpression)(name), "[callee.property.name='pipe']");
|
|
32
|
+
};
|
|
33
|
+
exports.pipeExpression = pipeExpression;
|
|
34
|
+
var pipeableSelect = function (name) {
|
|
35
|
+
return "".concat((0, exports.pipeExpression)(name), " CallExpression[callee.name='select']");
|
|
36
|
+
};
|
|
37
|
+
exports.pipeableSelect = pipeableSelect;
|
|
38
|
+
var selectExpression = function (name) {
|
|
39
|
+
return "".concat((0, exports.namedExpression)(name), "[callee.property.name='select']");
|
|
40
|
+
};
|
|
41
|
+
exports.selectExpression = selectExpression;
|
|
42
|
+
var dispatchExpression = function (name) {
|
|
43
|
+
return "".concat((0, exports.namedExpression)(name), "[callee.property.name='dispatch']");
|
|
44
|
+
};
|
|
45
|
+
exports.dispatchExpression = dispatchExpression;
|
|
46
|
+
var dispatchInEffects = function (name) {
|
|
47
|
+
return "".concat(exports.createEffectExpression, " ").concat((0, exports.dispatchExpression)(name), " > MemberExpression:has(Identifier[name=").concat(name, "])");
|
|
48
|
+
};
|
|
49
|
+
exports.dispatchInEffects = dispatchInEffects;
|
|
50
|
+
exports.createReducer = "CallExpression[callee.name='createReducer']";
|
|
51
|
+
exports.onFunctionWithoutType = "".concat(exports.createReducer, " CallExpression[callee.name='on'] > ArrowFunctionExpression:not([returnType.typeAnnotation], :has(CallExpression))");
|
|
52
|
+
exports.storeActionReducerMap = "".concat(exports.ngModuleImports, " CallExpression[callee.object.name='StoreModule'][callee.property.name=/^for(Root|Feature)$/] > ObjectExpression:first-child");
|
|
53
|
+
exports.actionReducerMap = "VariableDeclarator[id.typeAnnotation.typeAnnotation.typeName.name='ActionReducerMap'] > ObjectExpression";
|
|
54
|
+
var mapLikeOperators = '/^(concat|exhaust|flat|merge|switch)Map$/';
|
|
55
|
+
var mapLikeToOperators = '/^(concat|merge|switch)MapTo$/';
|
|
56
|
+
exports.mapLikeOperatorsExplicitReturn = "CallExpression[callee.name=".concat(mapLikeOperators, "] ReturnStatement");
|
|
57
|
+
exports.mapLikeOperatorsImplicitReturn = ":matches(CallExpression[callee.name=".concat(mapLikeToOperators, "], CallExpression[callee.name=").concat(mapLikeOperators, "] > ArrowFunctionExpression)");
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/selectors/index.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,sDAAsD,CAAC;AACvE,QAAA,sBAAsB,GAAG,4CAA4C,CAAC;AAEtE,QAAA,eAAe,GAAG,4CAA4C,CAAC;AAC/D,QAAA,qCAAqC,GAChD,8DAAuD,uBAAe,CAAW,CAAC;AAEvE,QAAA,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G,IAAA,sBAAc,EAAC,IAAI,CAAC,0CAAgD;AAAvE,CAAuE,CAAC;AAD7D,QAAA,cAAc,kBAC+C;AAEnE,IAAM,gBAAgB,GAAG,UAAC,IAAqB;IACpD,OAAA,UAAG,IAAA,uBAAe,EAAC,IAAI,CAAC,oCAA0C;AAAlE,CAAkE,CAAC;AADxD,QAAA,gBAAgB,oBACwC;AAE9D,IAAM,kBAAkB,GAAG,UAAC,IAAqB;IACtD,OAAA,UAAG,IAAA,uBAAe,EAAC,IAAI,CAAC,sCAA4C;AAApE,CAAoE,CAAC;AAD1D,QAAA,kBAAkB,sBACwC;AAEhE,IAAM,iBAAiB,GAAG,UAAC,IAAqB;IACrD,OAAA,UAAG,8BAAsB,cAAI,IAAA,0BAAkB,EAC7C,IAAI,CACL,qDAA2C,IAAI,OAAa;AAF7D,CAE6D,CAAC;AAHnD,QAAA,iBAAiB,qBAGkC;AAEnD,QAAA,aAAa,GAAG,6CAA6C,CAAC;AAE9D,QAAA,qBAAqB,GAChC,UAAG,qBAAa,uHAA6H,CAAC;AAEnI,QAAA,qBAAqB,GAChC,UAAG,uBAAe,iIAAuI,CAAC;AAE/I,QAAA,gBAAgB,GAAG,0GAA0G,CAAC;AAE3I,IAAM,gBAAgB,GAAG,2CAA2C,CAAC;AACrE,IAAM,kBAAkB,GAAG,gCAAgC,CAAC;AAC/C,QAAA,8BAA8B,GACzC,qCAA8B,gBAAgB,sBAA4B,CAAC;AAChE,QAAA,8BAA8B,GACzC,8CAAuC,kBAAkB,2CAAiC,gBAAgB,iCAAuC,CAAC","sourcesContent":["export const effectCreator = `PropertyDefinition[value.callee.name='createEffect']`;\nexport const createEffectExpression = `CallExpression[callee.name='createEffect']`;\n\nexport const effectDecorator = `Decorator[expression.callee.name='Effect']`;\nexport const propertyDefinitionWithEffectDecorator =\n `ClassDeclaration > ClassBody > PropertyDefinition > ${effectDecorator}` as const;\n\nexport const actionCreator = `CallExpression[callee.name='createAction']`;\nexport const actionCreatorWithLiteral =\n `${actionCreator}[arguments.0.type='Literal'][arguments.0.raw=/^'/]` as const;\nexport const actionCreatorProps =\n `${actionCreator} > CallExpression[callee.name='props']` as const;\nexport const actionCreatorPropsComputed =\n `${actionCreatorProps} > TSTypeParameterInstantiation > :matches(TSTypeReference[typeName.name!='Readonly'], [type=/^TS(.*)(Keyword|Type)$/])` as const;\n\nexport const constructorDefinition = `MethodDefinition[kind='constructor']`;\n\nexport function metadataProperty(key: RegExp): string;\nexport function metadataProperty<TKey extends string>(\n key: TKey\n): `Property:matches([key.name=${TKey}][computed=false], [key.value=${TKey}], [key.quasis.0.value.raw=${TKey}])`;\nexport function metadataProperty(key: RegExp | string): string {\n return `Property:matches([key.name=${key}][computed=false], [key.value=${key}], [key.quasis.0.value.raw=${key}])`;\n}\n\nexport const ngModuleDecorator = `ClassDeclaration > Decorator > CallExpression[callee.name='NgModule']`;\n\nexport const ngModuleImports =\n `${ngModuleDecorator} ObjectExpression ${metadataProperty(\n 'imports'\n )} > ArrayExpression` as const;\n\nexport const ngModuleProviders =\n `${ngModuleDecorator} ObjectExpression ${metadataProperty(\n 'providers'\n )} > ArrayExpression` as const;\n\nexport const effectsInNgModuleImports =\n `${ngModuleImports} CallExpression[callee.object.name='EffectsModule'][callee.property.name=/^for(Root|Feature)$/] ArrayExpression > Identifier` as const;\n\nexport const effectsInNgModuleProviders =\n `${ngModuleProviders} Identifier` as const;\n\nexport const namedExpression = (name: RegExp | string) =>\n `:matches(${constructorDefinition} CallExpression[callee.object.name=${name}], CallExpression[callee.object.object.type='ThisExpression'][callee.object.property.name=${name}])` as const;\n\nexport const namedCallableExpression = (name: RegExp | string) =>\n `:matches(${namedExpression(\n name\n )}, ${constructorDefinition} CallExpression[callee.object.callee.object.name=${name}], CallExpression[callee.object.callee.object.object.type='ThisExpression'][callee.object.callee.object.property.name=${name}])` as const;\n\nexport const pipeExpression = (name: RegExp | string) =>\n `${namedExpression(name)}[callee.property.name='pipe']` as const;\n\nexport const pipeableSelect = (name: RegExp | string) =>\n `${pipeExpression(name)} CallExpression[callee.name='select']` as const;\n\nexport const selectExpression = (name: RegExp | string) =>\n `${namedExpression(name)}[callee.property.name='select']` as const;\n\nexport const dispatchExpression = (name: RegExp | string) =>\n `${namedExpression(name)}[callee.property.name='dispatch']` as const;\n\nexport const dispatchInEffects = (name: RegExp | string) =>\n `${createEffectExpression} ${dispatchExpression(\n name\n )} > MemberExpression:has(Identifier[name=${name}])` as const;\n\nexport const createReducer = `CallExpression[callee.name='createReducer']`;\n\nexport const onFunctionWithoutType =\n `${createReducer} CallExpression[callee.name='on'] > ArrowFunctionExpression:not([returnType.typeAnnotation], :has(CallExpression))` as const;\n\nexport const storeActionReducerMap =\n `${ngModuleImports} CallExpression[callee.object.name='StoreModule'][callee.property.name=/^for(Root|Feature)$/] > ObjectExpression:first-child` as const;\n\nexport const actionReducerMap = `VariableDeclarator[id.typeAnnotation.typeAnnotation.typeName.name='ActionReducerMap'] > ObjectExpression`;\n\nconst mapLikeOperators = '/^(concat|exhaust|flat|merge|switch)Map$/';\nconst mapLikeToOperators = '/^(concat|merge|switch)MapTo$/';\nexport const mapLikeOperatorsExplicitReturn =\n `CallExpression[callee.name=${mapLikeOperators}] ReturnStatement` as const;\nexport const mapLikeOperatorsImplicitReturn =\n `:matches(CallExpression[callee.name=${mapLikeToOperators}], CallExpression[callee.name=${mapLikeOperators}] > ArrowFunctionExpression)` as const;\n"]}
|