@ngrx/eslint-plugin 20.0.1 → 21.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/package.json +1 -2
- package/schematics/ng-add/schema.json +15 -0
- package/scripts/generate-config.js +61 -72
- package/scripts/generate-config.js.map +1 -1
- package/scripts/generate-docs.js +21 -22
- package/scripts/generate-docs.js.map +1 -1
- package/scripts/generate-overview.js +63 -56
- package/scripts/generate-overview.js.map +1 -1
- package/spec/utils/from-fixture.js.map +1 -1
- package/spec/utils/rule-tester.d.ts +1 -4
- package/spec/utils/rule-tester.js +7 -9
- package/spec/utils/rule-tester.js.map +1 -1
- package/src/configs/all.js +0 -9
- package/src/configs/all.js.map +1 -1
- package/src/configs/all.json +0 -8
- package/src/configs/allTypeChecked.d.ts +7 -0
- package/src/configs/allTypeChecked.js +61 -0
- package/src/configs/allTypeChecked.js.map +1 -0
- package/src/configs/allTypeChecked.json +41 -0
- package/src/configs/component-store.js +0 -1
- package/src/configs/component-store.js.map +1 -1
- package/src/configs/effects.js +0 -8
- package/src/configs/effects.js.map +1 -1
- package/src/configs/effects.json +0 -7
- package/src/configs/effectsTypeChecked.d.ts +7 -0
- package/src/configs/effectsTypeChecked.js +33 -0
- package/src/configs/effectsTypeChecked.js.map +1 -0
- package/src/configs/effectsTypeChecked.json +13 -0
- package/src/configs/operators.js +0 -1
- package/src/configs/operators.js.map +1 -1
- package/src/configs/signals.js +0 -7
- package/src/configs/signals.js.map +1 -1
- package/src/configs/signals.json +1 -7
- package/src/configs/signalsTypeChecked.d.ts +7 -0
- package/src/configs/signalsTypeChecked.js +31 -0
- package/src/configs/signalsTypeChecked.js.map +1 -0
- package/src/configs/signalsTypeChecked.json +11 -0
- package/src/configs/store.js +0 -1
- package/src/configs/store.js.map +1 -1
- package/src/index.d.ts +35 -56
- package/src/rule-creator.d.ts +7 -23
- package/src/rule-creator.js +22 -18
- package/src/rule-creator.js.map +1 -1
- package/src/rules/component-store/avoid-combining-component-store-selectors.d.ts +1 -1
- package/src/rules/component-store/avoid-combining-component-store-selectors.js +1 -1
- package/src/rules/component-store/avoid-combining-component-store-selectors.js.map +1 -1
- package/src/rules/component-store/avoid-mapping-component-store-selectors.d.ts +1 -1
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js +1 -1
- package/src/rules/component-store/avoid-mapping-component-store-selectors.js.map +1 -1
- package/src/rules/component-store/require-super-ondestroy.d.ts +1 -1
- package/src/rules/component-store/require-super-ondestroy.js +1 -1
- package/src/rules/component-store/require-super-ondestroy.js.map +1 -1
- package/src/rules/component-store/updater-explicit-return-type.d.ts +1 -1
- package/src/rules/component-store/updater-explicit-return-type.js +1 -1
- package/src/rules/component-store/updater-explicit-return-type.js.map +1 -1
- package/src/rules/effects/avoid-cyclic-effects.d.ts +1 -1
- package/src/rules/effects/avoid-cyclic-effects.js +1 -1
- package/src/rules/effects/avoid-cyclic-effects.js.map +1 -1
- package/src/rules/effects/no-dispatch-in-effects.d.ts +1 -1
- package/src/rules/effects/no-dispatch-in-effects.js +1 -1
- package/src/rules/effects/no-dispatch-in-effects.js.map +1 -1
- package/src/rules/effects/no-effects-in-providers.d.ts +1 -1
- package/src/rules/effects/no-effects-in-providers.js +1 -1
- package/src/rules/effects/no-effects-in-providers.js.map +1 -1
- package/src/rules/effects/no-multiple-actions-in-effects.d.ts +1 -1
- package/src/rules/effects/no-multiple-actions-in-effects.js +1 -1
- package/src/rules/effects/no-multiple-actions-in-effects.js.map +1 -1
- package/src/rules/effects/prefer-action-creator-in-of-type.d.ts +1 -1
- package/src/rules/effects/prefer-action-creator-in-of-type.js +1 -1
- package/src/rules/effects/prefer-action-creator-in-of-type.js.map +1 -1
- package/src/rules/effects/prefer-effect-callback-in-block-statement.d.ts +1 -1
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js +1 -1
- package/src/rules/effects/prefer-effect-callback-in-block-statement.js.map +1 -1
- package/src/rules/effects/use-effects-lifecycle-interface.d.ts +1 -1
- package/src/rules/effects/use-effects-lifecycle-interface.js +1 -1
- package/src/rules/effects/use-effects-lifecycle-interface.js.map +1 -1
- package/src/rules/index.d.ts +35 -35
- package/src/rules/operators/prefer-concat-latest-from.d.ts +1 -1
- package/src/rules/operators/prefer-concat-latest-from.js +1 -1
- package/src/rules/operators/prefer-concat-latest-from.js.map +1 -1
- package/src/rules/signals/enforce-type-call.d.ts +1 -1
- package/src/rules/signals/enforce-type-call.js +1 -1
- package/src/rules/signals/enforce-type-call.js.map +1 -1
- package/src/rules/signals/prefer-protected-state.d.ts +1 -1
- package/src/rules/signals/prefer-protected-state.js +1 -1
- package/src/rules/signals/prefer-protected-state.js.map +1 -1
- package/src/rules/signals/signal-state-no-arrays-at-root-level.d.ts +1 -1
- package/src/rules/signals/signal-state-no-arrays-at-root-level.js +1 -1
- package/src/rules/signals/signal-state-no-arrays-at-root-level.js.map +1 -1
- package/src/rules/signals/signal-store-feature-should-use-generic-type.d.ts +1 -1
- package/src/rules/signals/signal-store-feature-should-use-generic-type.js +1 -1
- package/src/rules/signals/signal-store-feature-should-use-generic-type.js.map +1 -1
- package/src/rules/signals/with-state-no-arrays-at-root-level.d.ts +1 -1
- package/src/rules/signals/with-state-no-arrays-at-root-level.js +1 -1
- package/src/rules/signals/with-state-no-arrays-at-root-level.js.map +1 -1
- package/src/rules/store/avoid-combining-selectors.d.ts +1 -1
- package/src/rules/store/avoid-combining-selectors.js +1 -1
- package/src/rules/store/avoid-combining-selectors.js.map +1 -1
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.d.ts +1 -1
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js +1 -1
- package/src/rules/store/avoid-dispatching-multiple-actions-sequentially.js.map +1 -1
- package/src/rules/store/avoid-duplicate-actions-in-reducer.d.ts +1 -1
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js +1 -1
- package/src/rules/store/avoid-duplicate-actions-in-reducer.js.map +1 -1
- package/src/rules/store/avoid-mapping-selectors.d.ts +1 -1
- package/src/rules/store/avoid-mapping-selectors.js +1 -1
- package/src/rules/store/avoid-mapping-selectors.js.map +1 -1
- package/src/rules/store/good-action-hygiene.d.ts +1 -1
- package/src/rules/store/good-action-hygiene.js +1 -1
- package/src/rules/store/good-action-hygiene.js.map +1 -1
- package/src/rules/store/no-multiple-global-stores.d.ts +1 -1
- package/src/rules/store/no-multiple-global-stores.js +1 -1
- package/src/rules/store/no-multiple-global-stores.js.map +1 -1
- package/src/rules/store/no-reducer-in-key-names.d.ts +1 -1
- package/src/rules/store/no-reducer-in-key-names.js +1 -1
- package/src/rules/store/no-reducer-in-key-names.js.map +1 -1
- package/src/rules/store/no-store-subscription.d.ts +1 -1
- package/src/rules/store/no-store-subscription.js +1 -1
- package/src/rules/store/no-store-subscription.js.map +1 -1
- package/src/rules/store/no-typed-global-store.d.ts +1 -1
- package/src/rules/store/no-typed-global-store.js +1 -1
- package/src/rules/store/no-typed-global-store.js.map +1 -1
- package/src/rules/store/on-function-explicit-return-type.d.ts +1 -1
- package/src/rules/store/on-function-explicit-return-type.js +1 -1
- package/src/rules/store/on-function-explicit-return-type.js.map +1 -1
- package/src/rules/store/prefer-action-creator-in-dispatch.d.ts +1 -1
- package/src/rules/store/prefer-action-creator-in-dispatch.js +1 -1
- package/src/rules/store/prefer-action-creator-in-dispatch.js.map +1 -1
- package/src/rules/store/prefer-action-creator.d.ts +1 -1
- package/src/rules/store/prefer-action-creator.js +1 -1
- package/src/rules/store/prefer-action-creator.js.map +1 -1
- package/src/rules/store/prefer-inline-action-props.d.ts +1 -1
- package/src/rules/store/prefer-inline-action-props.js +1 -1
- package/src/rules/store/prefer-inline-action-props.js.map +1 -1
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.d.ts +1 -1
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js +1 -1
- package/src/rules/store/prefer-one-generic-in-create-for-feature-selector.js.map +1 -1
- package/src/rules/store/prefer-selector-in-select.d.ts +1 -1
- package/src/rules/store/prefer-selector-in-select.js +1 -1
- package/src/rules/store/prefer-selector-in-select.js.map +1 -1
- package/src/rules/store/prefix-selectors-with-select.d.ts +1 -1
- package/src/rules/store/prefix-selectors-with-select.js +121 -25
- package/src/rules/store/prefix-selectors-with-select.js.map +1 -1
- package/src/rules/store/select-style.d.ts +1 -1
- package/src/rules/store/select-style.js +1 -1
- package/src/rules/store/select-style.js.map +1 -1
- package/src/rules/store/use-consistent-global-store-name.d.ts +1 -1
- package/src/rules/store/use-consistent-global-store-name.js +1 -1
- package/src/rules/store/use-consistent-global-store-name.js.map +1 -1
- package/src/utils/helper-functions/index.d.ts +0 -2
- package/src/utils/helper-functions/index.js +0 -2
- package/src/utils/helper-functions/index.js.map +1 -1
- package/src/utils/helper-functions/rules.d.ts +1 -2
- package/src/utils/helper-functions/rules.js +5 -4
- package/src/utils/helper-functions/rules.js.map +1 -1
- package/src/utils/helper-functions/utils.js.map +1 -1
- package/v9/index.d.ts +6 -0
- package/v9/index.js +6 -0
- package/v9/index.js.map +1 -1
- package/jest.config.d.ts +0 -15
- package/jest.config.js +0 -25
- package/jest.config.js.map +0 -1
- package/src/utils/helper-functions/docs.d.ts +0 -1
- package/src/utils/helper-functions/docs.js +0 -6
- package/src/utils/helper-functions/docs.js.map +0 -1
- package/src/utils/helper-functions/versions.d.ts +0 -1
- package/src/utils/helper-functions/versions.js +0 -78
- package/src/utils/helper-functions/versions.js.map +0 -1
|
@@ -44,9 +44,9 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
44
44
|
meta: {
|
|
45
45
|
type: 'suggestion',
|
|
46
46
|
hasSuggestions: true,
|
|
47
|
-
ngrxModule: 'store',
|
|
48
47
|
docs: {
|
|
49
48
|
description: 'The selector should start with "select", for example "selectEntity".',
|
|
49
|
+
ngrxModule: 'store',
|
|
50
50
|
},
|
|
51
51
|
schema: [],
|
|
52
52
|
messages: {
|
|
@@ -56,51 +56,147 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
56
56
|
},
|
|
57
57
|
defaultOptions: [],
|
|
58
58
|
create: (context) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
function reportIfInvalid(name, node) {
|
|
60
|
+
// Name starts with select and
|
|
61
|
+
// the first character after select is an uppercase ASCII letter, _, or $
|
|
62
|
+
const isValid = name.startsWith('select') &&
|
|
63
|
+
name.length > 'select'.length &&
|
|
64
|
+
/^[A-Z_$]/.test(name.slice('select'.length));
|
|
65
|
+
if (!isValid) {
|
|
66
|
+
const suggestedName = getSuggestedName(name);
|
|
62
67
|
context.report({
|
|
68
|
+
node,
|
|
63
69
|
loc: {
|
|
64
|
-
|
|
70
|
+
start: node.loc.start,
|
|
65
71
|
end: {
|
|
66
|
-
|
|
67
|
-
column:
|
|
68
|
-
? id.typeAnnotation.range[0] - 1
|
|
69
|
-
: id.loc.end.column,
|
|
72
|
+
line: node.loc.start.line,
|
|
73
|
+
column: node.loc.start.column + name.length,
|
|
70
74
|
},
|
|
71
75
|
},
|
|
72
76
|
messageId: exports.prefixSelectorsWithSelect,
|
|
73
77
|
suggest: [
|
|
74
78
|
{
|
|
75
79
|
messageId: exports.prefixSelectorsWithSelectSuggest,
|
|
76
|
-
data: {
|
|
77
|
-
|
|
80
|
+
data: { name: suggestedName },
|
|
81
|
+
fix: (fixer) => {
|
|
82
|
+
const parent = node.parent;
|
|
83
|
+
const sourceCode = context.getSourceCode();
|
|
84
|
+
// Handle destructuring: { selectAll: allItems }
|
|
85
|
+
if (parent &&
|
|
86
|
+
parent.type === 'Property' &&
|
|
87
|
+
parent.value === node &&
|
|
88
|
+
parent.parent &&
|
|
89
|
+
parent.parent.type === 'ObjectPattern') {
|
|
90
|
+
return fixer.replaceText(node, suggestedName);
|
|
91
|
+
}
|
|
92
|
+
// Handle simple variable declarator: const allItems = ...
|
|
93
|
+
if (parent &&
|
|
94
|
+
parent.type === 'VariableDeclarator' &&
|
|
95
|
+
parent.id.type === 'Identifier') {
|
|
96
|
+
const typeAnnotation = parent.id.typeAnnotation
|
|
97
|
+
? sourceCode.getText(parent.id.typeAnnotation)
|
|
98
|
+
: '';
|
|
99
|
+
return fixer.replaceText(parent.id, `${suggestedName}${typeAnnotation}`);
|
|
100
|
+
}
|
|
101
|
+
// Fallback: just replace the identifier
|
|
102
|
+
return fixer.replaceText(node, suggestedName);
|
|
78
103
|
},
|
|
79
|
-
fix: (fixer) => fixer.replaceTextRange([id.range[0], id.typeAnnotation?.range[0] ?? id.range[1]], suggestedName),
|
|
80
104
|
},
|
|
81
105
|
],
|
|
82
106
|
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function isSelectorFactoryCall(node) {
|
|
110
|
+
const callee = node.callee;
|
|
111
|
+
return (callee.type === 'Identifier' &&
|
|
112
|
+
[
|
|
113
|
+
'createSelector',
|
|
114
|
+
'createFeatureSelector',
|
|
115
|
+
'createSelectorFactory',
|
|
116
|
+
].includes(callee.name));
|
|
117
|
+
}
|
|
118
|
+
function checkFunctionBody(name, node, body) {
|
|
119
|
+
if (body.type === 'CallExpression' && isSelectorFactoryCall(body)) {
|
|
120
|
+
reportIfInvalid(name, node);
|
|
121
|
+
}
|
|
122
|
+
if (body.type === 'BlockStatement') {
|
|
123
|
+
for (const stmt of body.body) {
|
|
124
|
+
if (stmt.type === 'ReturnStatement' &&
|
|
125
|
+
stmt.argument &&
|
|
126
|
+
stmt.argument.type === 'CallExpression' &&
|
|
127
|
+
isSelectorFactoryCall(stmt.argument)) {
|
|
128
|
+
reportIfInvalid(name, node);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
VariableDeclarator(node) {
|
|
135
|
+
const { id, init } = node;
|
|
136
|
+
const isSelectorSource = init?.type === 'CallExpression' &&
|
|
137
|
+
((init.callee.type === 'Identifier' &&
|
|
138
|
+
init.callee.name === 'getSelectors') ||
|
|
139
|
+
(init.callee.type === 'MemberExpression' &&
|
|
140
|
+
init.callee.property.type === 'Identifier' &&
|
|
141
|
+
init.callee.property.name === 'getSelectors'));
|
|
142
|
+
if (id.type === 'ObjectPattern' && isSelectorSource) {
|
|
143
|
+
for (const prop of id.properties) {
|
|
144
|
+
if (prop.type === 'Property' && prop.value.type === 'Identifier') {
|
|
145
|
+
reportIfInvalid(prop.value.name, prop.value);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (id.type === 'Identifier') {
|
|
151
|
+
const typeName = node.id.typeAnnotation?.typeAnnotation.type === 'TSTypeReference' &&
|
|
152
|
+
node.id.typeAnnotation.typeAnnotation.typeName.type === 'Identifier'
|
|
153
|
+
? node.id.typeAnnotation.typeAnnotation.typeName.name
|
|
154
|
+
: null;
|
|
155
|
+
const hasSelectorType = typeName !== null &&
|
|
156
|
+
[
|
|
157
|
+
'MemoizedSelector',
|
|
158
|
+
'MemoizedSelectorWithProps',
|
|
159
|
+
'Selector',
|
|
160
|
+
'SelectorWithProps',
|
|
161
|
+
].includes(typeName);
|
|
162
|
+
const isSelectorCall = init?.type === 'CallExpression' && isSelectorFactoryCall(init);
|
|
163
|
+
const isArrowFunction = init?.type === 'ArrowFunctionExpression' &&
|
|
164
|
+
init.body &&
|
|
165
|
+
(init.body.type === 'CallExpression' ||
|
|
166
|
+
init.body.type === 'BlockStatement');
|
|
167
|
+
const isFunctionExpression = init?.type === 'FunctionExpression' &&
|
|
168
|
+
init.body &&
|
|
169
|
+
init.body.type === 'BlockStatement';
|
|
170
|
+
if (hasSelectorType || isSelectorCall) {
|
|
171
|
+
reportIfInvalid(id.name, id);
|
|
172
|
+
}
|
|
173
|
+
else if (isArrowFunction || isFunctionExpression) {
|
|
174
|
+
checkFunctionBody(id.name, id, init.body);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
83
177
|
},
|
|
84
178
|
};
|
|
85
179
|
},
|
|
86
180
|
});
|
|
87
181
|
function getSuggestedName(name) {
|
|
88
182
|
const selectWord = 'select';
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
183
|
+
if (name.startsWith(selectWord)) {
|
|
184
|
+
const rest = name.slice(selectWord.length);
|
|
185
|
+
if (rest.length === 0) {
|
|
186
|
+
return 'selectSelect';
|
|
187
|
+
}
|
|
188
|
+
if (/^[A-Z_]+$/.test(rest)) {
|
|
189
|
+
return `${selectWord}${rest}`;
|
|
190
|
+
}
|
|
191
|
+
return `${selectWord}${(0, utils_1.capitalize)(rest)}`;
|
|
192
|
+
}
|
|
193
|
+
if (/^get([^a-z].+)/.test(name)) {
|
|
194
|
+
const rest = name.slice(3);
|
|
195
|
+
return `${selectWord}${(0, utils_1.capitalize)(rest)}`;
|
|
95
196
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return `${selectWord}${(0, utils_1.capitalize)(word)}`;
|
|
99
|
-
});
|
|
100
|
-
if (name !== possibleReplacedName) {
|
|
101
|
-
return possibleReplacedName;
|
|
197
|
+
if (/^[A-Z_]+$/.test(name)) {
|
|
198
|
+
return `${selectWord}${name}`;
|
|
102
199
|
}
|
|
103
|
-
// Ex: 'item' => 'selectItem'
|
|
104
200
|
return `${selectWord}${(0, utils_1.capitalize)(name)}`;
|
|
105
201
|
}
|
|
106
202
|
//# sourceMappingURL=prefix-selectors-with-select.js.map
|
|
@@ -1 +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,2CAA6B;AAC7B,qDAAgD;AAChD,uCAAyC;AAE5B,QAAA,yBAAyB,GAAG,2BAA2B,CAAC;AACxD,QAAA,gCAAgC,GAC3C,kCAAkC,CAAC;AAOrC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;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CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,UAAU,GAAG,QAAQ,CAAC;IAC5B,yCAAyC;IACzC,IAAI,oBAAoB,GAAG,IAAI,CAAC,OAAO,CACrC,IAAI,MAAM,CAAC,IAAI,UAAU,MAAM,CAAC,EAChC,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE;QAClB,OAAO,GAAG,UAAU,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;IAC5C,CAAC,CACF,CAAC;IAEF,IAAI,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAClC,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAED,kCAAkC;IAClC,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAAC,EAAE,IAAY,EAAE,EAAE;QACxE,OAAO,GAAG,UAAU,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,IAAI,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAClC,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAED,6BAA6B;IAC7B,OAAO,GAAG,UAAU,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/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 \"selectEntity\".',\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].+$/]:not(:has(Identifier[name=\"createFeature\"])):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]\n ? id.typeAnnotation.range[0] - 1\n : id.loc.end.column,\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"]}
|
|
1
|
+
{"version":3,"file":"prefix-selectors-with-select.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/prefix-selectors-with-select.ts"],"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,IAAI,CAAC,EAAE,CAAC;QAC3B,OAAO,GAAG,UAAU,GAAG,IAAI,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,GAAG,UAAU,GAAG,IAAA,kBAAU,EAAC,IAAI,CAAC,EAAE,CAAC;AAC5C,CAAC","sourcesContent":["import type { TSESTree } from '@typescript-eslint/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 docs: {\n description:\n 'The selector should start with \"select\", for example \"selectEntity\".',\n ngrxModule: 'store',\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 function reportIfInvalid(name: string, node: TSESTree.Identifier) {\n // Name starts with select and\n // the first character after select is an uppercase ASCII letter, _, or $\n const isValid =\n name.startsWith('select') &&\n name.length > 'select'.length &&\n /^[A-Z_$]/.test(name.slice('select'.length));\n\n if (!isValid) {\n const suggestedName = getSuggestedName(name);\n context.report({\n node,\n loc: {\n start: node.loc.start,\n end: {\n line: node.loc.start.line,\n column: node.loc.start.column + name.length,\n },\n },\n messageId: prefixSelectorsWithSelect,\n suggest: [\n {\n messageId: prefixSelectorsWithSelectSuggest,\n data: { name: suggestedName },\n fix: (fixer) => {\n const parent = node.parent;\n const sourceCode = context.getSourceCode();\n\n // Handle destructuring: { selectAll: allItems }\n if (\n parent &&\n parent.type === 'Property' &&\n parent.value === node &&\n parent.parent &&\n parent.parent.type === 'ObjectPattern'\n ) {\n return fixer.replaceText(node, suggestedName);\n }\n\n // Handle simple variable declarator: const allItems = ...\n if (\n parent &&\n parent.type === 'VariableDeclarator' &&\n parent.id.type === 'Identifier'\n ) {\n const typeAnnotation = parent.id.typeAnnotation\n ? sourceCode.getText(parent.id.typeAnnotation)\n : '';\n return fixer.replaceText(\n parent.id,\n `${suggestedName}${typeAnnotation}`\n );\n }\n\n // Fallback: just replace the identifier\n return fixer.replaceText(node, suggestedName);\n },\n },\n ],\n });\n }\n }\n\n function isSelectorFactoryCall(node: TSESTree.CallExpression): boolean {\n const callee = node.callee;\n return (\n callee.type === 'Identifier' &&\n [\n 'createSelector',\n 'createFeatureSelector',\n 'createSelectorFactory',\n ].includes(callee.name)\n );\n }\n\n function checkFunctionBody(\n name: string,\n node: TSESTree.Identifier,\n body: TSESTree.BlockStatement | TSESTree.Expression\n ) {\n if (body.type === 'CallExpression' && isSelectorFactoryCall(body)) {\n reportIfInvalid(name, node);\n }\n\n if (body.type === 'BlockStatement') {\n for (const stmt of body.body) {\n if (\n stmt.type === 'ReturnStatement' &&\n stmt.argument &&\n stmt.argument.type === 'CallExpression' &&\n isSelectorFactoryCall(stmt.argument)\n ) {\n reportIfInvalid(name, node);\n }\n }\n }\n }\n\n return {\n VariableDeclarator(node: TSESTree.VariableDeclarator) {\n const { id, init } = node;\n\n const isSelectorSource =\n init?.type === 'CallExpression' &&\n ((init.callee.type === 'Identifier' &&\n init.callee.name === 'getSelectors') ||\n (init.callee.type === 'MemberExpression' &&\n init.callee.property.type === 'Identifier' &&\n init.callee.property.name === 'getSelectors'));\n\n if (id.type === 'ObjectPattern' && isSelectorSource) {\n for (const prop of id.properties) {\n if (prop.type === 'Property' && prop.value.type === 'Identifier') {\n reportIfInvalid(prop.value.name, prop.value);\n }\n }\n return;\n }\n\n if (id.type === 'Identifier') {\n const typeName =\n node.id.typeAnnotation?.typeAnnotation.type === 'TSTypeReference' &&\n node.id.typeAnnotation.typeAnnotation.typeName.type === 'Identifier'\n ? node.id.typeAnnotation.typeAnnotation.typeName.name\n : null;\n\n const hasSelectorType =\n typeName !== null &&\n [\n 'MemoizedSelector',\n 'MemoizedSelectorWithProps',\n 'Selector',\n 'SelectorWithProps',\n ].includes(typeName);\n\n const isSelectorCall =\n init?.type === 'CallExpression' && isSelectorFactoryCall(init);\n\n const isArrowFunction =\n init?.type === 'ArrowFunctionExpression' &&\n init.body &&\n (init.body.type === 'CallExpression' ||\n init.body.type === 'BlockStatement');\n\n const isFunctionExpression =\n init?.type === 'FunctionExpression' &&\n init.body &&\n init.body.type === 'BlockStatement';\n\n if (hasSelectorType || isSelectorCall) {\n reportIfInvalid(id.name, id);\n } else if (isArrowFunction || isFunctionExpression) {\n checkFunctionBody(id.name, id, init.body);\n }\n }\n },\n };\n },\n});\n\nfunction getSuggestedName(name: string): string {\n const selectWord = 'select';\n\n if (name.startsWith(selectWord)) {\n const rest = name.slice(selectWord.length);\n if (rest.length === 0) {\n return 'selectSelect';\n }\n if (/^[A-Z_]+$/.test(rest)) {\n return `${selectWord}${rest}`;\n }\n return `${selectWord}${capitalize(rest)}`;\n }\n\n if (/^get([^a-z].+)/.test(name)) {\n const rest = name.slice(3);\n return `${selectWord}${capitalize(rest)}`;\n }\n\n if (/^[A-Z_]+$/.test(name)) {\n return `${selectWord}${name}`;\n }\n\n return `${selectWord}${capitalize(name)}`;\n}\n"]}
|
|
@@ -7,5 +7,5 @@ export declare const enum SelectStyle {
|
|
|
7
7
|
}
|
|
8
8
|
type MessageIds = `${SelectStyle}`;
|
|
9
9
|
type Options = readonly [MessageIds];
|
|
10
|
-
declare const _default: TSESLint.RuleModule<"operator" | "method", Options,
|
|
10
|
+
declare const _default: TSESLint.RuleModule<"operator" | "method", Options, import("../../rule-creator").NgRxRuleDocs, TSESLint.RuleListener>;
|
|
11
11
|
export default _default;
|
|
@@ -48,9 +48,9 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
48
48
|
name: path.parse(__filename).name,
|
|
49
49
|
meta: {
|
|
50
50
|
type: 'suggestion',
|
|
51
|
-
ngrxModule: 'store',
|
|
52
51
|
docs: {
|
|
53
52
|
description: 'Selector can be used either with `select` as a pipeable operator or as a method.',
|
|
53
|
+
ngrxModule: 'store',
|
|
54
54
|
},
|
|
55
55
|
fixable: 'code',
|
|
56
56
|
schema: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-style.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/select-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAYqB;AAER,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAE/C,IAAkB,WAGjB;AAHD,WAAkB,WAAW;IAC3B,gCAAiB,CAAA;IACjB,oCAAqB,CAAA;AACvB,CAAC,EAHiB,WAAW,2BAAX,WAAW,QAG5B;AAmBD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,
|
|
1
|
+
{"version":3,"file":"select-style.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/rules/store/select-style.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA6B;AAC7B,qDAAgD;AAChD,uCAYqB;AAER,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAE/C,IAAkB,WAGjB;AAHD,WAAkB,WAAW;IAC3B,gCAAiB,CAAA;IACjB,oCAAqB,CAAA;AACvB,CAAC,EAHiB,WAAW,2BAAX,WAAW,QAG5B;AAmBD,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,C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gB;QAChB,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,YAAY;KAC7C,CAAC;IACF,MAAM,CAAC,EAAE,cAAc,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC;IAC5C,OAAO;QACL,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC;QAC5B,KAAK,CAAC,oBAAoB,CAAC,CAAC,cAAc,EAAE,cAAc,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC;KACtE,CAAC;AACJ,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/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 docs: {\n description:\n 'Selector can be used either with `select` as a pipeable operator or as a method.',\n ngrxModule: 'store',\n },\n fixable: 'code',\n schema: [\n {\n type: 'string',\n enum: [SelectStyle.Method, SelectStyle.Operator],\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 }] = sourceCode.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"]}
|
|
@@ -2,5 +2,5 @@ export declare const useConsistentGlobalStoreName = "useConsistentGlobalStoreNam
|
|
|
2
2
|
export declare const useConsistentGlobalStoreNameSuggest = "useConsistentGlobalStoreNameSuggest";
|
|
3
3
|
type MessageIds = typeof useConsistentGlobalStoreName | typeof useConsistentGlobalStoreNameSuggest;
|
|
4
4
|
type Options = readonly [string];
|
|
5
|
-
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, Options,
|
|
5
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<MessageIds, Options, import("../../rule-creator").NgRxRuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
6
6
|
export default _default;
|
|
@@ -44,9 +44,9 @@ exports.default = (0, rule_creator_1.createRule)({
|
|
|
44
44
|
meta: {
|
|
45
45
|
type: 'suggestion',
|
|
46
46
|
hasSuggestions: true,
|
|
47
|
-
ngrxModule: 'store',
|
|
48
47
|
docs: {
|
|
49
48
|
description: 'Use a consistent name for the global store.',
|
|
49
|
+
ngrxModule: 'store',
|
|
50
50
|
},
|
|
51
51
|
schema: [
|
|
52
52
|
{
|
|
@@ -1 +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,2CAA6B;AAC7B,qDAAgD;AAChD,uCAA4C;AAE/B,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAOxC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,
|
|
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,2CAA6B;AAC7B,qDAAgD;AAChD,uCAA4C;AAE/B,QAAA,4BAA4B,GAAG,8BAA8B,CAAC;AAC9D,QAAA,mCAAmC,GAC9C,qCAAqC,CAAC;AAOxC,kBAAe,IAAA,yBAAU,EAAsB;IAC7C,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,IAAI;IACjC,IAAI,EAAE;QACJ,IAAI,EAAE,YAAY;QAClB,cAAc,EAAE,IAAI;QACpB,IAAI,EAAE;YACJ,WAAW,EAAE,6CAA6C;YAC1D,UAAU,EAAE,OAAO;SACpB;QACD,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,QAAQ;aACf;SACF;QACD,QAAQ,EAAE;YACR,CAAC,oCAA4B,CAAC,EAC5B,oDAAoD;YACtD,CAAC,2CAAmC,CAAC,EAAE,iCAAiC;SACzE;KACF;IACD,cAAc,EAAE,CAAC,OAAO,CAAC;IACzB,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE;QAC/B,OAAO;YACL,OAAO;gBACL,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,IAAA,qBAAa,EAAC,OAAO,CAAC,CAAC;gBAEpD,KAAK,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,cAAc,EAAE,IAAI,WAAW,EAAE,CAAC;oBAC/D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;wBACvB,OAAO;oBACT,CAAC;oBAED,MAAM,IAAI,GAAG,EAAE,SAAS,EAAE,CAAC;oBAC3B,OAAO,CAAC,MAAM,CAAC;wBACb,GAAG,EAAE;4BACH,GAAG,GAAG;4BACN,GAAG,EAAE;gCACH,GAAG,GAAG,CAAC,KAAK;gCACZ,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM;6BACvC;yBACF;wBACD,SAAS,EAAE,oCAA4B;wBACvC,IAAI;wBACJ,OAAO,EAAE;4BACP;gCACE,SAAS,EAAE,2CAAmC;gCAC9C,IAAI;gCACJ,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,CACb,KAAK,CAAC,gBAAgB,CACpB,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,EAChD,SAAS,CACV;6BACJ;yBACF;qBACF,CAAC,CAAC;gBACL,CAAC;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 docs: {\n description: 'Use a consistent name for the global store.',\n ngrxModule: 'store',\n },\n schema: [\n {\n type: 'string',\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] ?? range[1]],\n storeName\n ),\n },\n ],\n });\n }\n },\n };\n },\n});\n"]}
|
|
@@ -14,10 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./docs"), exports);
|
|
18
17
|
__exportStar(require("./folder"), exports);
|
|
19
18
|
__exportStar(require("./guards"), exports);
|
|
20
19
|
__exportStar(require("./ngrx-modules"), exports);
|
|
21
20
|
__exportStar(require("./utils"), exports);
|
|
22
|
-
__exportStar(require("./versions"), exports);
|
|
23
21
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,iDAA+B;AAC/B,0CAAwB","sourcesContent":["export * from './folder';\nexport * from './guards';\nexport * from './ngrx-modules';\nexport * from './utils';\n"]}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const rulesForGenerate: Record<string, NgRxRuleModule<[], string>>;
|
|
1
|
+
export declare const rulesForGenerate: Record<string, import("@typescript-eslint/utils/ts-eslint").RuleModule<string, readonly unknown[], import("../../rule-creator").NgRxRuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>>;
|
|
3
2
|
export declare const configsForGenerate: string[];
|
|
@@ -37,9 +37,7 @@ exports.configsForGenerate = exports.rulesForGenerate = void 0;
|
|
|
37
37
|
const folder_1 = require("./folder");
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const interopRequireDefault = (obj) => obj && obj.__esModule ? obj : { default: obj };
|
|
40
|
-
const importDefault = (moduleName) =>
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-require-imports
|
|
42
|
-
interopRequireDefault(require(moduleName)).default;
|
|
40
|
+
const importDefault = (moduleName) => interopRequireDefault(require(moduleName)).default;
|
|
43
41
|
const rulesDir = path.join(__dirname, '../../rules');
|
|
44
42
|
const configsDir = path.join(__dirname, '../../configs');
|
|
45
43
|
const excludedFiles = ['index'];
|
|
@@ -47,7 +45,10 @@ exports.rulesForGenerate = Array.from((0, folder_1.traverseFolder)(rulesDir, ['.
|
|
|
47
45
|
.filter((rule) => !excludedFiles.includes(rule.file))
|
|
48
46
|
.reduce((allRules, rule) => {
|
|
49
47
|
const ruleModule = importDefault(rule.path);
|
|
50
|
-
ruleModule.meta.
|
|
48
|
+
if (!ruleModule.meta.docs) {
|
|
49
|
+
throw new Error(`Rule ${rule.file} is missing meta.docs information`);
|
|
50
|
+
}
|
|
51
|
+
ruleModule.meta.docs.ngrxModule = path.basename(path.dirname(rule.path));
|
|
51
52
|
return {
|
|
52
53
|
...allRules,
|
|
53
54
|
[rule.file]: ruleModule,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/rules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/rules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAA0C;AAE1C,2CAA6B;AAG7B,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAwB,EAAE,CAC/D,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AAEjD,MAAM,aAAa,GAAG,CAAC,UAAkB,EAAE,EAAE,CAC3C,qBAAqB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC;AAErD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACrD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;AACzD,MAAM,aAAa,GAAG,CAAC,OAAO,CAAC,CAAC;AAEnB,QAAA,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,IAAA,uBAAc,EAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;KAC1E,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACpD,MAAM,CAA2B,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE;IACnD,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAC,IAAI,CAAa,CAAC;IACxD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,CAAC,IAAI,mCAAmC,CAAC,CAAC;IACxE,CAAC;IACD,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,QAAQ,CAC7C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CACT,CAAC;IACjB,OAAO;QACL,GAAG,QAAQ;QACX,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,UAAU;KACxB,CAAC;AACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AAEI,QAAA,kBAAkB,GAAG,KAAK,CAAC,IAAI,CAC1C,IAAA,uBAAc,EAAC,UAAU,EAAE,CAAC,OAAO,CAAC,CAAC,CACtC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import { traverseFolder } from './folder';\nimport { NGRX_MODULE } from './ngrx-modules';\nimport * as path from 'path';\nimport { NgRxRule } from '../../rule-creator';\n\nconst interopRequireDefault = (obj: any): { default: unknown } =>\n obj && obj.__esModule ? obj : { default: obj };\n\nconst importDefault = (moduleName: string) =>\n interopRequireDefault(require(moduleName)).default;\n\nconst rulesDir = path.join(__dirname, '../../rules');\nconst configsDir = path.join(__dirname, '../../configs');\nconst excludedFiles = ['index'];\n\nexport const rulesForGenerate = Array.from(traverseFolder(rulesDir, ['.ts']))\n .filter((rule) => !excludedFiles.includes(rule.file))\n .reduce<Record<string, NgRxRule>>((allRules, rule) => {\n const ruleModule = importDefault(rule.path) as NgRxRule;\n if (!ruleModule.meta.docs) {\n throw new Error(`Rule ${rule.file} is missing meta.docs information`);\n }\n ruleModule.meta.docs.ngrxModule = path.basename(\n path.dirname(rule.path)\n ) as NGRX_MODULE;\n return {\n ...allRules,\n [rule.file]: ruleModule,\n };\n }, {});\n\nexport const configsForGenerate = Array.from(\n traverseFolder(configsDir, ['.json'])\n).map((config) => config.file);\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/utils.ts"],"names":[],"mappings":";;AAyCA,0DAaC;AAED,sEAqBC;AAED,sDAaC;AAwBD,0CA0CC;AAED,gDA2CC;AAED,0DAWC;AAED,4CAUC;AAED,sCASC;AAED,oCAOC;AAED,4DAUC;AAED,0BAEC;AAED,4CAUC;AAED,gCA0BC;AAED,gCAEC;AAgED,oDAQC;AAED,wDAQC;AAED,sCAQC;AAGD,gCAEC;AAED,8BAGC;AAED,gEAKC;AAhaD,oDAAoD;AACpD,qCAkBkB;AAClB,iDAAmD;AAoBnD,SAAgB,uBAAuB,CACrC,EAAE,MAAM,EAAiB,EACzB,SAAiD;IAEjD,OAAO,MAAM,IAAI,CAAC,IAAA,kBAAS,EAAC,MAAM,CAAC,EAAE,CAAC;QACpC,IAAI,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;YACtB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IACzB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,6BAA6B,CAC3C,kBAAyD,EACzD,UAAkB;IAElB,KAAK,MAAM,iBAAiB,IAAI,kBAAkB,EAAE,CAAC;QACnD,MAAM,eAAe,GAAG,iBAAiB,CAAC,UAAU,CAAC,IAAI,CACvD,CAAC,YAAY,EAA4C,EAAE;YACzD,OAAO,CACL,IAAA,0BAAiB,EAAC,YAAY,CAAC;gBAC/B,IAAA,qBAAY,EAAC,YAAY,CAAC,QAAQ,CAAC;g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CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,OAAO,IAAI,MAAM,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,0BAA0B,CACxC,OAAyD;IAEzD,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7D,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/utils';\nimport { ASTUtils } from '@typescript-eslint/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 isTSTypeAnnotation,\n isTSTypeReference,\n isTemplateElement,\n isTemplateLiteral,\n isTSInstantiationExpression,\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 | TSESTree.PropertyDefinition;\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 isIdentifier(importClause.imported) &&\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 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] =\n classImplements && classImplements.length\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 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 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.sourceCode;\n const importDeclarations =\n getImportDeclarations(sourceCode.ast, moduleName) ?? [];\n const { importSpecifier } =\n getImportDeclarationSpecifier(importDeclarations, importName) ?? {};\n\n const injectImportDeclarations =\n getImportDeclarations(sourceCode.ast, '@angular/core') ?? [];\n\n const { importSpecifier: injectImportSpecifier } =\n getImportDeclarationSpecifier(injectImportDeclarations, 'inject') ?? {};\n\n if (!importSpecifier) {\n return { sourceCode };\n }\n\n const variables = sourceCode.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 (!parent) {\n return identifiers;\n }\n\n if (\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 const parentToCheck = isTSInstantiationExpression(parent)\n ? parent.parent\n : parent;\n\n if (\n parentToCheck &&\n isCallExpression(parentToCheck) &&\n isIdentifier(parentToCheck.callee) &&\n parentToCheck.callee.name == 'inject' &&\n parentToCheck.parent &&\n isPropertyDefinition(parentToCheck.parent) &&\n isIdentifier(parentToCheck.parent.key) &&\n injectImportSpecifier\n ) {\n return identifiers.concat(parentToCheck.parent.key 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\nexport function getNgrxComponentStoreNames(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): RegExp | null {\n const { identifiers = [] } = getNgRxComponentStores(context);\n return identifiers.length > 0 ? asPattern(identifiers) : null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../modules/eslint-plugin/src/utils/helper-functions/utils.ts"],"names":[],"mappings":";;AAwCA,0DAaC;AAED,sEAqBC;AAED,sDAaC;AAwBD,0CA0CC;AAED,gDA2CC;AAED,0DAWC;AAED,4CAUC;AAED,sCASC;AAED,oCAOC;AAED,4DAUC;AAED,0BAEC;AAED,4CAUC;AAED,gCA0BC;AAED,gCAEC;AAgED,oDAQC;AAED,wDAQC;AAED,sCAQC;AAGD,gCAEC;AAED,8BAGC;AAED,gEAKC;AA/ZD,oDAAoD;AACpD,qCAkBkB;AAClB,iDAAmD;AAmBnD,SAAgB,uBAAuB,CACrC,EAAE,MAAM,EAAiB,EACzB,SAAiD;IAEjD,OAAO,MAAM,IAAI,CAAC,IAAA,kBAAS,EAAC,MAAM,CAAC,EAAE,CAAC;QACpC,IAAI,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sBAAsB,CACpC,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,iBAAiB,CAAC,EACpC,gBAAgB,CACjB,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CAC3B,OAAyD;IAEzD,OAAO,mCAAmC,CACxC,OAAO,EACP,gCAAiB,CAAC,KAAK,EACvB,OAAO,CACR,CAAC;AACJ,CAAC;AAED,6FAA6F;AAC7F,SAAgB,UAAU,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,SAAS,CAAC,WAAyC;IACjE,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,OAAO,IAAI,MAAM,CAAC,KAAK,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACrD,CAAC;AAED,SAAgB,0BAA0B,CACxC,OAAyD;IAEzD,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7D,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC","sourcesContent":["import type { TSESLint, TSESTree } from '@typescript-eslint/utils';\nimport { ASTUtils } from '@typescript-eslint/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 isTSTypeAnnotation,\n isTSTypeReference,\n isTemplateElement,\n isTemplateLiteral,\n isTSInstantiationExpression,\n} from './guards';\nimport { NGRX_MODULE_PATHS } from './ngrx-modules';\n\ntype ConstructorFunctionExpression = TSESTree.FunctionExpression & {\n parent: TSESTree.MethodDefinition & { kind: 'constructor' };\n};\ntype InjectedParameter = TSESTree.Identifier & {\n typeAnnotation: TSESTree.TSTypeAnnotation;\n parent:\n | ConstructorFunctionExpression\n | (TSESTree.TSParameterProperty & {\n parent: ConstructorFunctionExpression;\n })\n | TSESTree.PropertyDefinition;\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 isIdentifier(importClause.imported) &&\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 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] =\n classImplements && classImplements.length\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 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 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.sourceCode;\n const importDeclarations =\n getImportDeclarations(sourceCode.ast, moduleName) ?? [];\n const { importSpecifier } =\n getImportDeclarationSpecifier(importDeclarations, importName) ?? {};\n\n const injectImportDeclarations =\n getImportDeclarations(sourceCode.ast, '@angular/core') ?? [];\n\n const { importSpecifier: injectImportSpecifier } =\n getImportDeclarationSpecifier(injectImportDeclarations, 'inject') ?? {};\n\n if (!importSpecifier) {\n return { sourceCode };\n }\n\n const variables = sourceCode.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 (!parent) {\n return identifiers;\n }\n\n if (\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 const parentToCheck = isTSInstantiationExpression(parent)\n ? parent.parent\n : parent;\n\n if (\n parentToCheck &&\n isCallExpression(parentToCheck) &&\n isIdentifier(parentToCheck.callee) &&\n parentToCheck.callee.name == 'inject' &&\n parentToCheck.parent &&\n isPropertyDefinition(parentToCheck.parent) &&\n isIdentifier(parentToCheck.parent.key) &&\n injectImportSpecifier\n ) {\n return identifiers.concat(parentToCheck.parent.key 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\nexport function getNgrxComponentStoreNames(\n context: TSESLint.RuleContext<string, readonly unknown[]>\n): RegExp | null {\n const { identifiers = [] } = getNgRxComponentStores(context);\n return identifiers.length > 0 ? asPattern(identifiers) : null;\n}\n"]}
|
package/v9/index.d.ts
CHANGED
|
@@ -5,11 +5,14 @@ declare const meta: {
|
|
|
5
5
|
};
|
|
6
6
|
declare const configs: {
|
|
7
7
|
all: TSESLint.FlatConfig.ConfigArray;
|
|
8
|
+
allTypeChecked: TSESLint.FlatConfig.ConfigArray;
|
|
8
9
|
store: TSESLint.FlatConfig.ConfigArray;
|
|
9
10
|
effects: TSESLint.FlatConfig.ConfigArray;
|
|
11
|
+
effectsTypeChecked: TSESLint.FlatConfig.ConfigArray;
|
|
10
12
|
componentStore: TSESLint.FlatConfig.ConfigArray;
|
|
11
13
|
operators: TSESLint.FlatConfig.ConfigArray;
|
|
12
14
|
signals: TSESLint.FlatConfig.ConfigArray;
|
|
15
|
+
signalsTypeChecked: TSESLint.FlatConfig.ConfigArray;
|
|
13
16
|
};
|
|
14
17
|
declare const _default: {
|
|
15
18
|
meta: {
|
|
@@ -18,11 +21,14 @@ declare const _default: {
|
|
|
18
21
|
};
|
|
19
22
|
configs: {
|
|
20
23
|
all: TSESLint.FlatConfig.ConfigArray;
|
|
24
|
+
allTypeChecked: TSESLint.FlatConfig.ConfigArray;
|
|
21
25
|
store: TSESLint.FlatConfig.ConfigArray;
|
|
22
26
|
effects: TSESLint.FlatConfig.ConfigArray;
|
|
27
|
+
effectsTypeChecked: TSESLint.FlatConfig.ConfigArray;
|
|
23
28
|
componentStore: TSESLint.FlatConfig.ConfigArray;
|
|
24
29
|
operators: TSESLint.FlatConfig.ConfigArray;
|
|
25
30
|
signals: TSESLint.FlatConfig.ConfigArray;
|
|
31
|
+
signalsTypeChecked: TSESLint.FlatConfig.ConfigArray;
|
|
26
32
|
};
|
|
27
33
|
};
|
|
28
34
|
export default _default;
|
package/v9/index.js
CHANGED
|
@@ -13,6 +13,9 @@ const effects_1 = __importDefault(require("../src/configs/effects"));
|
|
|
13
13
|
const component_store_1 = __importDefault(require("../src/configs/component-store"));
|
|
14
14
|
const operators_1 = __importDefault(require("../src/configs/operators"));
|
|
15
15
|
const signals_1 = __importDefault(require("../src/configs/signals"));
|
|
16
|
+
const allTypeChecked_1 = __importDefault(require("../src/configs/allTypeChecked"));
|
|
17
|
+
const effectsTypeChecked_1 = __importDefault(require("../src/configs/effectsTypeChecked"));
|
|
18
|
+
const signalsTypeChecked_1 = __importDefault(require("../src/configs/signalsTypeChecked"));
|
|
16
19
|
const meta = { name: package_json_1.name, version: package_json_1.version };
|
|
17
20
|
exports.meta = meta;
|
|
18
21
|
const tsPlugin = {
|
|
@@ -20,11 +23,14 @@ const tsPlugin = {
|
|
|
20
23
|
};
|
|
21
24
|
const configs = {
|
|
22
25
|
all: (0, all_1.default)(tsPlugin, typescript_eslint_1.parser),
|
|
26
|
+
allTypeChecked: (0, allTypeChecked_1.default)(tsPlugin, typescript_eslint_1.parser),
|
|
23
27
|
store: (0, store_1.default)(tsPlugin, typescript_eslint_1.parser),
|
|
24
28
|
effects: (0, effects_1.default)(tsPlugin, typescript_eslint_1.parser),
|
|
29
|
+
effectsTypeChecked: (0, effectsTypeChecked_1.default)(tsPlugin, typescript_eslint_1.parser),
|
|
25
30
|
componentStore: (0, component_store_1.default)(tsPlugin, typescript_eslint_1.parser),
|
|
26
31
|
operators: (0, operators_1.default)(tsPlugin, typescript_eslint_1.parser),
|
|
27
32
|
signals: (0, signals_1.default)(tsPlugin, typescript_eslint_1.parser),
|
|
33
|
+
signalsTypeChecked: (0, signalsTypeChecked_1.default)(tsPlugin, typescript_eslint_1.parser),
|
|
28
34
|
};
|
|
29
35
|
exports.configs = configs;
|
|
30
36
|
/*
|
package/v9/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/v9/index.ts"],"names":[],"mappings":";;;;;;AACA,yDAA2C;AAC3C,wCAAqC;AACrC,kDAGyB;AACzB,6DAAqC;AACrC,iEAAyC;AACzC,qEAA6C;AAC7C,qFAA4D;AAC5D,yEAAiD;AACjD,qEAA6C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../modules/eslint-plugin/v9/index.ts"],"names":[],"mappings":";;;;;;AACA,yDAA2C;AAC3C,wCAAqC;AACrC,kDAGyB;AACzB,6DAAqC;AACrC,iEAAyC;AACzC,qEAA6C;AAC7C,qFAA4D;AAC5D,yEAAiD;AACjD,qEAA6C;AAC7C,mFAA2D;AAC3D,2FAAmE;AACnE,2FAAmE;AAEnE,MAAM,IAAI,GAAG,EAAE,IAAI,EAAE,mBAAW,EAAE,OAAO,EAAE,sBAAc,EAAE,CAAC;AA0BnD,oBAAI;AAxBb,MAAM,QAAQ,GAA+B;IAC3C,KAAK,EAAL,aAAK;CACN,CAAC;AAEF,MAAM,OAAO,GAAG;IACd,GAAG,EAAE,IAAA,aAAG,EAAC,QAAQ,EAAE,0BAAM,CAAC;IAC1B,cAAc,EAAE,IAAA,wBAAc,EAAC,QAAQ,EAAE,0BAAM,CAAC;IAChD,KAAK,EAAE,IAAA,eAAK,EAAC,QAAQ,EAAE,0BAAM,CAAC;IAC9B,OAAO,EAAE,IAAA,iBAAO,EAAC,QAAQ,EAAE,0BAAM,CAAC;IAClC,kBAAkB,EAAE,IAAA,4BAAkB,EAAC,QAAQ,EAAE,0BAAM,CAAC;IACxD,cAAc,EAAE,IAAA,yBAAc,EAAC,QAAQ,EAAE,0BAAM,CAAC;IAChD,SAAS,EAAE,IAAA,mBAAS,EAAC,QAAQ,EAAE,0BAAM,CAAC;IACtC,OAAO,EAAE,IAAA,iBAAO,EAAC,QAAQ,EAAE,0BAAM,CAAC;IAClC,kBAAkB,EAAE,IAAA,4BAAkB,EAAC,QAAQ,EAAE,0BAAM,CAAC;CACzD,CAAC;AAUa,0BAAO;AARtB;;;EAGE;AACF,kBAAe;IACb,IAAI;IACJ,OAAO;CACR,CAAC","sourcesContent":["import { TSESLint } from '@typescript-eslint/utils';\nimport { parser } from 'typescript-eslint';\nimport { rules } from '../src/rules';\nimport {\n name as packageName,\n version as packageVersion,\n} from '../package.json';\nimport all from '../src/configs/all';\nimport store from '../src/configs/store';\nimport effects from '../src/configs/effects';\nimport componentStore from '../src/configs/component-store';\nimport operators from '../src/configs/operators';\nimport signals from '../src/configs/signals';\nimport allTypeChecked from '../src/configs/allTypeChecked';\nimport effectsTypeChecked from '../src/configs/effectsTypeChecked';\nimport signalsTypeChecked from '../src/configs/signalsTypeChecked';\n\nconst meta = { name: packageName, version: packageVersion };\n\nconst tsPlugin: TSESLint.FlatConfig.Plugin = {\n rules,\n};\n\nconst configs = {\n all: all(tsPlugin, parser),\n allTypeChecked: allTypeChecked(tsPlugin, parser),\n store: store(tsPlugin, parser),\n effects: effects(tsPlugin, parser),\n effectsTypeChecked: effectsTypeChecked(tsPlugin, parser),\n componentStore: componentStore(tsPlugin, parser),\n operators: operators(tsPlugin, parser),\n signals: signals(tsPlugin, parser),\n signalsTypeChecked: signalsTypeChecked(tsPlugin, parser),\n};\n\n/*\nAs the angular-eslint plugin we do both a default and named exports to allow people to use this package from\nboth CJS and ESM in very natural ways.\n*/\nexport default {\n meta,\n configs,\n};\nexport { meta, configs };\n"]}
|
package/jest.config.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
displayName: string;
|
|
3
|
-
preset: string;
|
|
4
|
-
coverageDirectory: string;
|
|
5
|
-
setupFilesAfterEnv: string[];
|
|
6
|
-
transform: {
|
|
7
|
-
'^.+\\.(ts|mjs|js|html)$': (string | {
|
|
8
|
-
tsconfig: string;
|
|
9
|
-
stringifyContentPathRegex: string;
|
|
10
|
-
})[];
|
|
11
|
-
};
|
|
12
|
-
transformIgnorePatterns: string[];
|
|
13
|
-
snapshotSerializers: string[];
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|