@angular-eslint/eslint-plugin-template 21.1.1-alpha.10 → 21.1.1-alpha.11
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/button-has-type.js +1 -0
- package/dist/rules/no-empty-control-flow.d.ts.map +1 -1
- package/dist/rules/no-empty-control-flow.js +19 -2
- package/dist/rules/prefer-class-binding.d.ts.map +1 -1
- package/dist/rules/prefer-class-binding.js +4 -0
- package/dist/utils/are-equivalent-asts.d.ts.map +1 -1
- package/dist/utils/are-equivalent-asts.js +19 -6
- package/dist/utils/get-attribute-value.d.ts.map +1 -1
- package/dist/utils/get-attribute-value.js +4 -0
- package/package.json +5 -5
|
@@ -100,6 +100,7 @@ function getInvalidButtonTypeIfPresent(element) {
|
|
|
100
100
|
if (name === TYPE_ATTRIBUTE_NAME &&
|
|
101
101
|
value instanceof bundled_angular_compiler_1.ASTWithSource &&
|
|
102
102
|
value.ast instanceof bundled_angular_compiler_1.LiteralPrimitive &&
|
|
103
|
+
typeof value.ast.value === 'string' &&
|
|
103
104
|
!VALID_BUTTON_TYPES.includes(value.ast.value)) {
|
|
104
105
|
return {
|
|
105
106
|
value: value.ast.value,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-empty-control-flow.d.ts","sourceRoot":"","sources":["../../src/rules/no-empty-control-flow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-empty-control-flow.d.ts","sourceRoot":"","sources":["../../src/rules/no-empty-control-flow.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAC9C,eAAO,MAAM,SAAS,0BAA0B,CAAC;;AAEjD,wBA4FG;AAEH,eAAO,MAAM,mBAAmB;;CAG/B,CAAC"}
|
|
@@ -20,7 +20,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
20
20
|
create(context) {
|
|
21
21
|
const parserServices = (0, utils_1.getTemplateParserServices)(context);
|
|
22
22
|
return {
|
|
23
|
-
'ForLoopBlockEmpty,IfBlockBranch
|
|
23
|
+
'ForLoopBlockEmpty,IfBlockBranch'(node) {
|
|
24
24
|
if (node.children.length === 0 ||
|
|
25
25
|
isEmpty(node.startSourceSpan.end, node.endSourceSpan?.start)) {
|
|
26
26
|
report(node);
|
|
@@ -42,8 +42,19 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
42
42
|
// A switch block is pointless without cases, so
|
|
43
43
|
// if there are no cases, don't bother checking
|
|
44
44
|
// if there's non-whitespace characters within it.
|
|
45
|
-
if (node.
|
|
45
|
+
if (node.groups.length === 0) {
|
|
46
46
|
report(node);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
// Check each group for empty content
|
|
50
|
+
for (const group of node.groups) {
|
|
51
|
+
if (group.children.length === 0 ||
|
|
52
|
+
isEmpty(group.startSourceSpan.end, group.endSourceSpan?.start)) {
|
|
53
|
+
// Report on the first case in the group
|
|
54
|
+
if (group.cases.length > 0) {
|
|
55
|
+
reportCase(group.cases[0]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
47
58
|
}
|
|
48
59
|
},
|
|
49
60
|
};
|
|
@@ -59,6 +70,12 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
59
70
|
loc: parserServices.convertNodeSourceSpanToLoc(node.nameSpan),
|
|
60
71
|
});
|
|
61
72
|
}
|
|
73
|
+
function reportCase(node) {
|
|
74
|
+
context.report({
|
|
75
|
+
messageId: 'noEmptyControlFlow',
|
|
76
|
+
loc: parserServices.convertNodeSourceSpanToLoc(node.nameSpan),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
62
79
|
},
|
|
63
80
|
});
|
|
64
81
|
exports.RULE_DOCS_EXTENSION = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-class-binding.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-class-binding.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAC9C,eAAO,MAAM,SAAS,yBAAyB,CAAC;;AAEhD,wBAmCG;
|
|
1
|
+
{"version":3,"file":"prefer-class-binding.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-class-binding.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAC9C,eAAO,MAAM,SAAS,yBAAyB,CAAC;;AAEhD,wBAmCG;AAwDH,eAAO,MAAM,mBAAmB;;CAG/B,CAAC"}
|
|
@@ -61,6 +61,10 @@ function requiresNgClass(node) {
|
|
|
61
61
|
const parsedAst = getParser().parseBinding(node.value.source, node.valueSpan, 0).ast;
|
|
62
62
|
if (parsedAst instanceof bundled_angular_compiler_1.LiteralMap) {
|
|
63
63
|
for (const astKey of parsedAst.keys) {
|
|
64
|
+
// Skip spread keys as they don't have a key property
|
|
65
|
+
if (astKey.kind === 'spread') {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
64
68
|
const className = astKey.key;
|
|
65
69
|
if (typeof className === 'string' &&
|
|
66
70
|
hasSpaceSeparatedClasses(className)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"are-equivalent-asts.d.ts","sourceRoot":"","sources":["../../src/utils/are-equivalent-asts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,
|
|
1
|
+
{"version":3,"file":"are-equivalent-asts.d.ts","sourceRoot":"","sources":["../../src/utils/are-equivalent-asts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAsBJ,MAAM,0CAA0C,CAAC;AAElD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CA2JzD"}
|
|
@@ -4,11 +4,10 @@ exports.areEquivalentASTs = areEquivalentASTs;
|
|
|
4
4
|
const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-compiler");
|
|
5
5
|
function areEquivalentASTs(a, b) {
|
|
6
6
|
// An `ImplicitReceiver` is equivalent to a `ThisReceiver` because
|
|
7
|
-
// `this.foo` and `foo` mean the same thing.
|
|
8
|
-
// `
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return b instanceof bundled_angular_compiler_1.ImplicitReceiver;
|
|
7
|
+
// `this.foo` and `foo` mean the same thing. In Angular v21.1.0+,
|
|
8
|
+
// `ThisReceiver` is a separate class, so we check for both types.
|
|
9
|
+
if (a instanceof bundled_angular_compiler_1.ImplicitReceiver || a instanceof bundled_angular_compiler_1.ThisReceiver) {
|
|
10
|
+
return b instanceof bundled_angular_compiler_1.ImplicitReceiver || b instanceof bundled_angular_compiler_1.ThisReceiver;
|
|
12
11
|
}
|
|
13
12
|
// Bail out if the two ASTs are not the same type.
|
|
14
13
|
if (a.constructor !== b.constructor) {
|
|
@@ -73,7 +72,21 @@ function areEquivalentASTs(a, b) {
|
|
|
73
72
|
// the `quoted` property because a quoted key with the same value as
|
|
74
73
|
// an unquoted key is the same key. Likewise, the `isShorthandInitialized`
|
|
75
74
|
// property doesn't affect the name of the key.
|
|
76
|
-
a.keys.every((aKey, index) =>
|
|
75
|
+
a.keys.every((aKey, index) => {
|
|
76
|
+
const bKey = b.keys[index];
|
|
77
|
+
// Handle spread keys - they match if both are spread keys
|
|
78
|
+
if (aKey.kind === 'spread' && bKey.kind === 'spread') {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
// If one is spread and the other isn't, they don't match
|
|
82
|
+
if (aKey.kind !== bKey.kind) {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
// Both are property keys, compare the key values
|
|
86
|
+
return (aKey.kind === 'property' &&
|
|
87
|
+
bKey.kind === 'property' &&
|
|
88
|
+
aKey.key === bKey.key);
|
|
89
|
+
}) &&
|
|
77
90
|
areEquivalentASTArrays(a.values, b.values));
|
|
78
91
|
}
|
|
79
92
|
// Pipes and interpolations are next.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-attribute-value.d.ts","sourceRoot":"","sources":["../../src/utils/get-attribute-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAU/E;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,cAAc,EACtC,aAAa,EAAE,MAAM,GACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"get-attribute-value.d.ts","sourceRoot":"","sources":["../../src/utils/get-attribute-value.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAU/E;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,cAAc,EACtC,aAAa,EAAE,MAAM,GACpB,OAAO,CAiCT"}
|
|
@@ -28,6 +28,10 @@ function getAttributeValue({ attributes, inputs }, attributeName) {
|
|
|
28
28
|
if (attributeOrInput.value.ast instanceof bundled_angular_compiler_1.LiteralMap) {
|
|
29
29
|
const { keys, values } = attributeOrInput.value.ast;
|
|
30
30
|
return keys.reduce((current, next, index) => {
|
|
31
|
+
// Skip spread keys as they don't have a key property
|
|
32
|
+
if (next.kind === 'spread') {
|
|
33
|
+
return current;
|
|
34
|
+
}
|
|
31
35
|
return current.set(next.key, values[index]);
|
|
32
36
|
}, new Map());
|
|
33
37
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin-template",
|
|
3
|
-
"version": "21.1.1-alpha.
|
|
3
|
+
"version": "21.1.1-alpha.11",
|
|
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": "21.1.1-alpha.
|
|
24
|
-
"@angular-eslint/utils": "21.1.1-alpha.
|
|
23
|
+
"@angular-eslint/bundled-angular-compiler": "21.1.1-alpha.11",
|
|
24
|
+
"@angular-eslint/utils": "21.1.1-alpha.11"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/aria-query": "5.0.4",
|
|
28
|
-
"@angular-eslint/test-utils": "21.1.1-alpha.
|
|
28
|
+
"@angular-eslint/test-utils": "21.1.1-alpha.11"
|
|
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": "21.1.1-alpha.
|
|
35
|
+
"@angular-eslint/template-parser": "21.1.1-alpha.11"
|
|
36
36
|
},
|
|
37
37
|
"gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24"
|
|
38
38
|
}
|