@angular-eslint/eslint-plugin-template 19.7.0-beta.0 → 19.7.1-alpha.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/dist/index.d.ts +1 -1
- package/dist/rules/click-events-have-key-events.d.ts +6 -2
- package/dist/rules/click-events-have-key-events.d.ts.map +1 -1
- package/dist/rules/click-events-have-key-events.js +44 -5
- package/dist/rules/interactive-supports-focus.js +1 -1
- package/dist/rules/label-has-associated-control.d.ts.map +1 -1
- package/dist/rules/label-has-associated-control.js +6 -4
- package/dist/rules/prefer-template-literal.d.ts.map +1 -1
- package/dist/rules/prefer-template-literal.js +118 -81
- package/dist/utils/is-interactive-element/index.d.ts +1 -1
- package/dist/utils/is-interactive-element/index.d.ts.map +1 -1
- package/dist/utils/is-interactive-element/index.js +2 -2
- package/dist/utils/literal-primitive.d.ts +2 -1
- package/dist/utils/literal-primitive.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/utils/unwrap-parenthesized-expression.d.ts +0 -3
- package/dist/utils/unwrap-parenthesized-expression.d.ts.map +0 -1
- package/dist/utils/unwrap-parenthesized-expression.js +0 -7
package/dist/index.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ declare const _default: {
|
|
|
91
91
|
"attributes-order": import("@typescript-eslint/utils/ts-eslint").RuleModule<"attributesOrder", import("./rules/attributes-order").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
92
92
|
"banana-in-box": import("@typescript-eslint/utils/ts-eslint").RuleModule<"bananaInBox", [], import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
93
93
|
"button-has-type": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/button-has-type").MessageIds, import("./rules/button-has-type").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
94
|
-
"click-events-have-key-events": import("@typescript-eslint/utils/ts-eslint").RuleModule<"clickEventsHaveKeyEvents",
|
|
94
|
+
"click-events-have-key-events": import("@typescript-eslint/utils/ts-eslint").RuleModule<"clickEventsHaveKeyEvents", import("./rules/click-events-have-key-events").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
95
95
|
"conditional-complexity": import("@typescript-eslint/utils/ts-eslint").RuleModule<"conditionalComplexity", import("./rules/conditional-complexity").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
96
96
|
"cyclomatic-complexity": import("@typescript-eslint/utils/ts-eslint").RuleModule<"cyclomaticComplexity", import("./rules/cyclomatic-complexity").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
97
97
|
"elements-content": import("@typescript-eslint/utils/ts-eslint").RuleModule<"elementsContent", import("./rules/elements-content").Options, import("./utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
export type Options = [
|
|
1
|
+
export type Options = [
|
|
2
|
+
{
|
|
3
|
+
readonly ignoreWithDirectives?: string[];
|
|
4
|
+
}
|
|
5
|
+
];
|
|
2
6
|
export type MessageIds = 'clickEventsHaveKeyEvents';
|
|
3
7
|
export declare const RULE_NAME = "click-events-have-key-events";
|
|
4
|
-
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"clickEventsHaveKeyEvents",
|
|
8
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"clickEventsHaveKeyEvents", Options, import("../utils/create-eslint-rule").RuleDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener>;
|
|
5
9
|
export default _default;
|
|
6
10
|
//# sourceMappingURL=click-events-have-key-events.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"click-events-have-key-events.d.ts","sourceRoot":"","sources":["../../src/rules/click-events-have-key-events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"click-events-have-key-events.d.ts","sourceRoot":"","sources":["../../src/rules/click-events-have-key-events.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC1C;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,0BAA0B,CAAC;AACpD,eAAO,MAAM,SAAS,iCAAiC,CAAC;;AAKxD,wBA+EG"}
|
|
@@ -7,7 +7,11 @@ const get_dom_elements_1 = require("../utils/get-dom-elements");
|
|
|
7
7
|
const is_hidden_from_screen_reader_1 = require("../utils/is-hidden-from-screen-reader");
|
|
8
8
|
const is_interactive_element_1 = require("../utils/is-interactive-element");
|
|
9
9
|
const is_presentation_role_1 = require("../utils/is-presentation-role");
|
|
10
|
+
const get_attribute_value_1 = require("../utils/get-attribute-value");
|
|
10
11
|
exports.RULE_NAME = 'click-events-have-key-events';
|
|
12
|
+
const DEFAULT_OPTIONS = {
|
|
13
|
+
ignoreWithDirectives: [],
|
|
14
|
+
};
|
|
11
15
|
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
12
16
|
name: exports.RULE_NAME,
|
|
13
17
|
meta: {
|
|
@@ -15,21 +19,41 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
15
19
|
docs: {
|
|
16
20
|
description: '[Accessibility] Ensures that the click event is accompanied with at least one key event keyup, keydown or keypress.',
|
|
17
21
|
},
|
|
18
|
-
schema: [
|
|
22
|
+
schema: [
|
|
23
|
+
{
|
|
24
|
+
type: 'object',
|
|
25
|
+
properties: {
|
|
26
|
+
ignoreWithDirectives: {
|
|
27
|
+
type: 'array',
|
|
28
|
+
items: { type: 'string' },
|
|
29
|
+
uniqueItems: true,
|
|
30
|
+
default: DEFAULT_OPTIONS.ignoreWithDirectives,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
additionalProperties: false,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
19
36
|
messages: {
|
|
20
37
|
clickEventsHaveKeyEvents: 'click must be accompanied by either keyup, keydown or keypress event for accessibility.',
|
|
21
38
|
},
|
|
22
39
|
},
|
|
23
|
-
defaultOptions: [],
|
|
24
|
-
create(context) {
|
|
40
|
+
defaultOptions: [DEFAULT_OPTIONS],
|
|
41
|
+
create(context, [{ ignoreWithDirectives }]) {
|
|
25
42
|
return {
|
|
26
43
|
Element(node) {
|
|
27
44
|
if (!(0, get_dom_elements_1.getDomElements)().has(node.name)) {
|
|
28
45
|
return;
|
|
29
46
|
}
|
|
30
|
-
if ((
|
|
47
|
+
if (isIgnored(ignoreWithDirectives, node) ||
|
|
48
|
+
(0, is_presentation_role_1.isPresentationRole)(node) ||
|
|
31
49
|
(0, is_hidden_from_screen_reader_1.isHiddenFromScreenReader)(node) ||
|
|
32
|
-
(0, is_interactive_element_1.
|
|
50
|
+
(0, is_interactive_element_1.isInherentlyInteractiveElement)(node)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
// The final case that should be ignored is element which is not inherently interactive, but which has an interactive role.
|
|
54
|
+
// TODO: extend utils with this check (and make it include all interactive roles)
|
|
55
|
+
const role = (0, get_attribute_value_1.getAttributeValue)(node, 'role');
|
|
56
|
+
if (role === 'button') {
|
|
33
57
|
return;
|
|
34
58
|
}
|
|
35
59
|
let hasClick = false, hasKeyEvent = false;
|
|
@@ -54,3 +78,18 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
54
78
|
};
|
|
55
79
|
},
|
|
56
80
|
});
|
|
81
|
+
function isIgnored(ignoreWithDirectives, { inputs, attributes }) {
|
|
82
|
+
if (ignoreWithDirectives && ignoreWithDirectives.length > 0) {
|
|
83
|
+
for (const input of inputs) {
|
|
84
|
+
if (ignoreWithDirectives.includes(input.name)) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const attribute of attributes) {
|
|
89
|
+
if (ignoreWithDirectives.includes(attribute.name)) {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
@@ -61,7 +61,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
61
61
|
const tabIndex = [...node.attributes, ...node.inputs].find((attr) => attr.name === 'tabindex');
|
|
62
62
|
if (interactiveOutput &&
|
|
63
63
|
!tabIndex &&
|
|
64
|
-
!(0, is_interactive_element_1.
|
|
64
|
+
!(0, is_interactive_element_1.isInherentlyInteractiveElement)(node) &&
|
|
65
65
|
!(0, is_interactive_element_1.isNonInteractiveRole)(node) &&
|
|
66
66
|
!(0, is_content_editable_1.isContentEditable)(node)) {
|
|
67
67
|
const parserServices = (0, utils_1.getTemplateParserServices)(context);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label-has-associated-control.d.ts","sourceRoot":"","sources":["../../src/rules/label-has-associated-control.ts"],"names":[],"mappings":"AAQA,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AACF,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QAC/C,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;QACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;KAC7B;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC;AACrD,eAAO,MAAM,SAAS,iCAAiC,CAAC;;AAkBxD,
|
|
1
|
+
{"version":3,"file":"label-has-associated-control.d.ts","sourceRoot":"","sources":["../../src/rules/label-has-associated-control.ts"],"names":[],"mappings":"AAQA,KAAK,cAAc,GAAG;IACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B,CAAC;AACF,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;QAC/C,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;QACrD,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;KAC7B;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,2BAA2B,CAAC;AACrD,eAAO,MAAM,SAAS,iCAAiC,CAAC;;AAkBxD,wBAoHG"}
|
|
@@ -70,10 +70,12 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
70
70
|
...DEFAULT_CONTROL_COMPONENTS,
|
|
71
71
|
...(controlComponents ?? []),
|
|
72
72
|
]);
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
const labelMap = new Map(DEFAULT_LABEL_COMPONENTS.map((comp) => [comp.selector, comp]));
|
|
74
|
+
// Add custom components, overriding defaults with same selector
|
|
75
|
+
if (labelComponents) {
|
|
76
|
+
labelComponents.forEach((comp) => labelMap.set(comp.selector, comp));
|
|
77
|
+
}
|
|
78
|
+
const allLabelComponents = Array.from(labelMap.values());
|
|
77
79
|
let inputItems = [];
|
|
78
80
|
let labelItems = [];
|
|
79
81
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-template-literal.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-template-literal.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prefer-template-literal.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-template-literal.ts"],"names":[],"mappings":"AAgBA,QAAA,MAAM,SAAS,0BAA0B,CAAC;AAE1C,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,OAAO,SAAS,CAAC;AAC1C,eAAO,MAAM,SAAS,4BAA4B,CAAC;;AAEnD,wBA+PG"}
|
|
@@ -34,17 +34,70 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
const { sourceSpan: { start, end }, } = node;
|
|
37
|
+
const parentIsTemplateLiteral = 'parent' in node && node.parent instanceof bundled_angular_compiler_1.TemplateLiteral;
|
|
37
38
|
function getQuote() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return leftValue;
|
|
39
|
+
if (parentIsTemplateLiteral) {
|
|
40
|
+
return '';
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
if (left instanceof bundled_angular_compiler_1.LiteralPrimitive &&
|
|
43
|
+
right instanceof bundled_angular_compiler_1.LiteralPrimitive) {
|
|
44
|
+
const leftValue = sourceCode.text.at(left.sourceSpan.start);
|
|
45
|
+
if (leftValue === "'" || leftValue === '"') {
|
|
46
|
+
return leftValue;
|
|
47
|
+
}
|
|
48
|
+
const rightValue = sourceCode.text.at(right.sourceSpan.start);
|
|
49
|
+
if (rightValue === "'" || rightValue === '"') {
|
|
50
|
+
return rightValue;
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
return '`';
|
|
47
54
|
}
|
|
55
|
+
function getLeftSideFixes(fixer, quote) {
|
|
56
|
+
const { start, end } = left.sourceSpan;
|
|
57
|
+
if (left instanceof bundled_angular_compiler_1.TemplateLiteral) {
|
|
58
|
+
// Remove the end ` sign from the left side
|
|
59
|
+
return [
|
|
60
|
+
fixer.replaceTextRange([start, start + 1], quote),
|
|
61
|
+
fixer.removeRange([end - 1, end]),
|
|
62
|
+
];
|
|
63
|
+
}
|
|
64
|
+
if ((0, literal_primitive_1.isLiteralPrimitive)(left)) {
|
|
65
|
+
// Transform left side to template literal
|
|
66
|
+
return [
|
|
67
|
+
fixer.replaceTextRange([start, end], parentIsTemplateLiteral
|
|
68
|
+
? `${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(left, '`')}`
|
|
69
|
+
: `${quote}${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(left, quote)}`),
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
// Transform left side to template literal
|
|
73
|
+
return [
|
|
74
|
+
fixer.insertTextBeforeRange([start, end], `${quote}\${`),
|
|
75
|
+
fixer.insertTextAfterRange([start, end], '}'),
|
|
76
|
+
];
|
|
77
|
+
}
|
|
78
|
+
function getRightSideFixes(fixer, quote) {
|
|
79
|
+
const { start, end } = right.sourceSpan;
|
|
80
|
+
if (right instanceof bundled_angular_compiler_1.TemplateLiteral) {
|
|
81
|
+
// Remove the start ` sign from the right side
|
|
82
|
+
return [
|
|
83
|
+
fixer.removeRange([start, start + 1]),
|
|
84
|
+
fixer.replaceTextRange([end - 1, end], quote),
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
if ((0, literal_primitive_1.isLiteralPrimitive)(right)) {
|
|
88
|
+
// Transform right side to template literal if it's a string
|
|
89
|
+
return [
|
|
90
|
+
fixer.replaceTextRange([start, end], parentIsTemplateLiteral
|
|
91
|
+
? `${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(right, '`')}`
|
|
92
|
+
: `${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(right, quote)}${quote}`),
|
|
93
|
+
];
|
|
94
|
+
}
|
|
95
|
+
// Transform right side to template literal
|
|
96
|
+
return [
|
|
97
|
+
fixer.insertTextBeforeRange([start, end], '${'),
|
|
98
|
+
fixer.insertTextAfterRange([start, end], `}${quote}`),
|
|
99
|
+
];
|
|
100
|
+
}
|
|
48
101
|
function hasParentheses(node) {
|
|
49
102
|
const { start, end } = node.sourceSpan;
|
|
50
103
|
const text = sourceCode.text.slice(start - 1, end + 1);
|
|
@@ -57,54 +110,74 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
57
110
|
},
|
|
58
111
|
messageId,
|
|
59
112
|
fix: (fixer) => {
|
|
60
|
-
|
|
61
|
-
if (left instanceof bundled_angular_compiler_1.LiteralPrimitive &&
|
|
62
|
-
right instanceof bundled_angular_compiler_1.LiteralPrimitive) {
|
|
63
|
-
const quote = getQuote();
|
|
64
|
-
return fixer.replaceTextRange([start, end], `${quote}${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(left, quote)}${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(right, quote)}${quote}`);
|
|
65
|
-
}
|
|
113
|
+
const quote = getQuote();
|
|
66
114
|
const fixes = Array();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (leftHasParentheses) {
|
|
115
|
+
// If the parent is a template literal, remove the `${` sign
|
|
116
|
+
if (parentIsTemplateLiteral) {
|
|
117
|
+
const templateInterpolationStartIndex = sourceCode.text.lastIndexOf('${', node.sourceSpan.start);
|
|
71
118
|
fixes.push(fixer.removeRange([
|
|
72
|
-
|
|
73
|
-
|
|
119
|
+
templateInterpolationStartIndex,
|
|
120
|
+
node.sourceSpan.start,
|
|
74
121
|
]));
|
|
75
122
|
}
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
left.
|
|
82
|
-
left.sourceSpan.end + 1,
|
|
83
|
-
]));
|
|
123
|
+
// If both sides are literals, we remove the `+` sign, escape if necessary and concatenate them
|
|
124
|
+
if (left instanceof bundled_angular_compiler_1.LiteralPrimitive &&
|
|
125
|
+
right instanceof bundled_angular_compiler_1.LiteralPrimitive) {
|
|
126
|
+
fixes.push(fixer.replaceTextRange([start, end], parentIsTemplateLiteral
|
|
127
|
+
? `${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(left, '`')}${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(right, '`')}`
|
|
128
|
+
: `${quote}${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(left, quote)}${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(right, quote)}${quote}`));
|
|
84
129
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
130
|
+
else {
|
|
131
|
+
const leftHasParentheses = hasParentheses(left);
|
|
132
|
+
const rightHasParentheses = hasParentheses(right);
|
|
133
|
+
// Remove the left first parenthesis if it exists
|
|
134
|
+
if (leftHasParentheses) {
|
|
135
|
+
fixes.push(fixer.removeRange([
|
|
136
|
+
left.sourceSpan.start - 1,
|
|
137
|
+
left.sourceSpan.start,
|
|
138
|
+
]));
|
|
139
|
+
}
|
|
140
|
+
// Fix the left side
|
|
141
|
+
fixes.push(...getLeftSideFixes(fixer, quote));
|
|
142
|
+
// Remove the left last parenthesis if it exists
|
|
143
|
+
if (leftHasParentheses) {
|
|
144
|
+
fixes.push(fixer.removeRange([
|
|
145
|
+
left.sourceSpan.end,
|
|
146
|
+
left.sourceSpan.end + 1,
|
|
147
|
+
]));
|
|
148
|
+
}
|
|
149
|
+
// Remove the `+` sign
|
|
96
150
|
fixes.push(fixer.removeRange([
|
|
97
|
-
|
|
98
|
-
|
|
151
|
+
leftHasParentheses
|
|
152
|
+
? left.sourceSpan.end + 1
|
|
153
|
+
: left.sourceSpan.end,
|
|
154
|
+
rightHasParentheses
|
|
155
|
+
? right.sourceSpan.start - 1
|
|
156
|
+
: right.sourceSpan.start,
|
|
99
157
|
]));
|
|
158
|
+
// Remove the right first parenthesis if it exists
|
|
159
|
+
if (rightHasParentheses) {
|
|
160
|
+
fixes.push(fixer.removeRange([
|
|
161
|
+
right.sourceSpan.start - 1,
|
|
162
|
+
right.sourceSpan.start,
|
|
163
|
+
]));
|
|
164
|
+
}
|
|
165
|
+
// Fix the right side
|
|
166
|
+
fixes.push(...getRightSideFixes(fixer, quote));
|
|
167
|
+
// Remove the right last parenthesis if it exists
|
|
168
|
+
if (rightHasParentheses) {
|
|
169
|
+
fixes.push(fixer.removeRange([
|
|
170
|
+
right.sourceSpan.end,
|
|
171
|
+
right.sourceSpan.end + 1,
|
|
172
|
+
]));
|
|
173
|
+
}
|
|
100
174
|
}
|
|
101
|
-
//
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (rightHasParentheses) {
|
|
175
|
+
// If the parent is a template literal, remove the `}` sign
|
|
176
|
+
if (parentIsTemplateLiteral) {
|
|
177
|
+
const templateInterpolationEndIndex = sourceCode.text.indexOf('}', node.sourceSpan.end);
|
|
105
178
|
fixes.push(fixer.removeRange([
|
|
106
|
-
|
|
107
|
-
|
|
179
|
+
node.sourceSpan.end,
|
|
180
|
+
templateInterpolationEndIndex + 1,
|
|
108
181
|
]));
|
|
109
182
|
}
|
|
110
183
|
return fixes;
|
|
@@ -114,39 +187,3 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
114
187
|
};
|
|
115
188
|
},
|
|
116
189
|
});
|
|
117
|
-
function getLeftSideFixes(fixer, left) {
|
|
118
|
-
const { start, end } = left.sourceSpan;
|
|
119
|
-
if (left instanceof bundled_angular_compiler_1.TemplateLiteral) {
|
|
120
|
-
// Remove the end ` sign from the left side
|
|
121
|
-
return [fixer.removeRange([end - 1, end])];
|
|
122
|
-
}
|
|
123
|
-
if ((0, literal_primitive_1.isLiteralPrimitive)(left)) {
|
|
124
|
-
// Transform left side to template literal
|
|
125
|
-
return [
|
|
126
|
-
fixer.replaceTextRange([start, end], `\`${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(left, '`')}`),
|
|
127
|
-
];
|
|
128
|
-
}
|
|
129
|
-
// Transform left side to template literal
|
|
130
|
-
return [
|
|
131
|
-
fixer.insertTextBeforeRange([start, end], '`${'),
|
|
132
|
-
fixer.insertTextAfterRange([start, end], '}'),
|
|
133
|
-
];
|
|
134
|
-
}
|
|
135
|
-
function getRightSideFixes(fixer, right) {
|
|
136
|
-
const { start, end } = right.sourceSpan;
|
|
137
|
-
if (right instanceof bundled_angular_compiler_1.TemplateLiteral) {
|
|
138
|
-
// Remove the start ` sign from the right side
|
|
139
|
-
return [fixer.removeRange([start, start + 1])];
|
|
140
|
-
}
|
|
141
|
-
if ((0, literal_primitive_1.isLiteralPrimitive)(right)) {
|
|
142
|
-
// Transform right side to template literal if it's a string
|
|
143
|
-
return [
|
|
144
|
-
fixer.replaceTextRange([start, end], `${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(right, '`')}\``),
|
|
145
|
-
];
|
|
146
|
-
}
|
|
147
|
-
// Transform right side to template literal
|
|
148
|
-
return [
|
|
149
|
-
fixer.insertTextBeforeRange([start, end], '${'),
|
|
150
|
-
fixer.insertTextAfterRange([start, end], '}`'),
|
|
151
|
-
];
|
|
152
|
-
}
|
|
@@ -5,6 +5,6 @@ import type { TmplAstElement } from '@angular-eslint/bundled-angular-compiler';
|
|
|
5
5
|
* has a dynamic handler on it and we need to discern whether or not
|
|
6
6
|
* it's intention is to be interacted with on the DOM.
|
|
7
7
|
*/
|
|
8
|
-
export declare function
|
|
8
|
+
export declare function isInherentlyInteractiveElement(node: TmplAstElement): boolean;
|
|
9
9
|
export declare function isNonInteractiveRole(node: TmplAstElement): boolean;
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/is-interactive-element/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAwC/E;;;;;GAKG;AACH,wBAAgB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/is-interactive-element/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAwC/E;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAE5E;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAElE"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isInherentlyInteractiveElement = isInherentlyInteractiveElement;
|
|
4
4
|
exports.isNonInteractiveRole = isNonInteractiveRole;
|
|
5
5
|
const attributes_comparator_1 = require("../attributes-comparator");
|
|
6
6
|
const get_attribute_value_1 = require("../get-attribute-value");
|
|
@@ -36,7 +36,7 @@ function checkIsNonInteractiveRole(node) {
|
|
|
36
36
|
* has a dynamic handler on it and we need to discern whether or not
|
|
37
37
|
* it's intention is to be interacted with on the DOM.
|
|
38
38
|
*/
|
|
39
|
-
function
|
|
39
|
+
function isInherentlyInteractiveElement(node) {
|
|
40
40
|
return (0, get_dom_elements_1.getDomElements)().has(node.name) && checkIsInteractiveElement(node);
|
|
41
41
|
}
|
|
42
42
|
function isNonInteractiveRole(node) {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AST, LiteralPrimitive } from '@angular-eslint/bundled-angular-compiler';
|
|
2
|
+
export type Quote = "'" | '"' | '`';
|
|
2
3
|
export declare function isLiteralPrimitive(node: AST): node is LiteralPrimitive;
|
|
3
4
|
export declare function isStringLiteralPrimitive(node: AST): node is Omit<LiteralPrimitive, 'value'> & {
|
|
4
5
|
value: string;
|
|
5
6
|
};
|
|
6
|
-
export declare function getLiteralPrimitiveStringValue(node: LiteralPrimitive, quote:
|
|
7
|
+
export declare function getLiteralPrimitiveStringValue(node: LiteralPrimitive, quote: Quote): string;
|
|
7
8
|
//# sourceMappingURL=literal-primitive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"literal-primitive.d.ts","sourceRoot":"","sources":["../../src/utils/literal-primitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,gBAAgB,EACjB,MAAM,0CAA0C,CAAC;AAElD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,gBAAgB,CAEtE;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,GAAG,GACR,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAE7D;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"literal-primitive.d.ts","sourceRoot":"","sources":["../../src/utils/literal-primitive.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EACH,gBAAgB,EACjB,MAAM,0CAA0C,CAAC;AAElD,MAAM,MAAM,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAEpC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,IAAI,gBAAgB,CAEtE;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,GAAG,GACR,IAAI,IAAI,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAE7D;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,KAAK,GACX,MAAM,CAIR"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin-template",
|
|
3
|
-
"version": "19.7.
|
|
3
|
+
"version": "19.7.1-alpha.0",
|
|
4
4
|
"description": "ESLint plugin for Angular Templates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"aria-query": "5.3.2",
|
|
22
22
|
"axobject-query": "4.1.0",
|
|
23
|
-
"@angular-eslint/bundled-angular-compiler": "19.7.
|
|
24
|
-
"@angular-eslint/utils": "19.7.
|
|
23
|
+
"@angular-eslint/bundled-angular-compiler": "19.7.1-alpha.0",
|
|
24
|
+
"@angular-eslint/utils": "19.7.1-alpha.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/aria-query": "5.0.4",
|
|
28
|
-
"@angular-eslint/test-utils": "19.7.
|
|
28
|
+
"@angular-eslint/test-utils": "19.7.1-alpha.0"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@typescript-eslint/types": "^7.11.0 || ^8.0.0",
|
|
32
32
|
"@typescript-eslint/utils": "^7.11.0 || ^8.0.0",
|
|
33
33
|
"eslint": "^8.57.0 || ^9.0.0",
|
|
34
34
|
"typescript": "*",
|
|
35
|
-
"@angular-eslint/template-parser": "19.7.
|
|
35
|
+
"@angular-eslint/template-parser": "19.7.1-alpha.0"
|
|
36
36
|
},
|
|
37
37
|
"gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24"
|
|
38
38
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unwrap-parenthesized-expression.d.ts","sourceRoot":"","sources":["../../src/utils/unwrap-parenthesized-expression.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EAET,MAAM,0CAA0C,CAAC;AAElD,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,GAAG,GAAG,GAAG,CAE5D"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unwrapParenthesizedExpression = unwrapParenthesizedExpression;
|
|
4
|
-
const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-compiler");
|
|
5
|
-
function unwrapParenthesizedExpression(node) {
|
|
6
|
-
return node instanceof bundled_angular_compiler_1.ParenthesizedExpression ? node.expression : node;
|
|
7
|
-
}
|