@angular-eslint/eslint-plugin-template 17.3.1-alpha.1 → 17.3.1-alpha.10

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.
@@ -74,7 +74,6 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
74
74
  }
75
75
  return {
76
76
  ['Element$1, Template'](node) {
77
- var _a;
78
77
  if (isImplicitTemplate(node)) {
79
78
  return;
80
79
  }
@@ -96,7 +95,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
96
95
  let errorRange;
97
96
  for (let i = 0; i < sortedAttributes.length; i++) {
98
97
  if (sortedAttributes[i] !== expectedAttributes[i]) {
99
- errorRange = [(_a = errorRange === null || errorRange === void 0 ? void 0 : errorRange[0]) !== null && _a !== void 0 ? _a : i, i];
98
+ errorRange = [errorRange?.[0] ?? i, i];
100
99
  }
101
100
  }
102
101
  if (errorRange) {
@@ -149,12 +148,11 @@ function byLocation(one, other) {
149
148
  }
150
149
  function byOrder(order, alphabetical) {
151
150
  return function (one, other) {
152
- var _a, _b, _c, _d;
153
151
  const orderComparison = getOrderIndex(one, order) - getOrderIndex(other, order);
154
152
  if (alphabetical && orderComparison === 0) {
155
- const oneName = (_b = (_a = one.keySpan) === null || _a === void 0 ? void 0 : _a.details) !== null && _b !== void 0 ? _b : one.name;
153
+ const oneName = one.keySpan?.details ?? one.name;
156
154
  const oneNormalised = oneName.replace(/^i18n-/, '');
157
- const otherName = (_d = (_c = other.keySpan) === null || _c === void 0 ? void 0 : _c.details) !== null && _d !== void 0 ? _d : other.name;
155
+ const otherName = other.keySpan?.details ?? other.name;
158
156
  const otherNormalised = otherName.replace(/^i18n-/, '');
159
157
  if (oneNormalised === otherNormalised) {
160
158
  return /^i18n-/.test(oneName) ? 1 : -1;
@@ -168,33 +166,53 @@ function getOrderIndex(attr, order) {
168
166
  return order.indexOf(attr.orderType);
169
167
  }
170
168
  function toAttributeBindingOrderType(attribute) {
171
- return Object.assign(Object.assign({}, attribute), { orderType: "ATTRIBUTE_BINDING" /* OrderType.AttributeBinding */ });
169
+ return {
170
+ ...attribute,
171
+ orderType: "ATTRIBUTE_BINDING" /* OrderType.AttributeBinding */,
172
+ };
172
173
  }
173
174
  function toInputBindingOrderType(input) {
174
- return Object.assign(Object.assign({}, input), { orderType: "INPUT_BINDING" /* OrderType.InputBinding */ });
175
+ return {
176
+ ...input,
177
+ orderType: "INPUT_BINDING" /* OrderType.InputBinding */,
178
+ };
175
179
  }
176
180
  function toStructuralDirectiveOrderType(attributeOrInput) {
177
- return Object.assign(Object.assign({}, attributeOrInput), { orderType: "STRUCTURAL_DIRECTIVE" /* OrderType.StructuralDirective */ });
181
+ return {
182
+ ...attributeOrInput,
183
+ orderType: "STRUCTURAL_DIRECTIVE" /* OrderType.StructuralDirective */,
184
+ };
178
185
  }
179
186
  function toOutputBindingOrderType(output) {
180
- return Object.assign(Object.assign({}, output), { orderType: "OUTPUT_BINDING" /* OrderType.OutputBinding */ });
187
+ return {
188
+ ...output,
189
+ orderType: "OUTPUT_BINDING" /* OrderType.OutputBinding */,
190
+ };
181
191
  }
182
192
  function toTwoWayBindingOrderType(output) {
183
- return Object.assign(Object.assign({}, output), { orderType: "TWO_WAY_BINDING" /* OrderType.TwoWayBinding */ });
193
+ return {
194
+ ...output,
195
+ orderType: "TWO_WAY_BINDING" /* OrderType.TwoWayBinding */,
196
+ };
184
197
  }
185
198
  function toTemplateReferenceVariableOrderType(reference) {
186
- return Object.assign(Object.assign({}, reference), { orderType: "TEMPLATE_REFERENCE" /* OrderType.TemplateReferenceVariable */ });
199
+ return {
200
+ ...reference,
201
+ orderType: "TEMPLATE_REFERENCE" /* OrderType.TemplateReferenceVariable */,
202
+ };
187
203
  }
188
204
  function isImplicitTemplate(node) {
189
205
  return isTmplAstTemplate(node) && node.tagName !== 'ng-template';
190
206
  }
191
207
  function extractTemplateAttrs(node) {
192
- var _a, _b, _c, _d, _e, _f;
193
208
  if (isTmplAstTemplate(node)) {
194
209
  return node.templateAttrs.map(toStructuralDirectiveOrderType).concat(node.variables.map((x) => {
195
- return Object.assign(Object.assign({}, toAttributeBindingOrderType(x)), {
210
+ return {
211
+ ...toAttributeBindingOrderType(x),
196
212
  // `let-` is excluded from the keySpan and name - add it back in
197
- keySpan: new bundled_angular_compiler_1.ParseSourceSpan(x.keySpan.start.moveBy(-4), x.keySpan.end), name: 'let-' + x.name });
213
+ keySpan: new bundled_angular_compiler_1.ParseSourceSpan(x.keySpan.start.moveBy(-4), x.keySpan.end),
214
+ name: 'let-' + x.name,
215
+ };
198
216
  }));
199
217
  }
200
218
  if (!isImplicitTemplate(node.parent)) {
@@ -207,22 +225,25 @@ function extractTemplateAttrs(node) {
207
225
  * will parsed as two attributes (`ngFor` and `ngForOf`)
208
226
  */
209
227
  const attrs = node.parent.templateAttrs.map(toStructuralDirectiveOrderType);
210
- let keyEnd = (_a = attrs[0].keySpan) === null || _a === void 0 ? void 0 : _a.end;
211
- if (((_b = keyEnd === null || keyEnd === void 0 ? void 0 : keyEnd.getContext(0, 0)) === null || _b === void 0 ? void 0 : _b.after) === '=') {
228
+ let keyEnd = attrs[0].keySpan?.end;
229
+ if (keyEnd?.getContext(0, 0)?.after === '=') {
212
230
  keyEnd = keyEnd.moveBy(1);
213
- const apos = (_c = keyEnd.getContext(0, 0)) === null || _c === void 0 ? void 0 : _c.after;
231
+ const apos = keyEnd.getContext(0, 0)?.after;
214
232
  if (apos === "'" || apos === '"') {
215
233
  do {
216
234
  keyEnd = keyEnd.moveBy(1);
217
- } while (((_d = keyEnd.getContext(0, 0)) === null || _d === void 0 ? void 0 : _d.after) !== apos);
235
+ } while (keyEnd.getContext(0, 0)?.after !== apos);
218
236
  }
219
237
  else {
220
- while (!/[\s>]/.test((_f = (_e = keyEnd.getContext(0, 0)) === null || _e === void 0 ? void 0 : _e.after) !== null && _f !== void 0 ? _f : '')) {
238
+ while (!/[\s>]/.test(keyEnd.getContext(0, 0)?.after ?? '')) {
221
239
  keyEnd = keyEnd.moveBy(1);
222
240
  }
223
241
  }
224
242
  return [
225
- Object.assign(Object.assign({}, attrs[0]), { sourceSpan: new bundled_angular_compiler_1.ParseSourceSpan(attrs[0].sourceSpan.start, keyEnd) }),
243
+ {
244
+ ...attrs[0],
245
+ sourceSpan: new bundled_angular_compiler_1.ParseSourceSpan(attrs[0].sourceSpan.start, keyEnd),
246
+ },
226
247
  ];
227
248
  }
228
249
  return [attrs[0]];
@@ -248,8 +269,7 @@ function isOnSameLocation(input, output) {
248
269
  input.sourceSpan.end === output.sourceSpan.end);
249
270
  }
250
271
  function getMessageName(expected) {
251
- var _a, _b;
252
- const fullName = (_b = (_a = expected.keySpan) === null || _a === void 0 ? void 0 : _a.details) !== null && _b !== void 0 ? _b : expected.name;
272
+ const fullName = expected.keySpan?.details ?? expected.name;
253
273
  switch (expected.orderType) {
254
274
  case "STRUCTURAL_DIRECTIVE" /* OrderType.StructuralDirective */:
255
275
  return `*${fullName}`;
@@ -50,7 +50,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
50
50
  const { attributes, inputs, name: element, sourceSpan } = node;
51
51
  const safelistAttributes = new Set([
52
52
  ...DEFAULT_SAFELIST_ATTRIBUTES,
53
- ...(allowList !== null && allowList !== void 0 ? allowList : []),
53
+ ...(allowList ?? []),
54
54
  ]);
55
55
  const hasAttributeSafelisted = [...attributes, ...inputs]
56
56
  .map(({ name }) => name)
@@ -48,22 +48,27 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
48
48
  actualOperation: operation,
49
49
  expectedOperation: `${operation}=`,
50
50
  };
51
- context.report(Object.assign({ loc: {
51
+ context.report({
52
+ loc: {
52
53
  start: sourceCode.getLocFromIndex(start),
53
54
  end: sourceCode.getLocFromIndex(end),
54
- }, messageId: 'eqeqeq', data }, (isStringNonNumericValue(left) || isStringNonNumericValue(right)
55
- ? {
56
- fix: (fixer) => getFix({ node, right, end, sourceCode, fixer }),
57
- }
58
- : {
59
- suggest: [
60
- {
61
- messageId: 'suggestStrictEquality',
62
- fix: (fixer) => getFix({ node, right, end, sourceCode, fixer }),
63
- data,
64
- },
65
- ],
66
- })));
55
+ },
56
+ messageId: 'eqeqeq',
57
+ data,
58
+ ...(isStringNonNumericValue(left) || isStringNonNumericValue(right)
59
+ ? {
60
+ fix: (fixer) => getFix({ node, right, end, sourceCode, fixer }),
61
+ }
62
+ : {
63
+ suggest: [
64
+ {
65
+ messageId: 'suggestStrictEquality',
66
+ fix: (fixer) => getFix({ node, right, end, sourceCode, fixer }),
67
+ data,
68
+ },
69
+ ],
70
+ }),
71
+ });
67
72
  },
68
73
  };
69
74
  },
@@ -141,7 +141,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
141
141
  : DEFAULT_ALLOWED_BOUND_TEXT_PATTERN;
142
142
  const allowedAttributes = new Set([
143
143
  ...DEFAULT_ALLOWED_ATTRIBUTES,
144
- ...(ignoreAttributes !== null && ignoreAttributes !== void 0 ? ignoreAttributes : []),
144
+ ...(ignoreAttributes ?? []),
145
145
  ]);
146
146
  const allowedTags = new Set(ignoreTags);
147
147
  const collectedCustomIds = new Map();
@@ -153,7 +153,6 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
153
153
  return parent;
154
154
  }
155
155
  function handleElementOrTemplate(node) {
156
- var _a;
157
156
  const { i18n, sourceSpan } = node;
158
157
  const parent = getNextElementOrTemplateParent(node);
159
158
  if (isTagAllowed(allowedTags, node) ||
@@ -171,7 +170,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
171
170
  });
172
171
  }
173
172
  else {
174
- const sourceSpans = (_a = collectedCustomIds.get(customId)) !== null && _a !== void 0 ? _a : [];
173
+ const sourceSpans = collectedCustomIds.get(customId) ?? [];
175
174
  collectedCustomIds.set(customId, [...sourceSpans, sourceSpan]);
176
175
  }
177
176
  }
@@ -189,11 +188,10 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
189
188
  }
190
189
  }
191
190
  function handleTextAttribute({ i18n, keySpan, name: attributeName, parent: { name: elementName }, sourceSpan, value, }) {
192
- var _a;
193
191
  if (allowedTags.has(elementName)) {
194
192
  return;
195
193
  }
196
- const keyOrSourceSpanLoc = parserServices.convertNodeSourceSpanToLoc(keySpan !== null && keySpan !== void 0 ? keySpan : sourceSpan);
194
+ const keyOrSourceSpanLoc = parserServices.convertNodeSourceSpanToLoc(keySpan ?? sourceSpan);
197
195
  if (i18n) {
198
196
  const { customId, description } = i18n;
199
197
  if (checkId) {
@@ -205,7 +203,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
205
203
  });
206
204
  }
207
205
  else {
208
- const sourceSpans = (_a = collectedCustomIds.get(customId)) !== null && _a !== void 0 ? _a : [];
206
+ const sourceSpans = collectedCustomIds.get(customId) ?? [];
209
207
  collectedCustomIds.set(customId, [...sourceSpans, sourceSpan]);
210
208
  }
211
209
  }
@@ -234,7 +232,6 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
234
232
  });
235
233
  }
236
234
  function handleBoundTextOrIcuOrText(node) {
237
- var _a;
238
235
  const { sourceSpan } = node;
239
236
  const parent = getNextElementOrTemplateParent(node);
240
237
  if ((isBoundText(node) &&
@@ -245,9 +242,13 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
245
242
  }
246
243
  const loc = parserServices.convertNodeSourceSpanToLoc(sourceSpan);
247
244
  const fix = (fixer) => getFixForIcuOrText(sourceCode, parserServices, fixer, loc, parent);
248
- context.report(Object.assign({ messageId: 'i18nAttributeOnIcuOrText', loc }, (((_a = parent === null || parent === void 0 ? void 0 : parent.children) === null || _a === void 0 ? void 0 : _a.filter((child) => isElement(child) || isNgTemplate(child)).length)
249
- ? { suggest: [{ messageId: 'suggestAddI18nAttribute', fix }] }
250
- : { fix })));
245
+ context.report({
246
+ messageId: 'i18nAttributeOnIcuOrText',
247
+ loc,
248
+ ...(parent?.children?.filter((child) => isElement(child) || isNgTemplate(child)).length
249
+ ? { suggest: [{ messageId: 'suggestAddI18nAttribute', fix }] }
250
+ : { fix }),
251
+ });
251
252
  }
252
253
  function reportDuplicatedCustomIds() {
253
254
  if (checkDuplicateId) {
@@ -267,24 +268,29 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
267
268
  }
268
269
  collectedCustomIds.clear();
269
270
  }
270
- return Object.assign(Object.assign(Object.assign(Object.assign({}, ((checkId || requireDescription || requireMeaning) && {
271
- ':matches(Element$1, Template[tagName="ng-template"])[i18n]'(node) {
272
- handleElementOrTemplate(node);
273
- },
274
- })), ((checkAttributes ||
275
- checkId ||
276
- requireDescription ||
277
- requireMeaning) && {
278
- [`Element$1 > TextAttribute[value=${PL_PATTERN}]`](node) {
279
- handleTextAttribute(node);
280
- },
281
- })), (checkText && {
282
- [`BoundText, Icu$1, Text$3[value=${PL_PATTERN}]`](node) {
283
- handleBoundTextOrIcuOrText(node);
284
- },
285
- })), { 'Program:exit'() {
271
+ return {
272
+ ...((checkId || requireDescription || requireMeaning) && {
273
+ ':matches(Element$1, Template[tagName="ng-template"])[i18n]'(node) {
274
+ handleElementOrTemplate(node);
275
+ },
276
+ }),
277
+ ...((checkAttributes ||
278
+ checkId ||
279
+ requireDescription ||
280
+ requireMeaning) && {
281
+ [`Element$1 > TextAttribute[value=${PL_PATTERN}]`](node) {
282
+ handleTextAttribute(node);
283
+ },
284
+ }),
285
+ ...(checkText && {
286
+ [`BoundText, Icu$1, Text$3[value=${PL_PATTERN}]`](node) {
287
+ handleBoundTextOrIcuOrText(node);
288
+ },
289
+ }),
290
+ 'Program:exit'() {
286
291
  reportDuplicatedCustomIds();
287
- } });
292
+ },
293
+ };
288
294
  },
289
295
  });
290
296
  function getFixForIcuOrTextWithParent(sourceCode, fixer, { start }, tagName) {
@@ -66,22 +66,21 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
66
66
  const parserServices = (0, utils_1.getTemplateParserServices)(context);
67
67
  const allControlComponents = new Set([
68
68
  ...DEFAULT_CONTROL_COMPONENTS,
69
- ...(controlComponents !== null && controlComponents !== void 0 ? controlComponents : []),
69
+ ...(controlComponents ?? []),
70
70
  ]);
71
71
  const allLabelComponents = [
72
72
  ...DEFAULT_LABEL_COMPONENTS,
73
- ...(labelComponents !== null && labelComponents !== void 0 ? labelComponents : []),
73
+ ...(labelComponents ?? []),
74
74
  ];
75
75
  const labelSelectors = allLabelComponents.map(({ selector }) => selector);
76
76
  const labelComponentsPattern = toPattern(labelSelectors);
77
77
  return {
78
78
  [`Element$1[name=${labelComponentsPattern}]`](node) {
79
- var _a;
80
79
  const element = allLabelComponents.find(({ selector }) => selector === node.name);
81
80
  if (!element)
82
81
  return;
83
82
  const attributesInputs = new Set([...node.attributes, ...node.inputs].map(({ name }) => name));
84
- const hasInput = (_a = element.inputs) === null || _a === void 0 ? void 0 : _a.some((input) => attributesInputs.has(input));
83
+ const hasInput = element.inputs?.some((input) => attributesInputs.has(input));
85
84
  if (hasInput || hasControlComponentIn(allControlComponents, node)) {
86
85
  return;
87
86
  }
@@ -27,13 +27,16 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
27
27
  ["blur" /* KeyEvents.Blur */, "mouseout" /* MouseEvents.MouseOut */],
28
28
  ["focus" /* KeyEvents.Focus */, "mouseover" /* MouseEvents.MouseOver */],
29
29
  ];
30
- return eventPairs.reduce((accumulator, [keyEvent, mouseEvent]) => (Object.assign(Object.assign({}, accumulator), { [`Element$1[name=${domElementsPattern}]:has(BoundEvent[name='${mouseEvent}']):not(:has(BoundEvent[name='${keyEvent}']))`]({ sourceSpan, }) {
30
+ return eventPairs.reduce((accumulator, [keyEvent, mouseEvent]) => ({
31
+ ...accumulator,
32
+ [`Element$1[name=${domElementsPattern}]:has(BoundEvent[name='${mouseEvent}']):not(:has(BoundEvent[name='${keyEvent}']))`]({ sourceSpan, }) {
31
33
  const loc = parserServices.convertNodeSourceSpanToLoc(sourceSpan);
32
34
  context.report({
33
35
  loc,
34
36
  messageId: 'mouseEventsHaveKeyEvents',
35
37
  data: { keyEvent, mouseEvent },
36
38
  });
37
- } })), {});
39
+ },
40
+ }), {});
38
41
  },
39
42
  });
@@ -62,7 +62,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
62
62
  ]);
63
63
  if (allowStylePrecedenceDuplicates) {
64
64
  const inputsIgnored = inputs.filter((input) => angularStylePrecedenceDuplicatesAllowed.includes((0, get_original_attribute_name_1.getOriginalAttributeName)(input)));
65
- if ((inputsIgnored === null || inputsIgnored === void 0 ? void 0 : inputsIgnored.length) > 0) {
65
+ if (inputsIgnored?.length > 0) {
66
66
  const attributesIgnored = attributes.filter((attr) => angularStylePrecedenceDuplicatesAllowed.includes((0, get_original_attribute_name_1.getOriginalAttributeName)(attr)));
67
67
  const inputsNotIgnored = inputs.filter((input) => !inputsIgnored.includes(input));
68
68
  const attributesNotIgnored = attributes.filter((attr) => !attributesIgnored.includes(attr));
@@ -99,5 +99,5 @@ function isNgStyle(name) {
99
99
  return name === 'ngStyle';
100
100
  }
101
101
  function isStyleBound(keySpan) {
102
- return (keySpan === null || keySpan === void 0 ? void 0 : keySpan.details) ? keySpan.details.includes('style.') : false;
102
+ return keySpan?.details ? keySpan.details.includes('style.') : false;
103
103
  }
@@ -62,14 +62,14 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
62
62
  });
63
63
  }
64
64
  function processContentNode(node) {
65
- var _a, _b;
66
65
  const { sourceSpan } = node;
67
66
  const ngContentCloseTag = '</ng-content>';
68
67
  if (sourceSpan.toString().includes(ngContentCloseTag)) {
69
68
  // content nodes can only contain whitespaces
70
- const content = (_b = (_a = sourceSpan
69
+ const content = sourceSpan
71
70
  .toString()
72
- .match(/>(\s*)</m)) === null || _a === void 0 ? void 0 : _a.at(1)) !== null && _b !== void 0 ? _b : '';
71
+ .match(/>(\s*)</m)
72
+ ?.at(1) ?? '';
73
73
  const openingTagLastChar =
74
74
  // This is more than the minimum length of a ng-content element
75
75
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -32,7 +32,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
32
32
  const { attributes, inputs, name: element } = node.parent;
33
33
  const props = [...attributes, ...inputs];
34
34
  const roleDef = aria_query_1.roles.get(role);
35
- const requiredProps = Object.keys((roleDef === null || roleDef === void 0 ? void 0 : roleDef.requiredProps) || {});
35
+ const requiredProps = Object.keys(roleDef?.requiredProps || {});
36
36
  if (!requiredProps.length)
37
37
  return;
38
38
  if ((0, is_semantic_role_element_1.isSemanticRoleElement)(element, role, props))
@@ -59,8 +59,8 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
59
59
  missingProps,
60
60
  },
61
61
  fix: (fixer) => fixer.removeRange([
62
- (sourceSpan === null || sourceSpan === void 0 ? void 0 : sourceSpan.start.offset) - 1,
63
- sourceSpan === null || sourceSpan === void 0 ? void 0 : sourceSpan.end.offset,
62
+ sourceSpan?.start.offset - 1,
63
+ sourceSpan?.end.offset,
64
64
  ]),
65
65
  },
66
66
  ],
@@ -52,8 +52,14 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
52
52
  const { start } = parserServices.convertNodeSourceSpanToLoc(templateAttrs[0].sourceSpan);
53
53
  const { end } = parserServices.convertNodeSourceSpanToLoc(templateAttrs[templateAttrs.length - 1].sourceSpan);
54
54
  const loc = {
55
- start: Object.assign(Object.assign({}, start), { column: start.column - 1 }),
56
- end: Object.assign(Object.assign({}, end), { column: end.column + 1 }),
55
+ start: {
56
+ ...start,
57
+ column: start.column - 1,
58
+ },
59
+ end: {
60
+ ...end,
61
+ column: end.column + 1,
62
+ },
57
63
  };
58
64
  context.report({
59
65
  messageId: 'useTrackByFunction',
@@ -125,7 +125,7 @@ function isValidAriaPropertyValue({ allowundefined, type, values }, attributeVal
125
125
  const parsedAttributeValue = isBooleanLike(attributeValue)
126
126
  ? JSON.parse(attributeValue)
127
127
  : attributeValue;
128
- return Boolean(values === null || values === void 0 ? void 0 : values.includes(parsedAttributeValue));
128
+ return Boolean(values?.includes(parsedAttributeValue));
129
129
  }
130
130
  }
131
131
  }
@@ -16,10 +16,10 @@ const get_original_attribute_name_1 = require("./get-original-attribute-name");
16
16
  */
17
17
  function getAttributeValue({ attributes, inputs }, attributeName) {
18
18
  const attributeOrInput = [...attributes, ...inputs].find((attrOrInput) => (0, get_original_attribute_name_1.getOriginalAttributeName)(attrOrInput) === attributeName);
19
- if (typeof (attributeOrInput === null || attributeOrInput === void 0 ? void 0 : attributeOrInput.value) === 'string') {
19
+ if (typeof attributeOrInput?.value === 'string') {
20
20
  return attributeOrInput.value;
21
21
  }
22
- if (!((attributeOrInput === null || attributeOrInput === void 0 ? void 0 : attributeOrInput.value) instanceof bundled_angular_compiler_1.ASTWithSource)) {
22
+ if (!(attributeOrInput?.value instanceof bundled_angular_compiler_1.ASTWithSource)) {
23
23
  return null;
24
24
  }
25
25
  if (attributeOrInput.value.ast instanceof bundled_angular_compiler_1.LiteralArray) {
@@ -4,6 +4,6 @@ exports.getDomElements = void 0;
4
4
  const aria_query_1 = require("aria-query");
5
5
  let domElements = null;
6
6
  function getDomElements() {
7
- return domElements !== null && domElements !== void 0 ? domElements : (domElements = new Set(aria_query_1.dom.keys()));
7
+ return domElements ?? (domElements = new Set(aria_query_1.dom.keys()));
8
8
  }
9
9
  exports.getDomElements = getDomElements;
@@ -13,8 +13,7 @@ const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-comp
13
13
  * ```
14
14
  */
15
15
  function getOriginalAttributeName(attribute) {
16
- var _a;
17
- const { details } = (_a = attribute.keySpan) !== null && _a !== void 0 ? _a : {};
16
+ const { details } = attribute.keySpan ?? {};
18
17
  if (!details) {
19
18
  return attribute.name;
20
19
  }
@@ -20,7 +20,8 @@ function getInteractiveElementAXObjectSchemas() {
20
20
  return accumulator.concat([...AXObjectSet].every((role) => interactiveAXObjects.has(role))
21
21
  ? // summary element should not have required attributes
22
22
  elementSchema.name === 'summary'
23
- ? Object.assign(Object.assign({}, elementSchema), { attributes: [] }) : elementSchema
23
+ ? { ...elementSchema, attributes: [] }
24
+ : elementSchema
24
25
  : []);
25
26
  }, []);
26
27
  }
@@ -9,7 +9,7 @@ const get_interactive_element_role_schemas_1 = require("./get-interactive-elemen
9
9
  const get_non_interactive_element_role_schemas_1 = require("./get-non-interactive-element-role-schemas");
10
10
  function checkIsInteractiveElement(node) {
11
11
  function elementSchemaMatcher({ attributes, name }) {
12
- return node.name === name && (0, attributes_comparator_1.attributesComparator)(attributes !== null && attributes !== void 0 ? attributes : [], node);
12
+ return node.name === name && (0, attributes_comparator_1.attributesComparator)(attributes ?? [], node);
13
13
  }
14
14
  // Check in elementRoles for inherent interactive role associations for
15
15
  // this element.
@@ -9,7 +9,6 @@ let axRoles = null;
9
9
  // initialize the `nonInteractiveElementRoleSchemas` until the function is called
10
10
  // for the first time, so we will not take up the memory.
11
11
  function isSemanticRoleElement(element, role, elementAttributes) {
12
- var _a;
13
12
  if (axElements === null || axRoles === null) {
14
13
  // eslint-disable-next-line @typescript-eslint/no-var-requires
15
14
  const { AXObjectRoles, elementAXObjects } = require('axobject-query');
@@ -17,20 +16,16 @@ function isSemanticRoleElement(element, role, elementAttributes) {
17
16
  axRoles = AXObjectRoles;
18
17
  }
19
18
  // elementAXObjects: HTML elements are mapped to their related AXConcepts concepts
20
- return Array.from((_a = axElements === null || axElements === void 0 ? void 0 : axElements.keys()) !== null && _a !== void 0 ? _a : []).some((htmlElement) => {
21
- var _a, _b;
22
- return htmlElement.name === element &&
23
- ((_a = htmlElement.attributes) !== null && _a !== void 0 ? _a : []).every((htmlElemAttr) =>
24
- // match every axElement html attributes to given elementAttributes
25
- elementAttributes.find((elemAttr) => htmlElemAttr.name === elemAttr.name &&
26
- htmlElemAttr.value === elemAttr.value)) &&
27
- (
28
- // aria- properties are covered by the element's semantic role
29
- (_b = axElements === null || axElements === void 0 ? void 0 : axElements.get(htmlElement)) === null || _b === void 0 ? void 0 : _b.find((roleName) => {
30
- var _a;
31
- // AXObjectRoles: AXObjects are mapped to their related ARIA concepts
32
- return (_a = axRoles === null || axRoles === void 0 ? void 0 : axRoles.get(roleName)) === null || _a === void 0 ? void 0 : _a.find((semanticRole) => semanticRole.name === role);
33
- }));
34
- });
19
+ return Array.from(axElements?.keys() ?? []).some((htmlElement) => htmlElement.name === element &&
20
+ (htmlElement.attributes ?? []).every((htmlElemAttr) =>
21
+ // match every axElement html attributes to given elementAttributes
22
+ elementAttributes.find((elemAttr) => htmlElemAttr.name === elemAttr.name &&
23
+ htmlElemAttr.value === elemAttr.value)) &&
24
+ // aria- properties are covered by the element's semantic role
25
+ axElements?.get(htmlElement)?.find((roleName) =>
26
+ // AXObjectRoles: AXObjects are mapped to their related ARIA concepts
27
+ axRoles
28
+ ?.get(roleName)
29
+ ?.find((semanticRole) => semanticRole.name === role)));
35
30
  }
36
31
  exports.isSemanticRoleElement = isSemanticRoleElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin-template",
3
- "version": "17.3.1-alpha.1",
3
+ "version": "17.3.1-alpha.10",
4
4
  "description": "ESLint plugin for Angular Templates",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -17,10 +17,10 @@
17
17
  "LICENSE"
18
18
  ],
19
19
  "dependencies": {
20
- "@angular-eslint/bundled-angular-compiler": "17.3.1-alpha.1",
21
- "@angular-eslint/utils": "17.3.1-alpha.1",
22
- "@typescript-eslint/type-utils": "7.2.0",
23
- "@typescript-eslint/utils": "7.2.0",
20
+ "@angular-eslint/bundled-angular-compiler": "17.3.1-alpha.10",
21
+ "@angular-eslint/utils": "17.3.1-alpha.10",
22
+ "@typescript-eslint/type-utils": "7.7.0",
23
+ "@typescript-eslint/utils": "7.7.0",
24
24
  "aria-query": "5.3.0",
25
25
  "axobject-query": "4.0.0"
26
26
  },