@angular-eslint/eslint-plugin-template 20.5.2-alpha.0 → 20.5.2-alpha.2
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.
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,wBAsFG"}
|
|
@@ -36,7 +36,9 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
36
36
|
const sourceCode = context.sourceCode;
|
|
37
37
|
return {
|
|
38
38
|
BoundAttribute(node) {
|
|
39
|
-
if (!node.value.source ||
|
|
39
|
+
if (!node.value.source ||
|
|
40
|
+
!node.valueSpan ||
|
|
41
|
+
node.value.ast instanceof bundled_angular_compiler_1.Interpolation) {
|
|
40
42
|
return;
|
|
41
43
|
}
|
|
42
44
|
const possibleBinary = extractPossibleBinaryOrConditionalFrom(getParser().parseBinding(node.value.source, node.valueSpan, 0).ast);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefer-ngsrc.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-ngsrc.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prefer-ngsrc.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-ngsrc.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,OAAO,GAAG,EAAE,CAAC;AACzB,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;AACpE,eAAO,MAAM,SAAS,iBAAiB,CAAC;;AAExC,wBA4CG"}
|
|
@@ -23,8 +23,8 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
23
23
|
const parserServices = (0, utils_1.getTemplateParserServices)(context);
|
|
24
24
|
return {
|
|
25
25
|
'Element[name=/^img$/i]'(element) {
|
|
26
|
-
const ngSrcAttribute =
|
|
27
|
-
const srcAttribute =
|
|
26
|
+
const ngSrcAttribute = getNgSrcAttribute(element);
|
|
27
|
+
const srcAttribute = getNormalSrcAttribute(element);
|
|
28
28
|
if (!srcAttribute ||
|
|
29
29
|
(!ngSrcAttribute && isSrcBase64Image(srcAttribute))) {
|
|
30
30
|
return;
|
|
@@ -40,17 +40,33 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
40
40
|
};
|
|
41
41
|
},
|
|
42
42
|
});
|
|
43
|
-
function
|
|
43
|
+
function getNgSrcAttribute({ inputs, attributes, }) {
|
|
44
44
|
return [...inputs, ...attributes].find(({ name }) => name === 'ngSrc');
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function getNormalSrcAttribute({ inputs, attributes, }) {
|
|
47
47
|
return [...inputs, ...attributes].find(({ name }) => name === 'src');
|
|
48
48
|
}
|
|
49
49
|
// Adheres to angular's assertion that ngSrc value is not a data URL.
|
|
50
50
|
// https://github.com/angular/angular/blob/17.0.3/packages/common/src/directives/ng_optimized_image/ng_optimized_image.ts#L585
|
|
51
51
|
function isSrcBase64Image(attribute) {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const isPlainDataAttribute = attribute instanceof bundled_angular_compiler_1.TmplAstTextAttribute &&
|
|
53
|
+
attribute.value.trim().startsWith('data:');
|
|
54
|
+
if (isPlainDataAttribute) {
|
|
55
|
+
return true;
|
|
54
56
|
}
|
|
55
|
-
|
|
57
|
+
const isBoundDataAttribute = attribute.value instanceof bundled_angular_compiler_1.ASTWithSource &&
|
|
58
|
+
isDataStringPrimitive(attribute.value.ast);
|
|
59
|
+
if (isBoundDataAttribute) {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
const isBoundDataInExpression = attribute.value instanceof bundled_angular_compiler_1.ASTWithSource &&
|
|
63
|
+
attribute.value.ast instanceof bundled_angular_compiler_1.Binary &&
|
|
64
|
+
attribute.value.ast.operation === '+' &&
|
|
65
|
+
isDataStringPrimitive(attribute.value.ast.left);
|
|
66
|
+
return isBoundDataInExpression;
|
|
67
|
+
}
|
|
68
|
+
function isDataStringPrimitive(primitive) {
|
|
69
|
+
return (primitive instanceof bundled_angular_compiler_1.LiteralPrimitive &&
|
|
70
|
+
typeof primitive.value === 'string' &&
|
|
71
|
+
primitive.value.trim().startsWith('data:'));
|
|
56
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin-template",
|
|
3
|
-
"version": "20.5.2-alpha.
|
|
3
|
+
"version": "20.5.2-alpha.2",
|
|
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": "20.5.2-alpha.
|
|
24
|
-
"@angular-eslint/utils": "20.5.2-alpha.
|
|
23
|
+
"@angular-eslint/bundled-angular-compiler": "20.5.2-alpha.2",
|
|
24
|
+
"@angular-eslint/utils": "20.5.2-alpha.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/aria-query": "5.0.4",
|
|
28
|
-
"@angular-eslint/test-utils": "20.5.2-alpha.
|
|
28
|
+
"@angular-eslint/test-utils": "20.5.2-alpha.2"
|
|
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": "20.5.2-alpha.
|
|
35
|
+
"@angular-eslint/template-parser": "20.5.2-alpha.2"
|
|
36
36
|
},
|
|
37
37
|
"gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24"
|
|
38
38
|
}
|