@depup/angular-eslint__utils 21.3.1-depup.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.
Files changed (34) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/changes.json +5 -0
  4. package/dist/eslint-plugin/ast-utils.d.ts +161 -0
  5. package/dist/eslint-plugin/ast-utils.d.ts.map +1 -0
  6. package/dist/eslint-plugin/ast-utils.js +465 -0
  7. package/dist/eslint-plugin/comment-utils.d.ts +11 -0
  8. package/dist/eslint-plugin/comment-utils.d.ts.map +1 -0
  9. package/dist/eslint-plugin/comment-utils.js +89 -0
  10. package/dist/eslint-plugin/get-aria-attribute-keys.d.ts +2 -0
  11. package/dist/eslint-plugin/get-aria-attribute-keys.d.ts.map +1 -0
  12. package/dist/eslint-plugin/get-aria-attribute-keys.js +56 -0
  13. package/dist/eslint-plugin/get-native-event-names.d.ts +12 -0
  14. package/dist/eslint-plugin/get-native-event-names.d.ts.map +1 -0
  15. package/dist/eslint-plugin/get-native-event-names.js +200 -0
  16. package/dist/eslint-plugin/rule-fixes.d.ts +17 -0
  17. package/dist/eslint-plugin/rule-fixes.d.ts.map +1 -0
  18. package/dist/eslint-plugin/rule-fixes.js +134 -0
  19. package/dist/eslint-plugin/selector-utils.d.ts +55 -0
  20. package/dist/eslint-plugin/selector-utils.d.ts.map +1 -0
  21. package/dist/eslint-plugin/selector-utils.js +269 -0
  22. package/dist/eslint-plugin/selectors.d.ts +28 -0
  23. package/dist/eslint-plugin/selectors.d.ts.map +1 -0
  24. package/dist/eslint-plugin/selectors.js +48 -0
  25. package/dist/eslint-plugin-template/parser-services.d.ts +13 -0
  26. package/dist/eslint-plugin-template/parser-services.d.ts.map +1 -0
  27. package/dist/eslint-plugin-template/parser-services.js +24 -0
  28. package/dist/index.d.ts +11 -0
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +56 -0
  31. package/dist/utils.d.ts +27 -0
  32. package/dist/utils.d.ts.map +1 -0
  33. package/dist/utils.js +59 -0
  34. package/package.json +61 -0
@@ -0,0 +1,269 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getApplicableConfig = exports.normalizeOptionsToConfigs = exports.isMultipleConfigOption = exports.checkSelector = exports.checkValidOptions = exports.getActualSelectorType = exports.parseSelectorNode = exports.reportTypeError = exports.reportStyleAndPrefixError = exports.reportStyleError = exports.reportSelectorAfterPrefixError = exports.reportPrefixError = exports.SelectorValidator = exports.OPTION_TYPE_ELEMENT = exports.OPTION_TYPE_ATTRS = exports.OPTION_TYPE_ATTRIBUTE = void 0;
4
+ const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-compiler");
5
+ const ast_utils_1 = require("./ast-utils");
6
+ const utils_1 = require("../utils");
7
+ exports.OPTION_TYPE_ATTRIBUTE = 'attribute';
8
+ exports.OPTION_TYPE_ATTRS = 'attrs';
9
+ exports.OPTION_TYPE_ELEMENT = 'element';
10
+ const SELECTOR_TYPE_MAPPER = {
11
+ [exports.OPTION_TYPE_ATTRIBUTE]: exports.OPTION_TYPE_ATTRS,
12
+ [exports.OPTION_TYPE_ELEMENT]: exports.OPTION_TYPE_ELEMENT,
13
+ };
14
+ exports.SelectorValidator = {
15
+ attribute(selector) {
16
+ return selector.length !== 0;
17
+ },
18
+ camelCase(selector) {
19
+ return /^[a-zA-Z0-9[\]]+$/.test(selector);
20
+ },
21
+ element(selector) {
22
+ return selector !== null;
23
+ },
24
+ kebabCase(selector) {
25
+ return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(selector);
26
+ },
27
+ prefixRegex(prefix) {
28
+ return new RegExp(`^\\[?(${prefix})`);
29
+ },
30
+ prefix(prefix, selectorStyle) {
31
+ const regex = this.prefixRegex(prefix);
32
+ return (selector) => {
33
+ if (!prefix)
34
+ return true;
35
+ if (!regex.test(selector))
36
+ return false;
37
+ const selectorAfterPrefix = selector.replace(regex, '');
38
+ if (selectorStyle === ast_utils_1.OPTION_STYLE_CAMEL_CASE) {
39
+ return (!selectorAfterPrefix ||
40
+ selectorAfterPrefix[0] === selectorAfterPrefix[0].toUpperCase());
41
+ }
42
+ else if (selectorStyle === ast_utils_1.OPTION_STYLE_KEBAB_CASE) {
43
+ return !selectorAfterPrefix || selectorAfterPrefix[0] === '-';
44
+ }
45
+ throw Error('Invalid selector style!');
46
+ };
47
+ },
48
+ selectorAfterPrefix(prefix) {
49
+ const regex = this.prefixRegex(prefix);
50
+ return (selector) => {
51
+ const selectorAfterPrefix = selector.replace(regex, '');
52
+ return Boolean(selectorAfterPrefix);
53
+ };
54
+ },
55
+ };
56
+ const getValidSelectors = (selectors, types) => {
57
+ return selectors.reduce((previousValue, currentValue) => {
58
+ const validSelectors = types.reduce((accumulator, type) => {
59
+ const value = currentValue[type];
60
+ return value ? accumulator.concat(value) : accumulator;
61
+ }, []);
62
+ return previousValue.concat(validSelectors);
63
+ }, []);
64
+ };
65
+ const reportPrefixError = (node, prefix, context) => {
66
+ const prefixArray = prefix ? (0, utils_1.arrayify)(prefix) : [];
67
+ context.report({
68
+ node,
69
+ messageId: 'prefixFailure',
70
+ data: {
71
+ prefix: (0, utils_1.toHumanReadableText)(prefixArray),
72
+ },
73
+ });
74
+ };
75
+ exports.reportPrefixError = reportPrefixError;
76
+ const reportSelectorAfterPrefixError = (node, prefix, context) => {
77
+ const prefixArray = prefix ? (0, utils_1.arrayify)(prefix) : [];
78
+ context.report({
79
+ node,
80
+ messageId: 'selectorAfterPrefixFailure',
81
+ data: {
82
+ prefix: (0, utils_1.toHumanReadableText)(prefixArray),
83
+ },
84
+ });
85
+ };
86
+ exports.reportSelectorAfterPrefixError = reportSelectorAfterPrefixError;
87
+ const reportStyleError = (node, style, context) => {
88
+ context.report({
89
+ node,
90
+ messageId: 'styleFailure',
91
+ data: {
92
+ style,
93
+ },
94
+ });
95
+ };
96
+ exports.reportStyleError = reportStyleError;
97
+ const reportStyleAndPrefixError = (node, style, prefix, context) => {
98
+ const prefixArray = prefix ? (0, utils_1.arrayify)(prefix) : [];
99
+ context.report({
100
+ node,
101
+ messageId: 'styleAndPrefixFailure',
102
+ data: {
103
+ style,
104
+ prefix: (0, utils_1.toHumanReadableText)(prefixArray),
105
+ },
106
+ });
107
+ };
108
+ exports.reportStyleAndPrefixError = reportStyleAndPrefixError;
109
+ const reportTypeError = (node, type, context) => {
110
+ context.report({
111
+ node,
112
+ messageId: 'typeFailure',
113
+ data: {
114
+ type,
115
+ },
116
+ });
117
+ };
118
+ exports.reportTypeError = reportTypeError;
119
+ const parseSelectorNode = (node) => {
120
+ if ((0, ast_utils_1.isLiteral)(node)) {
121
+ return bundled_angular_compiler_1.CssSelector.parse(node.raw);
122
+ }
123
+ else if ((0, ast_utils_1.isTemplateLiteral)(node) && node.quasis[0]) {
124
+ return bundled_angular_compiler_1.CssSelector.parse(node.quasis[0].value.raw);
125
+ }
126
+ return null;
127
+ };
128
+ exports.parseSelectorNode = parseSelectorNode;
129
+ const getActualSelectorType = (node) => {
130
+ const listSelectors = (0, exports.parseSelectorNode)(node);
131
+ if (!listSelectors || listSelectors.length === 0) {
132
+ return null;
133
+ }
134
+ // Check the first selector to determine type
135
+ const firstSelector = listSelectors[0];
136
+ // Attribute selectors have attrs populated (e.g., [appFoo])
137
+ // CssSelector.attrs is an array where each attribute is stored as [name, value]
138
+ if (Array.isArray(firstSelector.attrs) && firstSelector.attrs.length > 0) {
139
+ return exports.OPTION_TYPE_ATTRIBUTE;
140
+ }
141
+ // Element selectors have a non-null, non-empty element (e.g., app-foo)
142
+ if (firstSelector.element != null &&
143
+ firstSelector.element !== '' &&
144
+ firstSelector.element !== '*') {
145
+ return exports.OPTION_TYPE_ELEMENT;
146
+ }
147
+ return null;
148
+ };
149
+ exports.getActualSelectorType = getActualSelectorType;
150
+ const checkValidOptions = (type, prefix, style) => {
151
+ // Get options
152
+ const typeOption = (0, utils_1.arrayify)(type);
153
+ const styleOption = style;
154
+ // Check if options are valid
155
+ const isTypeOptionValid = typeOption.length > 0 &&
156
+ typeOption.every((argument) => [exports.OPTION_TYPE_ELEMENT, exports.OPTION_TYPE_ATTRIBUTE].indexOf(argument) !== -1);
157
+ // Prefix is optional - allow undefined, empty string, or empty array
158
+ // If provided, it should be non-empty
159
+ const isPrefixOptionValid = prefix === undefined ||
160
+ prefix === '' ||
161
+ (Array.isArray(prefix) && prefix.length === 0) ||
162
+ prefix.length > 0;
163
+ const isStyleOptionValid = [ast_utils_1.OPTION_STYLE_CAMEL_CASE, ast_utils_1.OPTION_STYLE_KEBAB_CASE].indexOf(styleOption) !==
164
+ -1;
165
+ return isTypeOptionValid && isPrefixOptionValid && isStyleOptionValid;
166
+ };
167
+ exports.checkValidOptions = checkValidOptions;
168
+ const checkSelector = (node, typeOption, prefixOption, styleOption, parsedSelectors) => {
169
+ // Get valid list of selectors
170
+ const types = (0, utils_1.arrayify)(typeOption || [exports.OPTION_TYPE_ATTRS, exports.OPTION_TYPE_ELEMENT]).reduce((previousValue, currentValue) => previousValue.concat(SELECTOR_TYPE_MAPPER[currentValue]), []);
171
+ const styleValidator = styleOption === ast_utils_1.OPTION_STYLE_KEBAB_CASE
172
+ ? exports.SelectorValidator.kebabCase
173
+ : exports.SelectorValidator.camelCase;
174
+ // Use provided parsed selectors or parse them
175
+ const listSelectors = parsedSelectors ?? (0, exports.parseSelectorNode)(node);
176
+ if (!listSelectors) {
177
+ return null;
178
+ }
179
+ const validSelectors = getValidSelectors(listSelectors, types);
180
+ // If no prefix is required (empty or undefined), consider prefix check as passed
181
+ const prefixArray = prefixOption ? (0, utils_1.arrayify)(prefixOption) : [];
182
+ const hasExpectedPrefix = !prefixOption ||
183
+ prefixArray.length === 0 ||
184
+ validSelectors.some((selector) => prefixArray.some((prefix) => exports.SelectorValidator.prefix(prefix, styleOption)(selector)));
185
+ // Style validation should ONLY check if the selector matches the style pattern
186
+ const hasExpectedStyle = validSelectors.some((selector) => styleValidator(selector));
187
+ const hasExpectedType = validSelectors.length > 0;
188
+ // Only check for selector after prefix if prefix is actually required
189
+ const hasSelectorAfterPrefix = !prefixOption ||
190
+ prefixArray.length === 0 ||
191
+ validSelectors.some((selector) => {
192
+ return prefixArray.some((prefix) => {
193
+ return exports.SelectorValidator.selectorAfterPrefix(prefix)(selector);
194
+ });
195
+ });
196
+ return {
197
+ hasExpectedPrefix,
198
+ hasExpectedType,
199
+ hasExpectedStyle,
200
+ hasSelectorAfterPrefix,
201
+ };
202
+ };
203
+ exports.checkSelector = checkSelector;
204
+ // Type guard for multiple configs
205
+ const isMultipleConfigOption = (option) => {
206
+ return (Array.isArray(option) &&
207
+ option.length >= 1 &&
208
+ option.length <= 2 &&
209
+ option.every((config) => typeof config.type === 'string'));
210
+ };
211
+ exports.isMultipleConfigOption = isMultipleConfigOption;
212
+ // Normalize options to a consistent format
213
+ const normalizeOptionsToConfigs = (option) => {
214
+ const configByType = new Map();
215
+ if ((0, exports.isMultipleConfigOption)(option)) {
216
+ // Validate no duplicate types
217
+ const types = option.map((config) => config.type);
218
+ if (new Set(types).size !== types.length) {
219
+ throw new Error('Invalid rule config: Each config object in the options array must have a unique "type" property (either "element" or "attribute")');
220
+ }
221
+ // Build lookup map by type
222
+ for (const config of option) {
223
+ configByType.set(config.type, config);
224
+ }
225
+ }
226
+ else {
227
+ // Single config - normalize to map format
228
+ // Handle both single type and array of types
229
+ const types = (0, utils_1.arrayify)(option.type);
230
+ for (const type of types) {
231
+ configByType.set(type, {
232
+ type,
233
+ prefix: option.prefix,
234
+ style: option.style,
235
+ });
236
+ }
237
+ }
238
+ return configByType;
239
+ };
240
+ exports.normalizeOptionsToConfigs = normalizeOptionsToConfigs;
241
+ /**
242
+ * Get the applicable config for a given selector node
243
+ */
244
+ const getApplicableConfig = (rawSelectors, configByType) => {
245
+ // For multiple configs, determine the actual selector type
246
+ let applicableConfig = null;
247
+ if (configByType.size > 1) {
248
+ // Multiple configs - need to determine which one applies
249
+ const actualType = (0, exports.getActualSelectorType)(rawSelectors);
250
+ if (!actualType) {
251
+ return null;
252
+ }
253
+ const config = configByType.get(actualType);
254
+ if (!config) {
255
+ // No config defined for this selector type
256
+ return null;
257
+ }
258
+ applicableConfig = config;
259
+ }
260
+ else {
261
+ // Single config or single type extracted from array
262
+ const firstEntry = configByType.entries().next();
263
+ if (!firstEntry.done) {
264
+ applicableConfig = firstEntry.value[1];
265
+ }
266
+ }
267
+ return applicableConfig;
268
+ };
269
+ exports.getApplicableConfig = getApplicableConfig;
@@ -0,0 +1,28 @@
1
+ export declare const COMPONENT_OR_DIRECTIVE_CLASS_DECORATOR = "ClassDeclaration > Decorator[expression.callee.name=/^(Component|Directive)$/]";
2
+ export declare const COMPONENT_CLASS_DECORATOR = "ClassDeclaration > Decorator[expression.callee.name=\"Component\"]";
3
+ export declare const DIRECTIVE_CLASS_DECORATOR = "ClassDeclaration > Decorator[expression.callee.name=\"Directive\"]";
4
+ export declare const PIPE_CLASS_DECORATOR = "ClassDeclaration > Decorator[expression.callee.name=\"Pipe\"]";
5
+ export declare const INJECTABLE_CLASS_DECORATOR = "ClassDeclaration > Decorator[expression.callee.name=\"Injectable\"]";
6
+ export declare const MODULE_CLASS_DECORATOR = "ClassDeclaration > Decorator[expression.callee.name=\"NgModule\"]";
7
+ export declare const INPUT_DECORATOR = "Decorator[expression.callee.name=\"Input\"]";
8
+ export declare const OUTPUT_DECORATOR = "Decorator[expression.callee.name=\"Output\"]";
9
+ export declare const HOST_BINDING_DECORATOR = "Decorator[expression.callee.name=\"HostBinding\"]";
10
+ export declare const HOST_LISTENER_DECORATOR = "Decorator[expression.callee.name=\"HostListener\"]";
11
+ export declare const LITERAL_OR_TEMPLATE_ELEMENT = ":matches(Literal, TemplateElement)";
12
+ export declare const ALIAS_PROPERTY_VALUE = "ObjectExpression > Property[key.name='alias'] :matches(Literal, TemplateElement)";
13
+ export declare function decoratorDefinition(decoratorName: RegExp): string;
14
+ export declare function decoratorDefinition<TDecoratorName extends string>(decoratorName: TDecoratorName): `ClassDeclaration:has(Decorator[expression.callee.name=${TDecoratorName}])`;
15
+ export declare function metadataProperty(key: RegExp): string;
16
+ export declare function metadataProperty<TKey extends string>(key: TKey): `Property:matches([key.name=${TKey}][computed=false], [key.value=${TKey}], [key.quasis.0.value.raw=${TKey}])`;
17
+ export declare function methodDefinition(key: RegExp): string;
18
+ export declare function methodDefinition<TKey extends string>(key: TKey): `MethodDefinition:matches([key.name=${TKey}][computed=false], [key.value=${TKey}], [key.quasis.0.value.raw=${TKey}])`;
19
+ export declare const COMPONENT_SELECTOR_LITERAL: string;
20
+ export declare const DIRECTIVE_SELECTOR_LITERAL: string;
21
+ export declare const COMPONENT_OR_DIRECTIVE_SELECTOR_LITERAL: string;
22
+ export declare const INPUTS_METADATA_PROPERTY_LITERAL: string;
23
+ export declare const INPUT_ALIAS: string;
24
+ export declare const INPUT_PROPERTY_OR_SETTER = ":matches(PropertyDefinition, MethodDefinition[kind='set'])[computed=false]:has(Decorator[expression.callee.name=\"Input\"]) > :matches(Identifier, Literal)";
25
+ export declare const OUTPUTS_METADATA_PROPERTY_LITERAL: string;
26
+ export declare const OUTPUT_ALIAS: string;
27
+ export declare const OUTPUT_PROPERTY_OR_GETTER: string;
28
+ //# sourceMappingURL=selectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/eslint-plugin/selectors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sCAAsC,mFAC+B,CAAC;AAEnF,eAAO,MAAM,yBAAyB,uEAC8B,CAAC;AAErE,eAAO,MAAM,yBAAyB,uEAC8B,CAAC;AAErE,eAAO,MAAM,oBAAoB,kEAC8B,CAAC;AAEhE,eAAO,MAAM,0BAA0B,wEAC8B,CAAC;AAEtE,eAAO,MAAM,sBAAsB,sEACgC,CAAC;AAEpE,eAAO,MAAM,eAAe,gDAA8C,CAAC;AAE3E,eAAO,MAAM,gBAAgB,iDAA+C,CAAC;AAE7E,eAAO,MAAM,sBAAsB,sDACgB,CAAC;AACpD,eAAO,MAAM,uBAAuB,uDACgB,CAAC;AAErD,eAAO,MAAM,2BAA2B,uCAAuC,CAAC;AAEhF,eAAO,MAAM,oBAAoB,qFAAiF,CAAC;AAEnH,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAC;AACnE,wBAAgB,mBAAmB,CAAC,cAAc,SAAS,MAAM,EAC/D,aAAa,EAAE,cAAc,GAC5B,yDAAyD,cAAc,IAAI,CAAC;AAK/E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;AACtD,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,GAAG,EAAE,IAAI,GACR,8BAA8B,IAAI,iCAAiC,IAAI,8BAA8B,IAAI,IAAI,CAAC;AAKjH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;AACtD,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,MAAM,EAClD,GAAG,EAAE,IAAI,GACR,sCAAsC,IAAI,iCAAiC,IAAI,8BAA8B,IAAI,IAAI,CAAC;AAKzH,eAAO,MAAM,0BAA0B,QAEL,CAAC;AAEnC,eAAO,MAAM,0BAA0B,QAEL,CAAC;AAEnC,eAAO,MAAM,uCAAuC,QAA2E,CAAC;AAEhI,eAAO,MAAM,gCAAgC,QAEO,CAAC;AAErD,eAAO,MAAM,WAAW,QAMb,CAAC;AAEZ,eAAO,MAAM,wBAAwB,gKAAuI,CAAC;AAE7K,eAAO,MAAM,iCAAiC,QAEM,CAAC;AAErD,eAAO,MAAM,YAAY,QAGd,CAAC;AAEZ,eAAO,MAAM,yBAAyB,QAG3B,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OUTPUT_PROPERTY_OR_GETTER = exports.OUTPUT_ALIAS = exports.OUTPUTS_METADATA_PROPERTY_LITERAL = exports.INPUT_PROPERTY_OR_SETTER = exports.INPUT_ALIAS = exports.INPUTS_METADATA_PROPERTY_LITERAL = exports.COMPONENT_OR_DIRECTIVE_SELECTOR_LITERAL = exports.DIRECTIVE_SELECTOR_LITERAL = exports.COMPONENT_SELECTOR_LITERAL = exports.ALIAS_PROPERTY_VALUE = exports.LITERAL_OR_TEMPLATE_ELEMENT = exports.HOST_LISTENER_DECORATOR = exports.HOST_BINDING_DECORATOR = exports.OUTPUT_DECORATOR = exports.INPUT_DECORATOR = exports.MODULE_CLASS_DECORATOR = exports.INJECTABLE_CLASS_DECORATOR = exports.PIPE_CLASS_DECORATOR = exports.DIRECTIVE_CLASS_DECORATOR = exports.COMPONENT_CLASS_DECORATOR = exports.COMPONENT_OR_DIRECTIVE_CLASS_DECORATOR = void 0;
4
+ exports.decoratorDefinition = decoratorDefinition;
5
+ exports.metadataProperty = metadataProperty;
6
+ exports.methodDefinition = methodDefinition;
7
+ exports.COMPONENT_OR_DIRECTIVE_CLASS_DECORATOR = 'ClassDeclaration > Decorator[expression.callee.name=/^(Component|Directive)$/]';
8
+ exports.COMPONENT_CLASS_DECORATOR = 'ClassDeclaration > Decorator[expression.callee.name="Component"]';
9
+ exports.DIRECTIVE_CLASS_DECORATOR = 'ClassDeclaration > Decorator[expression.callee.name="Directive"]';
10
+ exports.PIPE_CLASS_DECORATOR = 'ClassDeclaration > Decorator[expression.callee.name="Pipe"]';
11
+ exports.INJECTABLE_CLASS_DECORATOR = 'ClassDeclaration > Decorator[expression.callee.name="Injectable"]';
12
+ exports.MODULE_CLASS_DECORATOR = 'ClassDeclaration > Decorator[expression.callee.name="NgModule"]';
13
+ exports.INPUT_DECORATOR = 'Decorator[expression.callee.name="Input"]';
14
+ exports.OUTPUT_DECORATOR = 'Decorator[expression.callee.name="Output"]';
15
+ exports.HOST_BINDING_DECORATOR = 'Decorator[expression.callee.name="HostBinding"]';
16
+ exports.HOST_LISTENER_DECORATOR = 'Decorator[expression.callee.name="HostListener"]';
17
+ exports.LITERAL_OR_TEMPLATE_ELEMENT = ':matches(Literal, TemplateElement)';
18
+ exports.ALIAS_PROPERTY_VALUE = `ObjectExpression > Property[key.name='alias'] ${exports.LITERAL_OR_TEMPLATE_ELEMENT}`;
19
+ function decoratorDefinition(decoratorName) {
20
+ return `ClassDeclaration:has(Decorator[expression.callee.name=${decoratorName}])`;
21
+ }
22
+ function metadataProperty(key) {
23
+ return `Property:matches([key.name=${key}][computed=false], [key.value=${key}], [key.quasis.0.value.raw=${key}])`;
24
+ }
25
+ function methodDefinition(key) {
26
+ return `MethodDefinition:matches([key.name=${key}][computed=false], [key.value=${key}], [key.quasis.0.value.raw=${key}])`;
27
+ }
28
+ exports.COMPONENT_SELECTOR_LITERAL = `${exports.COMPONENT_CLASS_DECORATOR} ${metadataProperty('selector')} ${exports.LITERAL_OR_TEMPLATE_ELEMENT}`;
29
+ exports.DIRECTIVE_SELECTOR_LITERAL = `${exports.DIRECTIVE_CLASS_DECORATOR} ${metadataProperty('selector')} ${exports.LITERAL_OR_TEMPLATE_ELEMENT}`;
30
+ exports.COMPONENT_OR_DIRECTIVE_SELECTOR_LITERAL = `:matches(${exports.COMPONENT_SELECTOR_LITERAL}, ${exports.DIRECTIVE_SELECTOR_LITERAL})`;
31
+ exports.INPUTS_METADATA_PROPERTY_LITERAL = `${exports.COMPONENT_OR_DIRECTIVE_CLASS_DECORATOR} ${metadataProperty('inputs')} > ArrayExpression ${exports.LITERAL_OR_TEMPLATE_ELEMENT}`;
32
+ exports.INPUT_ALIAS = [
33
+ `:matches(PropertyDefinition, MethodDefinition[kind='set']) ${exports.INPUT_DECORATOR} > CallExpression > Literal`,
34
+ `:matches(PropertyDefinition, MethodDefinition[kind='set']) ${exports.INPUT_DECORATOR} > CallExpression > TemplateLiteral > TemplateElement`,
35
+ `:matches(PropertyDefinition, MethodDefinition[kind='set']) ${exports.INPUT_DECORATOR} > CallExpression > ${exports.ALIAS_PROPERTY_VALUE}`,
36
+ `PropertyDefinition > CallExpression[callee.name='input'] > ${exports.ALIAS_PROPERTY_VALUE}`,
37
+ `PropertyDefinition > CallExpression:has(MemberExpression[object.name='input'][property.name='required']) > ${exports.ALIAS_PROPERTY_VALUE}`,
38
+ ].join(',');
39
+ exports.INPUT_PROPERTY_OR_SETTER = `:matches(PropertyDefinition, MethodDefinition[kind='set'])[computed=false]:has(${exports.INPUT_DECORATOR}) > :matches(Identifier, Literal)`;
40
+ exports.OUTPUTS_METADATA_PROPERTY_LITERAL = `${exports.COMPONENT_OR_DIRECTIVE_CLASS_DECORATOR} ${metadataProperty('outputs')} > ArrayExpression ${exports.LITERAL_OR_TEMPLATE_ELEMENT}`;
41
+ exports.OUTPUT_ALIAS = [
42
+ `:matches(PropertyDefinition, MethodDefinition[kind='get']) ${exports.OUTPUT_DECORATOR} ${exports.LITERAL_OR_TEMPLATE_ELEMENT}`,
43
+ `PropertyDefinition > CallExpression[callee.name='output'] > ${exports.ALIAS_PROPERTY_VALUE}`,
44
+ ].join(',');
45
+ exports.OUTPUT_PROPERTY_OR_GETTER = [
46
+ `:matches(PropertyDefinition, MethodDefinition[kind='get'])[computed=false]:has(${exports.OUTPUT_DECORATOR}) > :matches(Identifier, Literal)`,
47
+ `PropertyDefinition[computed=false]:has(CallExpression[callee.name='output']) > :matches(Identifier, Literal)`,
48
+ ].join(',');
@@ -0,0 +1,13 @@
1
+ import type { ParseSourceSpan, TmplAstElement } from '@angular-eslint/bundled-angular-compiler';
2
+ import type { TSESLint, TSESTree } from '@typescript-eslint/utils';
3
+ export interface TemplateParserServices {
4
+ convertNodeSourceSpanToLoc: (sourceSpan: ParseSourceSpan) => TSESTree.SourceLocation;
5
+ convertElementSourceSpanToLoc: (context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>, node: TmplAstElement) => TSESTree.SourceLocation;
6
+ }
7
+ export declare function getTemplateParserServices(context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>): TemplateParserServices;
8
+ /**
9
+ * Utility for rule authors to ensure that their rule is correctly being used with @angular-eslint/template-parser
10
+ * If @angular-eslint/template-parser is not the configured parser when the function is invoked it will throw
11
+ */
12
+ export declare function ensureTemplateParser(context: Readonly<TSESLint.RuleContext<string, readonly unknown[]>>): void;
13
+ //# sourceMappingURL=parser-services.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser-services.d.ts","sourceRoot":"","sources":["../../src/eslint-plugin-template/parser-services.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,cAAc,EACf,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEnE,MAAM,WAAW,sBAAsB;IACrC,0BAA0B,EAAE,CAC1B,UAAU,EAAE,eAAe,KACxB,QAAQ,CAAC,cAAc,CAAC;IAC7B,6BAA6B,EAAE,CAC7B,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,EACnE,IAAI,EAAE,cAAc,KACjB,QAAQ,CAAC,cAAc,CAAC;CAC9B;AAED,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,GAClE,sBAAsB,CAGxB;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,OAAO,EAAE,CAAC,CAAC,GAClE,IAAI,CAgBN"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getTemplateParserServices = getTemplateParserServices;
4
+ exports.ensureTemplateParser = ensureTemplateParser;
5
+ function getTemplateParserServices(context) {
6
+ ensureTemplateParser(context);
7
+ return context.sourceCode.parserServices;
8
+ }
9
+ /**
10
+ * Utility for rule authors to ensure that their rule is correctly being used with @angular-eslint/template-parser
11
+ * If @angular-eslint/template-parser is not the configured parser when the function is invoked it will throw
12
+ */
13
+ function ensureTemplateParser(context) {
14
+ const parserServices = context.sourceCode
15
+ .parserServices;
16
+ if (!parserServices?.convertNodeSourceSpanToLoc ||
17
+ !parserServices?.convertElementSourceSpanToLoc) {
18
+ /**
19
+ * The user needs to have configured "parser" in their eslint config and set it
20
+ * to @angular-eslint/template-parser
21
+ */
22
+ throw new Error("You have used a rule which requires '@angular-eslint/template-parser' to be used as the 'parser' in your ESLint config.");
23
+ }
24
+ }
@@ -0,0 +1,11 @@
1
+ export { toHumanReadableText, arrayify, isNotNullOrUndefined, toPattern, kebabToCamelCase, withoutBracketsAndWhitespaces, capitalize, } from './utils';
2
+ export { getAriaAttributeKeys } from './eslint-plugin/get-aria-attribute-keys';
3
+ export { getNativeEventNames } from './eslint-plugin/get-native-event-names';
4
+ export * as ASTUtils from './eslint-plugin/ast-utils';
5
+ export * as CommentUtils from './eslint-plugin/comment-utils';
6
+ export * as RuleFixes from './eslint-plugin/rule-fixes';
7
+ export * as Selectors from './eslint-plugin/selectors';
8
+ export * as SelectorUtils from './eslint-plugin/selector-utils';
9
+ export type { TemplateParserServices } from './eslint-plugin-template/parser-services';
10
+ export { ensureTemplateParser, getTemplateParserServices, } from './eslint-plugin-template/parser-services';
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,oBAAoB,EACpB,SAAS,EACT,gBAAgB,EAChB,6BAA6B,EAC7B,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAE7E,OAAO,KAAK,QAAQ,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,YAAY,MAAM,+BAA+B,CAAC;AAC9D,OAAO,KAAK,SAAS,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,SAAS,MAAM,2BAA2B,CAAC;AACvD,OAAO,KAAK,aAAa,MAAM,gCAAgC,CAAC;AAEhE,YAAY,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AACvF,OAAO,EACL,oBAAoB,EACpB,yBAAyB,GAC1B,MAAM,0CAA0C,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getTemplateParserServices = exports.ensureTemplateParser = exports.SelectorUtils = exports.Selectors = exports.RuleFixes = exports.CommentUtils = exports.ASTUtils = exports.getNativeEventNames = exports.getAriaAttributeKeys = exports.capitalize = exports.withoutBracketsAndWhitespaces = exports.kebabToCamelCase = exports.toPattern = exports.isNotNullOrUndefined = exports.arrayify = exports.toHumanReadableText = void 0;
37
+ var utils_1 = require("./utils");
38
+ Object.defineProperty(exports, "toHumanReadableText", { enumerable: true, get: function () { return utils_1.toHumanReadableText; } });
39
+ Object.defineProperty(exports, "arrayify", { enumerable: true, get: function () { return utils_1.arrayify; } });
40
+ Object.defineProperty(exports, "isNotNullOrUndefined", { enumerable: true, get: function () { return utils_1.isNotNullOrUndefined; } });
41
+ Object.defineProperty(exports, "toPattern", { enumerable: true, get: function () { return utils_1.toPattern; } });
42
+ Object.defineProperty(exports, "kebabToCamelCase", { enumerable: true, get: function () { return utils_1.kebabToCamelCase; } });
43
+ Object.defineProperty(exports, "withoutBracketsAndWhitespaces", { enumerable: true, get: function () { return utils_1.withoutBracketsAndWhitespaces; } });
44
+ Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return utils_1.capitalize; } });
45
+ var get_aria_attribute_keys_1 = require("./eslint-plugin/get-aria-attribute-keys");
46
+ Object.defineProperty(exports, "getAriaAttributeKeys", { enumerable: true, get: function () { return get_aria_attribute_keys_1.getAriaAttributeKeys; } });
47
+ var get_native_event_names_1 = require("./eslint-plugin/get-native-event-names");
48
+ Object.defineProperty(exports, "getNativeEventNames", { enumerable: true, get: function () { return get_native_event_names_1.getNativeEventNames; } });
49
+ exports.ASTUtils = __importStar(require("./eslint-plugin/ast-utils"));
50
+ exports.CommentUtils = __importStar(require("./eslint-plugin/comment-utils"));
51
+ exports.RuleFixes = __importStar(require("./eslint-plugin/rule-fixes"));
52
+ exports.Selectors = __importStar(require("./eslint-plugin/selectors"));
53
+ exports.SelectorUtils = __importStar(require("./eslint-plugin/selector-utils"));
54
+ var parser_services_1 = require("./eslint-plugin-template/parser-services");
55
+ Object.defineProperty(exports, "ensureTemplateParser", { enumerable: true, get: function () { return parser_services_1.ensureTemplateParser; } });
56
+ Object.defineProperty(exports, "getTemplateParserServices", { enumerable: true, get: function () { return parser_services_1.getTemplateParserServices; } });
@@ -0,0 +1,27 @@
1
+ /**
2
+ * ===============================================================================
3
+ *
4
+ * This file contains general purpose utilities which are not specific to one of
5
+ * the plugins.
6
+ *
7
+ * ===============================================================================
8
+ */
9
+ /**
10
+ * Return the last item of the given array.
11
+ */
12
+ export declare function getLast<T extends readonly unknown[]>(items: T): T[number];
13
+ export declare const objectKeys: <T>(o: T) => readonly Extract<keyof T, string>[];
14
+ /**
15
+ * Enforces the invariant that the input is an array.
16
+ */
17
+ export declare function arrayify<T>(value: T | readonly T[]): readonly T[];
18
+ export declare const isNotNullOrUndefined: <T>(input: null | undefined | T) => input is T;
19
+ export declare const kebabToCamelCase: (value: string) => string;
20
+ /**
21
+ * Convert an array to human-readable text.
22
+ */
23
+ export declare const toHumanReadableText: (items: readonly string[]) => string;
24
+ export declare const toPattern: (value: readonly unknown[]) => RegExp;
25
+ export declare function capitalize<T extends string>(text: T): Capitalize<T>;
26
+ export declare function withoutBracketsAndWhitespaces(text: string): string;
27
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAEzE;AAED,eAAO,MAAM,UAAU,EAAkB,CAAC,CAAC,EACzC,CAAC,EAAE,CAAC,KACD,SAAS,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,CAAC;AAEzC;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAKjE;AAID,eAAO,MAAM,oBAAoB,GAAI,CAAC,EACpC,OAAO,IAAI,GAAG,SAAS,GAAG,CAAC,KAC1B,KAAK,IAAI,CAA0C,CAAC;AAEvD,eAAO,MAAM,gBAAgB,GAAI,OAAO,MAAM,KAAG,MAG9C,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,mBAAmB,GAAI,OAAO,SAAS,MAAM,EAAE,KAAG,MAW9D,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,SAAS,OAAO,EAAE,KAAG,MACpB,CAAC;AAEnC,wBAAgB,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAEnE;AAED,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElE"}
package/dist/utils.js ADDED
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * ===============================================================================
4
+ *
5
+ * This file contains general purpose utilities which are not specific to one of
6
+ * the plugins.
7
+ *
8
+ * ===============================================================================
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.toPattern = exports.toHumanReadableText = exports.kebabToCamelCase = exports.isNotNullOrUndefined = exports.objectKeys = void 0;
12
+ exports.getLast = getLast;
13
+ exports.arrayify = arrayify;
14
+ exports.capitalize = capitalize;
15
+ exports.withoutBracketsAndWhitespaces = withoutBracketsAndWhitespaces;
16
+ /**
17
+ * Return the last item of the given array.
18
+ */
19
+ function getLast(items) {
20
+ return items.slice(-1)[0];
21
+ }
22
+ exports.objectKeys = Object.keys;
23
+ /**
24
+ * Enforces the invariant that the input is an array.
25
+ */
26
+ function arrayify(value) {
27
+ if (Array.isArray(value)) {
28
+ return value;
29
+ }
30
+ return (value ? [value] : []);
31
+ }
32
+ // Needed because in the current Typescript version (TS 3.3.3333), Boolean() cannot be used to perform a null check.
33
+ // For more, see: https://github.com/Microsoft/TypeScript/issues/16655
34
+ const isNotNullOrUndefined = (input) => input !== null && input !== undefined;
35
+ exports.isNotNullOrUndefined = isNotNullOrUndefined;
36
+ const kebabToCamelCase = (value) => value.replace(/-[a-zA-Z]/g, ({ 1: letterAfterDash }) => letterAfterDash.toUpperCase());
37
+ exports.kebabToCamelCase = kebabToCamelCase;
38
+ /**
39
+ * Convert an array to human-readable text.
40
+ */
41
+ const toHumanReadableText = (items) => {
42
+ const itemsLength = items.length;
43
+ if (itemsLength === 1) {
44
+ return `"${items[0]}"`;
45
+ }
46
+ return `${items
47
+ .map((item) => `"${item}"`)
48
+ .slice(0, itemsLength - 1)
49
+ .join(', ')} or "${[...items].pop()}"`;
50
+ };
51
+ exports.toHumanReadableText = toHumanReadableText;
52
+ const toPattern = (value) => RegExp(`^(${value.join('|')})$`);
53
+ exports.toPattern = toPattern;
54
+ function capitalize(text) {
55
+ return `${text[0].toUpperCase()}${text.slice(1)}`;
56
+ }
57
+ function withoutBracketsAndWhitespaces(text) {
58
+ return text.replace(/[[\]\s]/g, '');
59
+ }
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@depup/angular-eslint__utils",
3
+ "version": "21.3.1-depup.0",
4
+ "license": "MIT",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/angular-eslint/angular-eslint.git",
10
+ "directory": "packages/utils"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "!**/*.tsbuildinfo",
15
+ "package.json",
16
+ "README.md",
17
+ "LICENSE",
18
+ "changes.json"
19
+ ],
20
+ "peerDependencies": {
21
+ "@typescript-eslint/utils": "^7.11.0 || ^8.0.0",
22
+ "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0",
23
+ "typescript": "*"
24
+ },
25
+ "dependencies": {
26
+ "@angular-eslint/bundled-angular-compiler": "21.3.1"
27
+ },
28
+ "nx": {
29
+ "namedInputs": {
30
+ "projectSpecificFiles": [
31
+ "{workspaceRoot}/tools/scripts/update-native-event-names.ts"
32
+ ]
33
+ },
34
+ "targets": {
35
+ "update-native-event-names": {
36
+ "outputs": [
37
+ "{projectRoot}/src/eslint-plugin/get-native-event-names"
38
+ ],
39
+ "command": "npx tsx ./tools/scripts/update-native-event-names.ts"
40
+ }
41
+ }
42
+ },
43
+ "gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24",
44
+ "description": "@angular-eslint/utils with all dependencies updated to latest",
45
+ "keywords": [
46
+ "@angular-eslint/utils",
47
+ "depup",
48
+ "updated-dependencies",
49
+ "security",
50
+ "latest",
51
+ "patched"
52
+ ],
53
+ "depup": {
54
+ "changes": {},
55
+ "depsUpdated": 0,
56
+ "originalPackage": "@angular-eslint/utils",
57
+ "originalVersion": "21.3.1",
58
+ "processedAt": "2026-03-22T00:36:55.599Z",
59
+ "smokeTest": "passed"
60
+ }
61
+ }