@angular-eslint/eslint-plugin-template 19.6.1-alpha.3 → 20.0.0-alpha.1
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/rules/conditional-complexity.d.ts.map +1 -1
- package/dist/rules/conditional-complexity.js +9 -3
- package/dist/rules/no-negated-async.d.ts.map +1 -1
- package/dist/rules/no-negated-async.js +22 -15
- package/dist/rules/prefer-contextual-for-variables.d.ts.map +1 -1
- package/dist/rules/prefer-contextual-for-variables.js +19 -15
- package/dist/rules/prefer-template-literal.d.ts.map +1 -1
- package/dist/rules/prefer-template-literal.js +69 -43
- package/dist/utils/unwrap-parenthesized-expression.d.ts +3 -0
- package/dist/utils/unwrap-parenthesized-expression.d.ts.map +1 -0
- package/dist/utils/unwrap-parenthesized-expression.js +7 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conditional-complexity.d.ts","sourceRoot":"","sources":["../../src/rules/conditional-complexity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conditional-complexity.d.ts","sourceRoot":"","sources":["../../src/rules/conditional-complexity.ts"],"names":[],"mappings":"AAiBA,MAAM,MAAM,OAAO,GAAG,CAAC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAClD,MAAM,MAAM,UAAU,GAAG,uBAAuB,CAAC;AACjD,eAAO,MAAM,SAAS,2BAA2B,CAAC;;AAIlD,wBAkFG"}
|
|
@@ -4,6 +4,7 @@ exports.RULE_NAME = void 0;
|
|
|
4
4
|
const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-compiler");
|
|
5
5
|
const utils_1 = require("@angular-eslint/utils");
|
|
6
6
|
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
7
|
+
const unwrap_parenthesized_expression_1 = require("../utils/unwrap-parenthesized-expression");
|
|
7
8
|
exports.RULE_NAME = 'conditional-complexity';
|
|
8
9
|
const DEFAULT_MAX_COMPLEXITY = 5;
|
|
9
10
|
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
@@ -74,7 +75,8 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
74
75
|
},
|
|
75
76
|
});
|
|
76
77
|
function extractPossibleBinaryOrConditionalFrom(node) {
|
|
77
|
-
|
|
78
|
+
const unwrapped = (0, unwrap_parenthesized_expression_1.unwrapParenthesizedExpression)(node);
|
|
79
|
+
return unwrapped instanceof bundled_angular_compiler_1.BindingPipe ? unwrapped.exp : unwrapped;
|
|
78
80
|
}
|
|
79
81
|
let parser = null;
|
|
80
82
|
// Instantiate the `Parser` class lazily only when this rule is applied.
|
|
@@ -89,10 +91,14 @@ function getTotalComplexity(ast) {
|
|
|
89
91
|
}
|
|
90
92
|
let total = 1;
|
|
91
93
|
if (possibleBinaryOrConditional instanceof bundled_angular_compiler_1.Binary) {
|
|
92
|
-
|
|
94
|
+
const leftUnwrapped = (0, unwrap_parenthesized_expression_1.unwrapParenthesizedExpression)(possibleBinaryOrConditional.left);
|
|
95
|
+
const rightUnwrapped = (0, unwrap_parenthesized_expression_1.unwrapParenthesizedExpression)(possibleBinaryOrConditional.right);
|
|
96
|
+
if (leftUnwrapped instanceof bundled_angular_compiler_1.Binary ||
|
|
97
|
+
leftUnwrapped instanceof bundled_angular_compiler_1.Conditional) {
|
|
93
98
|
total += getTotalComplexity(possibleBinaryOrConditional.left);
|
|
94
99
|
}
|
|
95
|
-
if (
|
|
100
|
+
if (rightUnwrapped instanceof bundled_angular_compiler_1.Binary ||
|
|
101
|
+
rightUnwrapped instanceof bundled_angular_compiler_1.Conditional) {
|
|
96
102
|
total += getTotalComplexity(possibleBinaryOrConditional.right);
|
|
97
103
|
}
|
|
98
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-negated-async.d.ts","sourceRoot":"","sources":["../../src/rules/no-negated-async.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,wBAAwB,GACxB,wBAAwB,GACxB,uBAAuB,GACvB,4BAA4B,GAC5B,6BAA6B,CAAC;AAClC,eAAO,MAAM,SAAS,qBAAqB,CAAC;;AAE5C,
|
|
1
|
+
{"version":3,"file":"no-negated-async.d.ts","sourceRoot":"","sources":["../../src/rules/no-negated-async.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAClB,gBAAgB,GAChB,wBAAwB,GACxB,wBAAwB,GACxB,uBAAuB,GACvB,4BAA4B,GAC5B,6BAA6B,CAAC;AAClC,eAAO,MAAM,SAAS,qBAAqB,CAAC;;AAE5C,wBAmFG;AAEH,eAAO,MAAM,mBAAmB;;CAE/B,CAAC"}
|
|
@@ -28,6 +28,23 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
28
28
|
create(context) {
|
|
29
29
|
(0, utils_1.ensureTemplateParser)(context);
|
|
30
30
|
const sourceCode = context.sourceCode;
|
|
31
|
+
function reportNegatedAsync(prefixNotNode) {
|
|
32
|
+
const { start, end } = prefixNotNode.sourceSpan;
|
|
33
|
+
context.report({
|
|
34
|
+
messageId: 'noNegatedAsync',
|
|
35
|
+
loc: {
|
|
36
|
+
start: sourceCode.getLocFromIndex(start),
|
|
37
|
+
end: sourceCode.getLocFromIndex(end),
|
|
38
|
+
},
|
|
39
|
+
suggest: getSuggestionsSchema().map(({ messageId, textToInsert }) => ({
|
|
40
|
+
messageId,
|
|
41
|
+
fix: (fixer) => [
|
|
42
|
+
fixer.removeRange([start, start + 1]),
|
|
43
|
+
fixer.insertTextAfterRange([end, end], textToInsert),
|
|
44
|
+
],
|
|
45
|
+
})),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
31
48
|
return {
|
|
32
49
|
'BindingPipe[name="async"]'(bindingPipe) {
|
|
33
50
|
if (bindingPipe.exp instanceof bundled_angular_compiler_1.PrefixNot) {
|
|
@@ -48,21 +65,11 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
48
65
|
});
|
|
49
66
|
}
|
|
50
67
|
},
|
|
51
|
-
':not(PrefixNot) > PrefixNot > BindingPipe[name="async"]'({ parent
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
end: sourceCode.getLocFromIndex(end),
|
|
57
|
-
},
|
|
58
|
-
suggest: getSuggestionsSchema().map(({ messageId, textToInsert }) => ({
|
|
59
|
-
messageId,
|
|
60
|
-
fix: (fixer) => [
|
|
61
|
-
fixer.removeRange([start, start + 1]),
|
|
62
|
-
fixer.insertTextAfterRange([end, end], textToInsert),
|
|
63
|
-
],
|
|
64
|
-
})),
|
|
65
|
-
});
|
|
68
|
+
':not(PrefixNot) > PrefixNot > BindingPipe[name="async"]'({ parent, }) {
|
|
69
|
+
reportNegatedAsync(parent);
|
|
70
|
+
},
|
|
71
|
+
':not(PrefixNot) > PrefixNot > ParenthesizedExpression > BindingPipe[name="async"]'({ parent: { parent }, }) {
|
|
72
|
+
reportNegatedAsync(parent);
|
|
66
73
|
},
|
|
67
74
|
};
|
|
68
75
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-contextual-for-variables.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-contextual-for-variables.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prefer-contextual-for-variables.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-contextual-for-variables.ts"],"names":[],"mappings":"AAoBA,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,QAAQ,CAAC,cAAc,CAAC,EAAE;YACxB,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;YAC3B,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;YAC1B,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;YAC1B,IAAI,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;SAC1B,CAAC;KACH;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAClB,0BAA0B,GAC1B,aAAa,GACb,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,WAAW,CAAC;AAChB,eAAO,MAAM,SAAS,oCAAoC,CAAC;;AAc3D,wBAiaG"}
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.RULE_NAME = void 0;
|
|
4
4
|
const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-compiler");
|
|
5
5
|
const utils_1 = require("@angular-eslint/utils");
|
|
6
|
-
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
7
6
|
const are_equivalent_asts_1 = require("../utils/are-equivalent-asts");
|
|
7
|
+
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
8
|
+
const unwrap_parenthesized_expression_1 = require("../utils/unwrap-parenthesized-expression");
|
|
8
9
|
exports.RULE_NAME = 'prefer-contextual-for-variables';
|
|
9
10
|
const DEFAULT_OPTIONS = {
|
|
10
11
|
allowedAliases: {
|
|
@@ -482,35 +483,38 @@ function isIndex(node) {
|
|
|
482
483
|
return isContextualVariable(node, '$index');
|
|
483
484
|
}
|
|
484
485
|
function isIndexPlusOne(node) {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
486
|
+
const unwrapped = (0, unwrap_parenthesized_expression_1.unwrapParenthesizedExpression)(node);
|
|
487
|
+
if (unwrapped instanceof bundled_angular_compiler_1.Binary) {
|
|
488
|
+
if (unwrapped.operation === '+') {
|
|
489
|
+
if (isIndex(unwrapped.left)) {
|
|
490
|
+
return isOne(unwrapped.right);
|
|
489
491
|
}
|
|
490
492
|
else {
|
|
491
|
-
return isIndex(
|
|
493
|
+
return isIndex(unwrapped.right) && isOne(unwrapped.left);
|
|
492
494
|
}
|
|
493
495
|
}
|
|
494
496
|
}
|
|
495
497
|
return false;
|
|
496
498
|
}
|
|
497
499
|
function isIndexModTwo(node) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
500
|
+
const unwrapped = (0, unwrap_parenthesized_expression_1.unwrapParenthesizedExpression)(node);
|
|
501
|
+
return (unwrapped instanceof bundled_angular_compiler_1.Binary &&
|
|
502
|
+
unwrapped.operation === '%' &&
|
|
503
|
+
isIndex(unwrapped.left) &&
|
|
504
|
+
isTwo(unwrapped.right));
|
|
502
505
|
}
|
|
503
506
|
function isCount(node) {
|
|
504
507
|
return isContextualVariable(node, '$count');
|
|
505
508
|
}
|
|
506
509
|
function isCountMinusOne(node) {
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
510
|
+
const unwrapped = (0, unwrap_parenthesized_expression_1.unwrapParenthesizedExpression)(node);
|
|
511
|
+
if (unwrapped instanceof bundled_angular_compiler_1.Binary) {
|
|
512
|
+
if (unwrapped.operation === '-') {
|
|
513
|
+
if (isCount(unwrapped.left)) {
|
|
514
|
+
return isOne(unwrapped.right);
|
|
511
515
|
}
|
|
512
516
|
else {
|
|
513
|
-
return isCount(
|
|
517
|
+
return isCount(unwrapped.right) && isOne(unwrapped.left);
|
|
514
518
|
}
|
|
515
519
|
}
|
|
516
520
|
}
|
|
@@ -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":"AAiBA,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+GG"}
|
|
@@ -5,6 +5,7 @@ const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-comp
|
|
|
5
5
|
const utils_1 = require("@angular-eslint/utils");
|
|
6
6
|
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
7
7
|
const literal_primitive_1 = require("../utils/literal-primitive");
|
|
8
|
+
const unwrap_parenthesized_expression_1 = require("../utils/unwrap-parenthesized-expression");
|
|
8
9
|
const messageId = 'preferTemplateLiteral';
|
|
9
10
|
exports.RULE_NAME = 'prefer-template-literal';
|
|
10
11
|
exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
@@ -26,7 +27,10 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
26
27
|
const { sourceCode } = context;
|
|
27
28
|
return {
|
|
28
29
|
'Binary[operation="+"]'(node) {
|
|
29
|
-
const
|
|
30
|
+
const originalLeft = node.left;
|
|
31
|
+
const originalRight = node.right;
|
|
32
|
+
const left = (0, unwrap_parenthesized_expression_1.unwrapParenthesizedExpression)(originalLeft);
|
|
33
|
+
const right = (0, unwrap_parenthesized_expression_1.unwrapParenthesizedExpression)(originalRight);
|
|
30
34
|
const isLeftString = (0, literal_primitive_1.isStringLiteralPrimitive)(left) || left instanceof bundled_angular_compiler_1.TemplateLiteral;
|
|
31
35
|
const isRightString = (0, literal_primitive_1.isStringLiteralPrimitive)(right) || right instanceof bundled_angular_compiler_1.TemplateLiteral;
|
|
32
36
|
// If both sides are not strings, we don't report anything
|
|
@@ -45,11 +49,6 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
45
49
|
}
|
|
46
50
|
return '`';
|
|
47
51
|
}
|
|
48
|
-
function hasParentheses(node) {
|
|
49
|
-
const { start, end } = node.sourceSpan;
|
|
50
|
-
const text = sourceCode.text.slice(start - 1, end + 1);
|
|
51
|
-
return text.startsWith('(') && text.endsWith(')');
|
|
52
|
-
}
|
|
53
52
|
context.report({
|
|
54
53
|
loc: {
|
|
55
54
|
start: sourceCode.getLocFromIndex(start),
|
|
@@ -64,48 +63,25 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
64
63
|
return fixer.replaceTextRange([start, end], `${quote}${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(left, quote)}${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(right, quote)}${quote}`);
|
|
65
64
|
}
|
|
66
65
|
const fixes = Array();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (leftHasParentheses) {
|
|
71
|
-
fixes.push(fixer.removeRange([
|
|
72
|
-
left.sourceSpan.start - 1,
|
|
73
|
-
left.sourceSpan.start,
|
|
74
|
-
]));
|
|
66
|
+
// Fix the left side - handle parenthesized expressions specially
|
|
67
|
+
if (originalLeft instanceof bundled_angular_compiler_1.ParenthesizedExpression) {
|
|
68
|
+
fixes.push(...getLeftSideFixesForParenthesized(fixer, left, originalLeft));
|
|
75
69
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// Remove the left last parenthesis if it exists
|
|
79
|
-
if (leftHasParentheses) {
|
|
80
|
-
fixes.push(fixer.removeRange([
|
|
81
|
-
left.sourceSpan.end,
|
|
82
|
-
left.sourceSpan.end + 1,
|
|
83
|
-
]));
|
|
70
|
+
else {
|
|
71
|
+
fixes.push(...getLeftSideFixes(fixer, left));
|
|
84
72
|
}
|
|
85
|
-
// Remove the `+` sign
|
|
73
|
+
// Remove the `+` sign (including surrounding whitespace)
|
|
86
74
|
fixes.push(fixer.removeRange([
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
: left.sourceSpan.end,
|
|
90
|
-
rightHasParentheses
|
|
91
|
-
? right.sourceSpan.start - 1
|
|
92
|
-
: right.sourceSpan.start,
|
|
75
|
+
originalLeft.sourceSpan.end,
|
|
76
|
+
originalRight.sourceSpan.start,
|
|
93
77
|
]));
|
|
94
|
-
//
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
right.sourceSpan.start,
|
|
99
|
-
]));
|
|
78
|
+
// Fix the right side - handle parenthesized expressions specially
|
|
79
|
+
if (originalRight instanceof bundled_angular_compiler_1.ParenthesizedExpression) {
|
|
80
|
+
// For parenthesized expressions, we want to replace the whole thing including parens
|
|
81
|
+
fixes.push(...getRightSideFixesForParenthesized(fixer, right, originalRight));
|
|
100
82
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
// Remove the right last parenthesis if it exists
|
|
104
|
-
if (rightHasParentheses) {
|
|
105
|
-
fixes.push(fixer.removeRange([
|
|
106
|
-
right.sourceSpan.end,
|
|
107
|
-
right.sourceSpan.end + 1,
|
|
108
|
-
]));
|
|
83
|
+
else {
|
|
84
|
+
fixes.push(...getRightSideFixes(fixer, right));
|
|
109
85
|
}
|
|
110
86
|
return fixes;
|
|
111
87
|
},
|
|
@@ -132,6 +108,31 @@ function getLeftSideFixes(fixer, left) {
|
|
|
132
108
|
fixer.insertTextAfterRange([start, end], '}'),
|
|
133
109
|
];
|
|
134
110
|
}
|
|
111
|
+
function getLeftSideFixesForParenthesized(fixer, innerExpression, parenthesizedExpression) {
|
|
112
|
+
const parenthesizedStart = parenthesizedExpression.sourceSpan.start;
|
|
113
|
+
const parenthesizedEnd = parenthesizedExpression.sourceSpan.end;
|
|
114
|
+
const innerStart = innerExpression.sourceSpan.start;
|
|
115
|
+
const innerEnd = innerExpression.sourceSpan.end;
|
|
116
|
+
if (innerExpression instanceof bundled_angular_compiler_1.TemplateLiteral) {
|
|
117
|
+
// Remove the end ` sign from the inner expression and remove the parentheses
|
|
118
|
+
return [
|
|
119
|
+
fixer.removeRange([parenthesizedStart, innerStart]), // Remove opening paren
|
|
120
|
+
fixer.removeRange([innerEnd - 1, innerEnd]), // Remove closing backtick
|
|
121
|
+
fixer.removeRange([innerEnd, parenthesizedEnd]), // Remove closing paren
|
|
122
|
+
];
|
|
123
|
+
}
|
|
124
|
+
if ((0, literal_primitive_1.isLiteralPrimitive)(innerExpression)) {
|
|
125
|
+
// Transform to template literal and remove parentheses
|
|
126
|
+
return [
|
|
127
|
+
fixer.replaceTextRange([parenthesizedStart, parenthesizedEnd], `\`${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(innerExpression, '`')}`),
|
|
128
|
+
];
|
|
129
|
+
}
|
|
130
|
+
// Transform parenthesized expression to template literal by removing parens and wrapping in ${}
|
|
131
|
+
return [
|
|
132
|
+
fixer.replaceTextRange([parenthesizedStart, innerStart], '`${'), // Replace opening paren with `${
|
|
133
|
+
fixer.replaceTextRange([innerEnd, parenthesizedEnd], '}'), // Replace closing paren with }
|
|
134
|
+
];
|
|
135
|
+
}
|
|
135
136
|
function getRightSideFixes(fixer, right) {
|
|
136
137
|
const { start, end } = right.sourceSpan;
|
|
137
138
|
if (right instanceof bundled_angular_compiler_1.TemplateLiteral) {
|
|
@@ -150,3 +151,28 @@ function getRightSideFixes(fixer, right) {
|
|
|
150
151
|
fixer.insertTextAfterRange([start, end], '}`'),
|
|
151
152
|
];
|
|
152
153
|
}
|
|
154
|
+
function getRightSideFixesForParenthesized(fixer, innerExpression, parenthesizedExpression) {
|
|
155
|
+
const parenthesizedStart = parenthesizedExpression.sourceSpan.start;
|
|
156
|
+
const parenthesizedEnd = parenthesizedExpression.sourceSpan.end;
|
|
157
|
+
const innerStart = innerExpression.sourceSpan.start;
|
|
158
|
+
const innerEnd = innerExpression.sourceSpan.end;
|
|
159
|
+
if (innerExpression instanceof bundled_angular_compiler_1.TemplateLiteral) {
|
|
160
|
+
// Remove the start ` sign from the inner expression and remove the parentheses
|
|
161
|
+
return [
|
|
162
|
+
fixer.removeRange([parenthesizedStart, innerStart]), // Remove opening paren
|
|
163
|
+
fixer.removeRange([innerStart, innerStart + 1]), // Remove opening backtick
|
|
164
|
+
fixer.removeRange([innerEnd, parenthesizedEnd]), // Remove closing paren
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
if ((0, literal_primitive_1.isLiteralPrimitive)(innerExpression)) {
|
|
168
|
+
// Transform to template literal and remove parentheses
|
|
169
|
+
return [
|
|
170
|
+
fixer.replaceTextRange([parenthesizedStart, parenthesizedEnd], `${(0, literal_primitive_1.getLiteralPrimitiveStringValue)(innerExpression, '`')}\``),
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
// Transform parenthesized expression to template literal by removing parens and wrapping in ${}
|
|
174
|
+
return [
|
|
175
|
+
fixer.replaceTextRange([parenthesizedStart, innerStart], '${'), // Replace opening paren with ${
|
|
176
|
+
fixer.replaceTextRange([innerEnd, parenthesizedEnd], '}`'), // Replace closing paren with }`
|
|
177
|
+
];
|
|
178
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin-template",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "20.0.0-alpha.1",
|
|
4
4
|
"description": "ESLint plugin for Angular Templates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -20,13 +20,13 @@
|
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"aria-query": "5.3.2",
|
|
22
22
|
"axobject-query": "4.1.0",
|
|
23
|
-
"@angular-eslint/bundled-angular-compiler": "
|
|
24
|
-
"@angular-eslint/utils": "
|
|
23
|
+
"@angular-eslint/bundled-angular-compiler": "20.0.0-alpha.1",
|
|
24
|
+
"@angular-eslint/utils": "20.0.0-alpha.1"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/aria-query": "5.0.4",
|
|
28
|
-
"@angular-eslint/
|
|
29
|
-
"@angular-eslint/
|
|
28
|
+
"@angular-eslint/template-parser": "20.0.0-alpha.1",
|
|
29
|
+
"@angular-eslint/test-utils": "20.0.0-alpha.1"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@typescript-eslint/types": "^7.11.0 || ^8.0.0",
|