@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 @@
|
|
|
1
|
+
{"version":3,"file":"prefix-selectors-with-select.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefix-selectors-with-select.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAAyC;AAE5B,QAAA,yBAAyB,GAAG,2BAA2B,CAAC;AACxD,QAAA,gCAAgC,GAC3C,kCAAkC,CAAC;AAOrC,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,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,qEAAqE;YACvE,WAAW,EAAE,MAAM;YACnB,UAAU,EAAE,IAAI;SACjB;QACD,MAAM,EAAE,EAAE;QACV,QAAQ;YACN,GAAC,iCAAyB,IAAG,0CAA0C;YACvE,GAAC,wCAAgC,IAC/B,kDAAkD;eACrD;KACF;IACD,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,UAAC,OAAO;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AAoB,CAAC;KAC7B;IAED,kCAAkC;IAClC,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,UAAC,CAAC,EAAE,IAAY;QACpE,OAAO,UAAG,UAAU,SAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAE,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,IAAI,IAAI,KAAK,oBAAoB,EAAE;QACjC,OAAO,oBAAoB,CAAC;KAC7B;IAED,6BAA6B;IAC7B,OAAO,UAAG,UAAU,SAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,CAAE,CAAC;AAC5C,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { capitalize } from '../../utils';\n\nexport const prefixSelectorsWithSelect = 'prefixSelectorsWithSelect';\nexport const prefixSelectorsWithSelectSuggest =\n 'prefixSelectorsWithSelectSuggest';\n\ntype MessageIds =\n | typeof prefixSelectorsWithSelect\n | typeof prefixSelectorsWithSelectSuggest;\ntype Options = readonly [];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description:\n 'The selector should start with \"select\", for example \"selectThing\".',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [],\n messages: {\n [prefixSelectorsWithSelect]: 'The selector should start with \"select\".',\n [prefixSelectorsWithSelectSuggest]:\n 'Prefix the selector with \"select\": `{{ name }}`.',\n },\n },\n defaultOptions: [],\n create: (context) => {\n return {\n 'VariableDeclarator[id.name!=/^select[^a-z].+$/]:matches([id.typeAnnotation.typeAnnotation.typeName.name=/^MemoizedSelector(WithProps)?$/], :has(CallExpression[callee.name=/^(create(Feature)?Selector|createSelectorFactory)$/]))'({\n id,\n }: TSESTree.VariableDeclarator & { id: TSESTree.Identifier }) {\n const suggestedName = getSuggestedName(id.name);\n context.report({\n loc: {\n ...id.loc,\n end: {\n ...id.loc.end,\n column: (id.typeAnnotation?.range[0] ?? id.range[1]) - 1,\n },\n },\n messageId: prefixSelectorsWithSelect,\n suggest: [\n {\n messageId: prefixSelectorsWithSelectSuggest,\n data: {\n name: suggestedName,\n },\n fix: (fixer) =>\n fixer.replaceTextRange(\n [id.range[0], id.typeAnnotation?.range[0] ?? id.range[1]],\n suggestedName\n ),\n },\n ],\n });\n },\n };\n },\n});\n\nfunction getSuggestedName(name: string) {\n const selectWord = 'select';\n // Ex: 'selectfeature' => 'selectFeature'\n let possibleReplacedName = name.replace(\n new RegExp(`^${selectWord}(.+)`),\n (_, word: string) => {\n return `${selectWord}${capitalize(word)}`;\n }\n );\n\n if (name !== possibleReplacedName) {\n return possibleReplacedName;\n }\n\n // Ex: 'getCount' => 'selectCount'\n possibleReplacedName = name.replace(/^get([^a-z].+)/, (_, word: string) => {\n return `${selectWord}${capitalize(word)}`;\n });\n\n if (name !== possibleReplacedName) {\n return possibleReplacedName;\n }\n\n // Ex: 'item' => 'selectItem'\n return `${selectWord}${capitalize(name)}`;\n}\n"]}
|
|
@@ -0,0 +1,196 @@
|
|
|
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 __values = (this && this.__values) || function(o) {
|
|
42
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
43
|
+
if (m) return m.call(o);
|
|
44
|
+
if (o && typeof o.length === "number") return {
|
|
45
|
+
next: function () {
|
|
46
|
+
if (o && i >= o.length) o = void 0;
|
|
47
|
+
return { value: o && o[i++], done: !o };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
51
|
+
};
|
|
52
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
53
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
54
|
+
if (ar || !(i in from)) {
|
|
55
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
56
|
+
ar[i] = from[i];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
60
|
+
};
|
|
61
|
+
var _a;
|
|
62
|
+
exports.__esModule = true;
|
|
63
|
+
exports.selectOperator = exports.selectMethod = void 0;
|
|
64
|
+
var path = __importStar(require("path"));
|
|
65
|
+
var rule_creator_1 = require("../../rule-creator");
|
|
66
|
+
var utils_1 = require("../../utils");
|
|
67
|
+
exports.selectMethod = 'selectMethod';
|
|
68
|
+
exports.selectOperator = 'selectOperator';
|
|
69
|
+
exports["default"] = (0, rule_creator_1.createRule)({
|
|
70
|
+
name: path.parse(__filename).name,
|
|
71
|
+
meta: {
|
|
72
|
+
type: 'suggestion',
|
|
73
|
+
ngrxModule: 'store',
|
|
74
|
+
docs: {
|
|
75
|
+
description: 'Selector can be used either with `select` as a pipeable operator or as a method.',
|
|
76
|
+
recommended: 'warn'
|
|
77
|
+
},
|
|
78
|
+
fixable: 'code',
|
|
79
|
+
schema: [
|
|
80
|
+
{
|
|
81
|
+
type: 'string',
|
|
82
|
+
"enum": ["method" /* Method */, "operator" /* Operator */],
|
|
83
|
+
additionalProperties: false
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
messages: (_a = {},
|
|
87
|
+
_a["method" /* Method */] = 'Selector should be used with select method: `this.store.select(selector)`.',
|
|
88
|
+
_a["operator" /* Operator */] = 'Selector should be used with the pipeable operator: `this.store.pipe(select(selector))`.',
|
|
89
|
+
_a)
|
|
90
|
+
},
|
|
91
|
+
defaultOptions: ["method" /* Method */],
|
|
92
|
+
create: function (context, _a) {
|
|
93
|
+
var _b, _c;
|
|
94
|
+
var _d = __read(_a, 1), mode = _d[0];
|
|
95
|
+
var _e = (0, utils_1.getNgRxStores)(context), _f = _e.identifiers, identifiers = _f === void 0 ? [] : _f, sourceCode = _e.sourceCode;
|
|
96
|
+
var storeNames = identifiers.length > 0 ? (0, utils_1.asPattern)(identifiers) : null;
|
|
97
|
+
if (!storeNames) {
|
|
98
|
+
return {};
|
|
99
|
+
}
|
|
100
|
+
if (mode === "operator" /* Operator */) {
|
|
101
|
+
return _b = {},
|
|
102
|
+
_b[(0, utils_1.selectExpression)(storeNames)] = function (node) {
|
|
103
|
+
context.report({
|
|
104
|
+
node: node.callee.property,
|
|
105
|
+
messageId: "operator" /* Operator */,
|
|
106
|
+
fix: function (fixer) { return getMethodToOperatorFixes(node, fixer); }
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
_b;
|
|
110
|
+
}
|
|
111
|
+
return _c = {},
|
|
112
|
+
_c["Program:has(".concat((0, utils_1.pipeableSelect)(storeNames), ") ImportDeclaration[source.value='").concat(utils_1.NGRX_MODULE_PATHS.store, "'] > ImportSpecifier[imported.name='select']")] = function (node) {
|
|
113
|
+
var e_1, _a;
|
|
114
|
+
context.report({
|
|
115
|
+
node: node,
|
|
116
|
+
messageId: "method" /* Method */,
|
|
117
|
+
fix: function (fixer) {
|
|
118
|
+
return (0, utils_1.getImportRemoveFix)(sourceCode, [node.parent], 'select', fixer);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
var _b = __read(context.getDeclaredVariables(node), 1), references = _b[0].references;
|
|
122
|
+
var _loop_1 = function (identifier) {
|
|
123
|
+
context.report({
|
|
124
|
+
node: identifier,
|
|
125
|
+
messageId: "method" /* Method */,
|
|
126
|
+
fix: function (fixer) {
|
|
127
|
+
return getOperatorToMethodFixes(identifier, sourceCode, fixer);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
};
|
|
131
|
+
try {
|
|
132
|
+
for (var references_1 = __values(references), references_1_1 = references_1.next(); !references_1_1.done; references_1_1 = references_1.next()) {
|
|
133
|
+
var identifier = references_1_1.value.identifier;
|
|
134
|
+
_loop_1(identifier);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
138
|
+
finally {
|
|
139
|
+
try {
|
|
140
|
+
if (references_1_1 && !references_1_1.done && (_a = references_1["return"])) _a.call(references_1);
|
|
141
|
+
}
|
|
142
|
+
finally { if (e_1) throw e_1.error; }
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
_c;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
function getMethodToOperatorFixes(node, fixer) {
|
|
149
|
+
var classDeclaration = (0, utils_1.getNearestUpperNodeFrom)(node, utils_1.isClassDeclaration);
|
|
150
|
+
if (!classDeclaration) {
|
|
151
|
+
return [];
|
|
152
|
+
}
|
|
153
|
+
return [
|
|
154
|
+
fixer.insertTextBefore(node.callee.property, 'pipe('),
|
|
155
|
+
fixer.insertTextAfter(node, ')'),
|
|
156
|
+
].concat((0, utils_1.getImportAddFix)({
|
|
157
|
+
fixer: fixer,
|
|
158
|
+
importName: 'select',
|
|
159
|
+
moduleName: utils_1.NGRX_MODULE_PATHS.store,
|
|
160
|
+
node: classDeclaration
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
function getOperatorToMethodFixes(identifier, sourceCode, fixer) {
|
|
164
|
+
var _a;
|
|
165
|
+
var select = identifier.parent;
|
|
166
|
+
var storePipe = select === null || select === void 0 ? void 0 : select.parent;
|
|
167
|
+
if (!storePipe ||
|
|
168
|
+
!(0, utils_1.isCallExpression)(storePipe) ||
|
|
169
|
+
!(0, utils_1.isMemberExpression)(storePipe.callee)) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
var pipeContainsOnlySelect = storePipe.arguments.length === 1;
|
|
173
|
+
if (!pipeContainsOnlySelect) {
|
|
174
|
+
var selectContent = sourceCode.getText(select);
|
|
175
|
+
var nextTokenAfterSelect = sourceCode.getTokenAfter(select);
|
|
176
|
+
var store = storePipe.callee.object;
|
|
177
|
+
return __spreadArray(__spreadArray([
|
|
178
|
+
fixer.remove(select)
|
|
179
|
+
], __read((nextTokenAfterSelect ? [fixer.remove(nextTokenAfterSelect)] : [])), false), [
|
|
180
|
+
fixer.insertTextAfter(store, ".".concat(selectContent)),
|
|
181
|
+
], false);
|
|
182
|
+
}
|
|
183
|
+
var property = storePipe.callee.property;
|
|
184
|
+
var nextTokenAfterPipe = sourceCode.getTokenAfter(property);
|
|
185
|
+
var _b = __read(property.range, 2), pipeInitialRange = _b[0], pipeEndRange = _b[1];
|
|
186
|
+
var pipeRange = [
|
|
187
|
+
pipeInitialRange,
|
|
188
|
+
(_a = nextTokenAfterPipe === null || nextTokenAfterPipe === void 0 ? void 0 : nextTokenAfterPipe.range[1]) !== null && _a !== void 0 ? _a : pipeEndRange,
|
|
189
|
+
];
|
|
190
|
+
var _c = __read(identifier.range, 2), selectEndRange = _c[1];
|
|
191
|
+
return [
|
|
192
|
+
fixer.removeRange(pipeRange),
|
|
193
|
+
fixer.insertTextAfterRange([selectEndRange, selectEndRange + 1], '('),
|
|
194
|
+
];
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=select-style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select-style.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/select-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAYqB;AAER,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAwB/C,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,OAAO;QACnB,IAAI,EAAE;YACJ,WAAW,EACT,kFAAkF;YACpF,WAAW,EAAE,MAAM;SACpB;QACD,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;gBACd,MAAI,EAAE,kDAA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AAE,GAAG,CAAC;KACtE,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 asPattern,\n getImportAddFix,\n getImportRemoveFix,\n getNearestUpperNodeFrom,\n getNgRxStores,\n isCallExpression,\n isClassDeclaration,\n isMemberExpression,\n NGRX_MODULE_PATHS,\n pipeableSelect,\n selectExpression,\n} from '../../utils';\n\nexport const selectMethod = 'selectMethod';\nexport const selectOperator = 'selectOperator';\n\nexport const enum SelectStyle {\n Method = 'method',\n Operator = 'operator',\n}\n\ntype MessageIds = `${SelectStyle}`;\ntype Options = readonly [MessageIds];\ntype MemberExpressionWithProperty = Omit<\n TSESTree.MemberExpression,\n 'property'\n> & {\n property: TSESTree.Identifier;\n};\ntype CallExpression = Omit<TSESTree.CallExpression, 'parent'> & {\n callee: MemberExpressionWithProperty;\n parent: TSESTree.CallExpression & {\n callee: Omit<TSESTree.MemberExpression, 'object'> & {\n object: MemberExpressionWithProperty;\n };\n };\n};\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n ngrxModule: 'store',\n docs: {\n description:\n 'Selector can be used either with `select` as a pipeable operator or as a method.',\n recommended: 'warn',\n },\n fixable: 'code',\n schema: [\n {\n type: 'string',\n enum: [SelectStyle.Method, SelectStyle.Operator],\n additionalProperties: false,\n },\n ],\n messages: {\n [SelectStyle.Method]:\n 'Selector should be used with select method: `this.store.select(selector)`.',\n [SelectStyle.Operator]:\n 'Selector should be used with the pipeable operator: `this.store.pipe(select(selector))`.',\n },\n },\n defaultOptions: [SelectStyle.Method],\n create: (context, [mode]) => {\n const { identifiers = [], sourceCode } = getNgRxStores(context);\n const storeNames = identifiers.length > 0 ? asPattern(identifiers) : null;\n\n if (!storeNames) {\n return {};\n }\n\n if (mode === SelectStyle.Operator) {\n return {\n [selectExpression(storeNames)](node: CallExpression) {\n context.report({\n node: node.callee.property,\n messageId: SelectStyle.Operator,\n fix: (fixer) => getMethodToOperatorFixes(node, fixer),\n });\n },\n };\n }\n\n return {\n [`Program:has(${pipeableSelect(\n storeNames\n )}) ImportDeclaration[source.value='${\n NGRX_MODULE_PATHS.store\n }'] > ImportSpecifier[imported.name='select']`](\n node: TSESTree.ImportSpecifier & {\n parent: TSESTree.ImportDeclaration;\n }\n ) {\n context.report({\n node,\n messageId: SelectStyle.Method,\n fix: (fixer) =>\n getImportRemoveFix(sourceCode, [node.parent], 'select', fixer),\n });\n\n const [{ references }] = context.getDeclaredVariables(node);\n\n for (const { identifier } of references) {\n context.report({\n node: identifier,\n messageId: SelectStyle.Method,\n fix: (fixer) =>\n getOperatorToMethodFixes(identifier, sourceCode, fixer),\n });\n }\n },\n };\n },\n});\n\nfunction getMethodToOperatorFixes(\n node: CallExpression,\n fixer: TSESLint.RuleFixer\n): readonly TSESLint.RuleFix[] {\n const classDeclaration = getNearestUpperNodeFrom(node, isClassDeclaration);\n\n if (!classDeclaration) {\n return [];\n }\n\n return [\n fixer.insertTextBefore(node.callee.property, 'pipe('),\n fixer.insertTextAfter(node, ')'),\n ].concat(\n getImportAddFix({\n fixer,\n importName: 'select',\n moduleName: NGRX_MODULE_PATHS.store,\n node: classDeclaration,\n })\n );\n}\n\nfunction getOperatorToMethodFixes(\n identifier: TSESTree.Node,\n sourceCode: Readonly<TSESLint.SourceCode>,\n fixer: TSESLint.RuleFixer\n): readonly TSESLint.RuleFix[] {\n const select = identifier.parent;\n const storePipe = select?.parent;\n\n if (\n !storePipe ||\n !isCallExpression(storePipe) ||\n !isMemberExpression(storePipe.callee)\n ) {\n return [];\n }\n\n const pipeContainsOnlySelect = storePipe.arguments.length === 1;\n\n if (!pipeContainsOnlySelect) {\n const selectContent = sourceCode.getText(select);\n const nextTokenAfterSelect = sourceCode.getTokenAfter(select);\n const store = storePipe.callee.object;\n return [\n fixer.remove(select),\n ...(nextTokenAfterSelect ? [fixer.remove(nextTokenAfterSelect)] : []),\n fixer.insertTextAfter(store, `.${selectContent}`),\n ];\n }\n\n const { property } = storePipe.callee;\n const nextTokenAfterPipe = sourceCode.getTokenAfter(property);\n const [pipeInitialRange, pipeEndRange] = property.range;\n const pipeRange: TSESTree.Range = [\n pipeInitialRange,\n nextTokenAfterPipe?.range[1] ?? pipeEndRange,\n ];\n const [, selectEndRange] = identifier.range;\n return [\n fixer.removeRange(pipeRange),\n fixer.insertTextAfterRange([selectEndRange, selectEndRange + 1], '('),\n ];\n}\n"]}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
37
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
38
|
+
if (!m) return o;
|
|
39
|
+
var i = m.call(o), r, ar = [], e;
|
|
40
|
+
try {
|
|
41
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
42
|
+
}
|
|
43
|
+
catch (error) { e = { error: error }; }
|
|
44
|
+
finally {
|
|
45
|
+
try {
|
|
46
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
47
|
+
}
|
|
48
|
+
finally { if (e) throw e.error; }
|
|
49
|
+
}
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
var __values = (this && this.__values) || function(o) {
|
|
53
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
54
|
+
if (m) return m.call(o);
|
|
55
|
+
if (o && typeof o.length === "number") return {
|
|
56
|
+
next: function () {
|
|
57
|
+
if (o && i >= o.length) o = void 0;
|
|
58
|
+
return { value: o && o[i++], done: !o };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
62
|
+
};
|
|
63
|
+
var _a;
|
|
64
|
+
exports.__esModule = true;
|
|
65
|
+
exports.useConsistentGlobalStoreNameSuggest = exports.useConsistentGlobalStoreName = void 0;
|
|
66
|
+
var path = __importStar(require("path"));
|
|
67
|
+
var rule_creator_1 = require("../../rule-creator");
|
|
68
|
+
var utils_1 = require("../../utils");
|
|
69
|
+
exports.useConsistentGlobalStoreName = 'useConsistentGlobalStoreName';
|
|
70
|
+
exports.useConsistentGlobalStoreNameSuggest = 'useConsistentGlobalStoreNameSuggest';
|
|
71
|
+
exports["default"] = (0, rule_creator_1.createRule)({
|
|
72
|
+
name: path.parse(__filename).name,
|
|
73
|
+
meta: {
|
|
74
|
+
type: 'suggestion',
|
|
75
|
+
hasSuggestions: true,
|
|
76
|
+
ngrxModule: 'store',
|
|
77
|
+
docs: {
|
|
78
|
+
description: 'Use a consistent name for the global store.',
|
|
79
|
+
recommended: 'warn',
|
|
80
|
+
suggestion: true
|
|
81
|
+
},
|
|
82
|
+
schema: [
|
|
83
|
+
{
|
|
84
|
+
type: 'string',
|
|
85
|
+
additionalProperties: false
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
messages: (_a = {},
|
|
89
|
+
_a[exports.useConsistentGlobalStoreName] = 'Global store should be named as `{{ storeName }}`.',
|
|
90
|
+
_a[exports.useConsistentGlobalStoreNameSuggest] = 'Rename it to `{{ storeName }}`.',
|
|
91
|
+
_a)
|
|
92
|
+
},
|
|
93
|
+
defaultOptions: ['store'],
|
|
94
|
+
create: function (context, _a) {
|
|
95
|
+
var _b = __read(_a, 1), storeName = _b[0];
|
|
96
|
+
return {
|
|
97
|
+
Program: function () {
|
|
98
|
+
var e_1, _a;
|
|
99
|
+
var _b = (0, utils_1.getNgRxStores)(context).identifiers, identifiers = _b === void 0 ? [] : _b;
|
|
100
|
+
var _loop_1 = function (loc, name_1, range, typeAnnotation) {
|
|
101
|
+
if (name_1 === storeName) {
|
|
102
|
+
return { value: void 0 };
|
|
103
|
+
}
|
|
104
|
+
var data = { storeName: storeName };
|
|
105
|
+
context.report({
|
|
106
|
+
loc: __assign(__assign({}, loc), { end: __assign(__assign({}, loc.start), { column: loc.start.column + name_1.length }) }),
|
|
107
|
+
messageId: exports.useConsistentGlobalStoreName,
|
|
108
|
+
data: data,
|
|
109
|
+
suggest: [
|
|
110
|
+
{
|
|
111
|
+
messageId: exports.useConsistentGlobalStoreNameSuggest,
|
|
112
|
+
data: data,
|
|
113
|
+
fix: function (fixer) {
|
|
114
|
+
return fixer.replaceTextRange([range[0], typeAnnotation.range[0]], storeName);
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
try {
|
|
121
|
+
for (var identifiers_1 = __values(identifiers), identifiers_1_1 = identifiers_1.next(); !identifiers_1_1.done; identifiers_1_1 = identifiers_1.next()) {
|
|
122
|
+
var _c = identifiers_1_1.value, loc = _c.loc, name_1 = _c.name, range = _c.range, typeAnnotation = _c.typeAnnotation;
|
|
123
|
+
var state_1 = _loop_1(loc, name_1, range, typeAnnotation);
|
|
124
|
+
if (typeof state_1 === "object")
|
|
125
|
+
return state_1.value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
129
|
+
finally {
|
|
130
|
+
try {
|
|
131
|
+
if (identifiers_1_1 && !identifiers_1_1.done && (_a = identifiers_1["return"])) _a.call(identifiers_1);
|
|
132
|
+
}
|
|
133
|
+
finally { if (e_1) throw e_1.error; }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
//# sourceMappingURL=use-consistent-global-store-name.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-consistent-global-store-name.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/use-consistent-global-store-name.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAA6B;AAC7B,mDAAgD;AAChD,qCAA4C;AAE/B,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAOxC,qBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI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AAC,EACnC,SAAS,CACV;gCAHD,CAGC;6BACJ;yBACF;qBACF,CAAC,CAAC;;;oBA3BL,KAAmD,IAAA,gBAAA,SAAA,WAAW,CAAA,wCAAA;wBAAnD,IAAA,0BAAoC,EAAlC,GAAG,SAAA,EAAE,MAAI,UAAA,EAAE,KAAK,WAAA,EAAE,cAAc,oBAAA;8CAAhC,GAAG,EAAE,MAAI,EAAE,KAAK,EAAE,cAAc;;;qBA4B5C;;;;;;;;;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import * as path from 'path';\nimport { createRule } from '../../rule-creator';\nimport { getNgRxStores } from '../../utils';\n\nexport const useConsistentGlobalStoreName = 'useConsistentGlobalStoreName';\nexport const useConsistentGlobalStoreNameSuggest =\n 'useConsistentGlobalStoreNameSuggest';\n\ntype MessageIds =\n | typeof useConsistentGlobalStoreName\n | typeof useConsistentGlobalStoreNameSuggest;\ntype Options = readonly [string];\n\nexport default createRule<Options, MessageIds>({\n name: path.parse(__filename).name,\n meta: {\n type: 'suggestion',\n hasSuggestions: true,\n ngrxModule: 'store',\n docs: {\n description: 'Use a consistent name for the global store.',\n recommended: 'warn',\n suggestion: true,\n },\n schema: [\n {\n type: 'string',\n additionalProperties: false,\n },\n ],\n messages: {\n [useConsistentGlobalStoreName]:\n 'Global store should be named as `{{ storeName }}`.',\n [useConsistentGlobalStoreNameSuggest]: 'Rename it to `{{ storeName }}`.',\n },\n },\n defaultOptions: ['store'],\n create: (context, [storeName]) => {\n return {\n Program() {\n const { identifiers = [] } = getNgRxStores(context);\n\n for (const { loc, name, range, typeAnnotation } of identifiers) {\n if (name === storeName) {\n return;\n }\n\n const data = { storeName };\n context.report({\n loc: {\n ...loc,\n end: {\n ...loc.start,\n column: loc.start.column + name.length,\n },\n },\n messageId: useConsistentGlobalStoreName,\n data,\n suggest: [\n {\n messageId: useConsistentGlobalStoreNameSuggest,\n data,\n fix: (fixer) =>\n fixer.replaceTextRange(\n [range[0], typeAnnotation.range[0]],\n storeName\n ),\n },\n ],\n });\n }\n },\n };\n },\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/docs.ts"],"names":[],"mappings":";;;AAAO,IAAM,OAAO,GAAG,UAAC,QAAgB;IACtC,OAAA,oDAA6C,QAAQ,QAAK;AAA1D,CAA0D,CAAC;AADhD,QAAA,OAAO,WACyC","sourcesContent":["export const docsUrl = (ruleName: string) =>\n `https://ngrx.io/guide/eslint-plugin/rules/${ruleName}.md`;\n"]}
|
|
@@ -0,0 +1,118 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (_) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var __values = (this && this.__values) || function(o) {
|
|
53
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
54
|
+
if (m) return m.call(o);
|
|
55
|
+
if (o && typeof o.length === "number") return {
|
|
56
|
+
next: function () {
|
|
57
|
+
if (o && i >= o.length) o = void 0;
|
|
58
|
+
return { value: o && o[i++], done: !o };
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
62
|
+
};
|
|
63
|
+
exports.__esModule = true;
|
|
64
|
+
exports.traverseFolder = void 0;
|
|
65
|
+
var fs = __importStar(require("fs"));
|
|
66
|
+
var path = __importStar(require("path"));
|
|
67
|
+
function traverseFolder(folder, extensions) {
|
|
68
|
+
var folders, folders_1, folders_1_1, folderEntry, entryPath, e_1_1;
|
|
69
|
+
var e_1, _a;
|
|
70
|
+
if (extensions === void 0) { extensions = ['.ts', '.js']; }
|
|
71
|
+
return __generator(this, function (_b) {
|
|
72
|
+
switch (_b.label) {
|
|
73
|
+
case 0:
|
|
74
|
+
folders = fs.readdirSync(folder, { withFileTypes: true });
|
|
75
|
+
_b.label = 1;
|
|
76
|
+
case 1:
|
|
77
|
+
_b.trys.push([1, 8, 9, 10]);
|
|
78
|
+
folders_1 = __values(folders), folders_1_1 = folders_1.next();
|
|
79
|
+
_b.label = 2;
|
|
80
|
+
case 2:
|
|
81
|
+
if (!!folders_1_1.done) return [3 /*break*/, 7];
|
|
82
|
+
folderEntry = folders_1_1.value;
|
|
83
|
+
entryPath = path.resolve(folder, folderEntry.name);
|
|
84
|
+
if (!folderEntry.isDirectory()) return [3 /*break*/, 4];
|
|
85
|
+
return [5 /*yield**/, __values(traverseFolder(entryPath, extensions))];
|
|
86
|
+
case 3:
|
|
87
|
+
_b.sent();
|
|
88
|
+
return [3 /*break*/, 6];
|
|
89
|
+
case 4:
|
|
90
|
+
if (!extensions.includes(path.extname(entryPath))) return [3 /*break*/, 6];
|
|
91
|
+
return [4 /*yield*/, {
|
|
92
|
+
folder: folder,
|
|
93
|
+
file: path.parse(folderEntry.name).name,
|
|
94
|
+
path: entryPath
|
|
95
|
+
}];
|
|
96
|
+
case 5:
|
|
97
|
+
_b.sent();
|
|
98
|
+
_b.label = 6;
|
|
99
|
+
case 6:
|
|
100
|
+
folders_1_1 = folders_1.next();
|
|
101
|
+
return [3 /*break*/, 2];
|
|
102
|
+
case 7: return [3 /*break*/, 10];
|
|
103
|
+
case 8:
|
|
104
|
+
e_1_1 = _b.sent();
|
|
105
|
+
e_1 = { error: e_1_1 };
|
|
106
|
+
return [3 /*break*/, 10];
|
|
107
|
+
case 9:
|
|
108
|
+
try {
|
|
109
|
+
if (folders_1_1 && !folders_1_1.done && (_a = folders_1["return"])) _a.call(folders_1);
|
|
110
|
+
}
|
|
111
|
+
finally { if (e_1) throw e_1.error; }
|
|
112
|
+
return [7 /*endfinally*/];
|
|
113
|
+
case 10: return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
exports.traverseFolder = traverseFolder;
|
|
118
|
+
//# sourceMappingURL=folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folder.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/folder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyB;AACzB,yCAA6B;AAE7B,SAAiB,cAAc,CAC7B,MAAc,EACd,UAA2B;;;IAA3B,2BAAA,EAAA,cAAc,KAAK,EAAE,KAAK,CAAC;;;;gBAErB,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;;;;gBACtC,YAAA,SAAA,OAAO,CAAA;;;;gBAAtB,WAAW;gBACd,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;qBACrD,WAAW,CAAC,WAAW,EAAE,EAAzB,wBAAyB;gBAC3B,sBAAA,SAAO,cAAc,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA,EAAA;;gBAA5C,SAA4C,CAAC;;;qBACpC,UAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAA5C,wBAA4C;gBACrD,qBAAM;wBACJ,MAAM,QAAA;wBACN,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI;wBACvC,IAAI,EAAE,SAAS;qBAChB,EAAA;;gBAJD,SAIC,CAAC;;;;;;;;;;;;;;;;;;;CAGP;AAjBD,wCAiBC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nexport function* traverseFolder(\n folder: string,\n extensions = ['.ts', '.js']\n): Generator<{ folder: string; file: string; path: string }> {\n const folders = fs.readdirSync(folder, { withFileTypes: true });\n for (const folderEntry of folders) {\n const entryPath = path.resolve(folder, folderEntry.name);\n if (folderEntry.isDirectory()) {\n yield* traverseFolder(entryPath, extensions);\n } else if (extensions.includes(path.extname(entryPath))) {\n yield {\n folder,\n file: path.parse(folderEntry.name).name,\n path: entryPath,\n };\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.isCallExpressionWith = exports.isTypeReference = exports.isIdentifierOrMemberExpression = exports.isProperty = exports.isObjectExpression = exports.isTSTypeReference = exports.isTSTypeAnnotation = exports.isTSParameterProperty = exports.isThisExpression = exports.isProgram = exports.isMemberExpression = exports.isTemplateLiteral = exports.isTemplateElement = exports.isLiteral = exports.isImportSpecifier = exports.isImportNamespaceSpecifier = exports.isImportDefaultSpecifier = exports.isImportDeclaration = exports.isIdentifier = exports.isFunctionExpression = exports.isPropertyDefinition = exports.isClassDeclaration = exports.isCallExpression = exports.isMethodDefinition = exports.isReturnStatement = exports.isArrowFunctionExpression = void 0;
|
|
4
|
+
var experimental_utils_1 = require("@typescript-eslint/experimental-utils");
|
|
5
|
+
var isNodeOfType = function (nodeType) {
|
|
6
|
+
return function (node) {
|
|
7
|
+
return node.type === nodeType;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
exports.isArrowFunctionExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ArrowFunctionExpression);
|
|
11
|
+
exports.isReturnStatement = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ReturnStatement);
|
|
12
|
+
exports.isMethodDefinition = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.MethodDefinition);
|
|
13
|
+
exports.isCallExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.CallExpression);
|
|
14
|
+
exports.isClassDeclaration = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ClassDeclaration);
|
|
15
|
+
exports.isPropertyDefinition = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.PropertyDefinition);
|
|
16
|
+
exports.isFunctionExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.FunctionExpression);
|
|
17
|
+
exports.isIdentifier = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.Identifier);
|
|
18
|
+
exports.isImportDeclaration = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ImportDeclaration);
|
|
19
|
+
exports.isImportDefaultSpecifier = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ImportDefaultSpecifier);
|
|
20
|
+
exports.isImportNamespaceSpecifier = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ImportNamespaceSpecifier);
|
|
21
|
+
exports.isImportSpecifier = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ImportSpecifier);
|
|
22
|
+
exports.isLiteral = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.Literal);
|
|
23
|
+
exports.isTemplateElement = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TemplateElement);
|
|
24
|
+
exports.isTemplateLiteral = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TemplateLiteral);
|
|
25
|
+
exports.isMemberExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.MemberExpression);
|
|
26
|
+
exports.isProgram = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.Program);
|
|
27
|
+
exports.isThisExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ThisExpression);
|
|
28
|
+
exports.isTSParameterProperty = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TSParameterProperty);
|
|
29
|
+
exports.isTSTypeAnnotation = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TSTypeAnnotation);
|
|
30
|
+
exports.isTSTypeReference = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.TSTypeReference);
|
|
31
|
+
exports.isObjectExpression = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.ObjectExpression);
|
|
32
|
+
exports.isProperty = isNodeOfType(experimental_utils_1.AST_NODE_TYPES.Property);
|
|
33
|
+
function isIdentifierOrMemberExpression(node) {
|
|
34
|
+
return (0, exports.isIdentifier)(node) || (0, exports.isMemberExpression)(node);
|
|
35
|
+
}
|
|
36
|
+
exports.isIdentifierOrMemberExpression = isIdentifierOrMemberExpression;
|
|
37
|
+
function isTypeReference(type) {
|
|
38
|
+
return type.hasOwnProperty('target');
|
|
39
|
+
}
|
|
40
|
+
exports.isTypeReference = isTypeReference;
|
|
41
|
+
function equalTo(one, other) {
|
|
42
|
+
return typeof one === 'string' ? one === other : one.test(other);
|
|
43
|
+
}
|
|
44
|
+
function isCallExpressionWith(node, objectName, propertyName) {
|
|
45
|
+
return ((0, exports.isMemberExpression)(node.callee) &&
|
|
46
|
+
!node.callee.computed &&
|
|
47
|
+
node.callee.property.name === propertyName &&
|
|
48
|
+
(((0, exports.isIdentifier)(node.callee.object) &&
|
|
49
|
+
equalTo(objectName, node.callee.object.name)) ||
|
|
50
|
+
((0, exports.isMemberExpression)(node.callee.object) &&
|
|
51
|
+
(0, exports.isThisExpression)(node.callee.object.object) &&
|
|
52
|
+
(0, exports.isIdentifier)(node.callee.object.property) &&
|
|
53
|
+
equalTo(objectName, node.callee.object.property.name))));
|
|
54
|
+
}
|
|
55
|
+
exports.isCallExpressionWith = isCallExpressionWith;
|
|
56
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/guards.ts"],"names":[],"mappings":";;;AACA,4EAAuE;AAGvE,IAAM,YAAY,GAChB,UAAkC,QAAkB;IACpD,OAAA,UAAC,IAAmB;QAClB,OAAA,IAAI,CAAC,IAAI,KAAK,QAAQ;IAAtB,CAAsB;AADxB,CACwB,CAAC;AAEd,QAAA,yBAAyB,GAAG,YAAY,CACnD,mCAAc,CAAC,uBAAuB,CACvC,CAAC;AACW,QAAA,iBAAiB,GAAG,YAAY,CAAC,mCAAc,CAAC,eAAe,CAAC,CAAC;AACjE,QAAA,kBAAkB,GAAG,YAAY,CAAC,mCAAc,CAAC,gBAAgB,CAAC,CAAC;AACnE,QAAA,gBAAgB,GAAG,YAAY,CAAC,mCAAc,CAAC,cAAc,CAAC,CAAC;AAC/D,QAAA,kBAAkB,GAAG,YAAY,CAAC,mCAAc,CAAC,gBAAgB,CAAC,CAAC;AACnE,QAAA,oBAAoB,GAAG,YAAY,CAC9C,mCAAc,CAAC,kBAAkB,CAClC,CAAC;AACW,QAAA,oBAAoB,GAAG,YAAY,CAC9C,mCAAc,CAAC,kBAAkB,CAClC,CAAC;AACW,QAAA,YAAY,GAAG,YAAY,CAAC,mCAAc,CAAC,UAAU,CAAC,CAAC;AACvD,QAAA,mBAAmB,GAAG,YAAY,CAC7C,mCAAc,CAAC,iBAAiB,CACjC,CAAC;AACW,QAAA,wBAAwB,GAAG,YAAY,CAClD,mCAAc,CAAC,sBAAsB,CACtC,CAAC;A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O,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC;AAED,SAAgB,oBAAoB,CAClC,IAA6B,EAC7B,UAA2B,EAC3B,YAAoB;IAEpB,OAAO,CACL,IAAA,0BAAkB,EAAC,IAAI,CAAC,MAAM,CAAC;QAC/B,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ;QACrB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,YAAY;QAC1C,CAAC,CAAC,IAAA,oBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAChC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YAC7C,CAAC,IAAA,0BAAkB,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;gBACrC,IAAA,wBAAgB,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;gBAC3C,IAAA,oBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;gBACzC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAC5D,CAAC;AACJ,CAAC;AAhBD,oDAgBC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/experimental-utils';\nimport { AST_NODE_TYPES } from '@typescript-eslint/experimental-utils';\nimport type * as ts from 'typescript';\n\nconst isNodeOfType =\n <NodeType extends AST_NODE_TYPES>(nodeType: NodeType) =>\n (node: TSESTree.Node): node is TSESTree.Node & { type: NodeType } =>\n node.type === nodeType;\n\nexport const isArrowFunctionExpression = isNodeOfType(\n AST_NODE_TYPES.ArrowFunctionExpression\n);\nexport const isReturnStatement = isNodeOfType(AST_NODE_TYPES.ReturnStatement);\nexport const isMethodDefinition = isNodeOfType(AST_NODE_TYPES.MethodDefinition);\nexport const isCallExpression = isNodeOfType(AST_NODE_TYPES.CallExpression);\nexport const isClassDeclaration = isNodeOfType(AST_NODE_TYPES.ClassDeclaration);\nexport const isPropertyDefinition = isNodeOfType(\n AST_NODE_TYPES.PropertyDefinition\n);\nexport const isFunctionExpression = isNodeOfType(\n AST_NODE_TYPES.FunctionExpression\n);\nexport const isIdentifier = isNodeOfType(AST_NODE_TYPES.Identifier);\nexport const isImportDeclaration = isNodeOfType(\n AST_NODE_TYPES.ImportDeclaration\n);\nexport const isImportDefaultSpecifier = isNodeOfType(\n AST_NODE_TYPES.ImportDefaultSpecifier\n);\nexport const isImportNamespaceSpecifier = isNodeOfType(\n AST_NODE_TYPES.ImportNamespaceSpecifier\n);\nexport const isImportSpecifier = isNodeOfType(AST_NODE_TYPES.ImportSpecifier);\nexport const isLiteral = isNodeOfType(AST_NODE_TYPES.Literal);\nexport const isTemplateElement = isNodeOfType(AST_NODE_TYPES.TemplateElement);\nexport const isTemplateLiteral = isNodeOfType(AST_NODE_TYPES.TemplateLiteral);\nexport const isMemberExpression = isNodeOfType(AST_NODE_TYPES.MemberExpression);\nexport const isProgram = isNodeOfType(AST_NODE_TYPES.Program);\nexport const isThisExpression = isNodeOfType(AST_NODE_TYPES.ThisExpression);\nexport const isTSParameterProperty = isNodeOfType(\n AST_NODE_TYPES.TSParameterProperty\n);\nexport const isTSTypeAnnotation = isNodeOfType(AST_NODE_TYPES.TSTypeAnnotation);\nexport const isTSTypeReference = isNodeOfType(AST_NODE_TYPES.TSTypeReference);\nexport const isObjectExpression = isNodeOfType(AST_NODE_TYPES.ObjectExpression);\nexport const isProperty = isNodeOfType(AST_NODE_TYPES.Property);\n\nexport function isIdentifierOrMemberExpression(\n node: TSESTree.Node\n): node is TSESTree.Identifier | TSESTree.MemberExpression {\n return isIdentifier(node) || isMemberExpression(node);\n}\n\nexport function isTypeReference(type: ts.Type): type is ts.TypeReference {\n return type.hasOwnProperty('target');\n}\n\nfunction equalTo(one: RegExp | string, other: string) {\n return typeof one === 'string' ? one === other : one.test(other);\n}\n\nexport function isCallExpressionWith(\n node: TSESTree.CallExpression,\n objectName: RegExp | string,\n propertyName: string\n) {\n return (\n isMemberExpression(node.callee) &&\n !node.callee.computed &&\n node.callee.property.name === propertyName &&\n ((isIdentifier(node.callee.object) &&\n equalTo(objectName, node.callee.object.name)) ||\n (isMemberExpression(node.callee.object) &&\n isThisExpression(node.callee.object.object) &&\n isIdentifier(node.callee.object.property) &&\n equalTo(objectName, node.callee.object.property.name)))\n );\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
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("./docs"), exports);
|
|
18
|
+
__exportStar(require("./folder"), exports);
|
|
19
|
+
__exportStar(require("./guards"), exports);
|
|
20
|
+
__exportStar(require("./ngrx-modules"), exports);
|
|
21
|
+
__exportStar(require("./utils"), exports);
|
|
22
|
+
__exportStar(require("./versions"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,2CAAyB;AACzB,iDAA+B;AAC/B,0CAAwB;AACxB,6CAA2B","sourcesContent":["export * from './docs';\nexport * from './folder';\nexport * from './guards';\nexport * from './ngrx-modules';\nexport * from './utils';\nexport * from './versions';\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.NGRX_MODULE_PATHS = void 0;
|
|
5
|
+
exports.NGRX_MODULE_PATHS = (_a = {},
|
|
6
|
+
_a['component-store'] = '@ngrx/component-store',
|
|
7
|
+
_a.effects = '@ngrx/effects',
|
|
8
|
+
_a.store = '@ngrx/store',
|
|
9
|
+
_a);
|
|
10
|
+
//# sourceMappingURL=ngrx-modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ngrx-modules.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/ngrx-modules.ts"],"names":[],"mappings":";;;;AAAa,QAAA,iBAAiB,GAAG,CAAA;IAC/B,GAAC,iBAAiB,IAAG,uBAAuB;IAC5C,UAAO,GAAE,eAAe;IACxB,QAAK,GAAE,aAAa;MACZ,CAAA,CAAC","sourcesContent":["export const NGRX_MODULE_PATHS = {\n ['component-store']: '@ngrx/component-store',\n effects: '@ngrx/effects',\n store: '@ngrx/store',\n} as const;\n\nexport type NGRX_MODULE = keyof typeof NGRX_MODULE_PATHS;\n"]}
|