@angular-eslint/eslint-plugin-template 17.1.1-alpha.0 → 17.1.1-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/prefer-ngsrc.js +11 -1
- package/package.json +3 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RULE_NAME = void 0;
|
|
4
|
+
const bundled_angular_compiler_1 = require("@angular-eslint/bundled-angular-compiler");
|
|
4
5
|
const utils_1 = require("@angular-eslint/utils");
|
|
5
6
|
const create_eslint_rule_1 = require("../utils/create-eslint-rule");
|
|
6
7
|
exports.RULE_NAME = 'prefer-ngsrc';
|
|
@@ -24,7 +25,8 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
24
25
|
'Element$1[name=img]'(element) {
|
|
25
26
|
const ngSrcAttribute = hasNgSrcAttribute(element);
|
|
26
27
|
const srcAttribute = hasNormalSrcAttribute(element);
|
|
27
|
-
if (!srcAttribute
|
|
28
|
+
if (!srcAttribute ||
|
|
29
|
+
(!ngSrcAttribute && isSrcBase64Image(srcAttribute))) {
|
|
28
30
|
return;
|
|
29
31
|
}
|
|
30
32
|
const loc = parserServices.convertNodeSourceSpanToLoc(srcAttribute.sourceSpan);
|
|
@@ -44,3 +46,11 @@ function hasNgSrcAttribute({ inputs, attributes, }) {
|
|
|
44
46
|
function hasNormalSrcAttribute({ inputs, attributes, }) {
|
|
45
47
|
return [...inputs, ...attributes].find(({ name }) => name === 'src');
|
|
46
48
|
}
|
|
49
|
+
// Adheres to angular's assertion that ngSrc value is not a data URL.
|
|
50
|
+
// https://github.com/angular/angular/blob/17.0.3/packages/common/src/directives/ng_optimized_image/ng_optimized_image.ts#L585
|
|
51
|
+
function isSrcBase64Image(attribute) {
|
|
52
|
+
if (attribute instanceof bundled_angular_compiler_1.TmplAstTextAttribute) {
|
|
53
|
+
return attribute.value.trim().startsWith('data:');
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin-template",
|
|
3
|
-
"version": "17.1.1-alpha.
|
|
3
|
+
"version": "17.1.1-alpha.1",
|
|
4
4
|
"description": "ESLint plugin for Angular Templates",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"LICENSE"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@angular-eslint/bundled-angular-compiler": "17.1.1-alpha.
|
|
21
|
-
"@angular-eslint/utils": "17.1.1-alpha.
|
|
20
|
+
"@angular-eslint/bundled-angular-compiler": "17.1.1-alpha.1",
|
|
21
|
+
"@angular-eslint/utils": "17.1.1-alpha.1",
|
|
22
22
|
"@typescript-eslint/type-utils": "6.11.0",
|
|
23
23
|
"@typescript-eslint/utils": "6.11.0",
|
|
24
24
|
"aria-query": "5.3.0",
|