@angular-eslint/eslint-plugin-template 17.2.1-alpha.1 → 17.2.1-alpha.3
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/i18n.js +13 -13
- package/package.json +3 -3
package/dist/rules/i18n.js
CHANGED
|
@@ -147,7 +147,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
147
147
|
const collectedCustomIds = new Map();
|
|
148
148
|
function getNextElementOrTemplateParent(node) {
|
|
149
149
|
const parent = node.parent;
|
|
150
|
-
if (parent && !isElement(parent) && !
|
|
150
|
+
if (parent && !isElement(parent) && !isNgTemplate(parent)) {
|
|
151
151
|
return getNextElementOrTemplateParent(parent);
|
|
152
152
|
}
|
|
153
153
|
return parent;
|
|
@@ -158,7 +158,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
158
158
|
const parent = getNextElementOrTemplateParent(node);
|
|
159
159
|
if (isTagAllowed(allowedTags, node) ||
|
|
160
160
|
isElementWithI18n(parent) ||
|
|
161
|
-
|
|
161
|
+
isNgTemplateWithI18n(parent)) {
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
164
|
const loc = parserServices.convertNodeSourceSpanToLoc(sourceSpan);
|
|
@@ -239,13 +239,13 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
239
239
|
const parent = getNextElementOrTemplateParent(node);
|
|
240
240
|
if ((isBoundText(node) &&
|
|
241
241
|
isBoundTextAllowed(allowedBoundTextPattern, node)) ||
|
|
242
|
-
((isElement(parent) ||
|
|
242
|
+
((isElement(parent) || isNgTemplate(parent)) &&
|
|
243
243
|
(parent.i18n || isTagAllowed(allowedTags, parent)))) {
|
|
244
244
|
return;
|
|
245
245
|
}
|
|
246
246
|
const loc = parserServices.convertNodeSourceSpanToLoc(sourceSpan);
|
|
247
247
|
const fix = (fixer) => getFixForIcuOrText(sourceCode, parserServices, fixer, loc, parent);
|
|
248
|
-
context.report(Object.assign({ messageId: 'i18nAttributeOnIcuOrText', loc }, (((_a = parent === null || parent === void 0 ? void 0 : parent.children) === null || _a === void 0 ? void 0 : _a.filter((child) => isElement(child) ||
|
|
248
|
+
context.report(Object.assign({ messageId: 'i18nAttributeOnIcuOrText', loc }, (((_a = parent === null || parent === void 0 ? void 0 : parent.children) === null || _a === void 0 ? void 0 : _a.filter((child) => isElement(child) || isNgTemplate(child)).length)
|
|
249
249
|
? { suggest: [{ messageId: 'suggestAddI18nAttribute', fix }] }
|
|
250
250
|
: { fix })));
|
|
251
251
|
}
|
|
@@ -301,10 +301,10 @@ function getFixForIcuOrTextWithoutParent(sourceCode, fixer, { start, end }) {
|
|
|
301
301
|
];
|
|
302
302
|
}
|
|
303
303
|
function getFixForIcuOrText(sourceCode, parserServices, fixer, loc, parent) {
|
|
304
|
-
if (!isElement(parent) && !
|
|
304
|
+
if (!isElement(parent) && !isNgTemplate(parent)) {
|
|
305
305
|
return getFixForIcuOrTextWithoutParent(sourceCode, fixer, loc);
|
|
306
306
|
}
|
|
307
|
-
if ((0, get_nearest_node_from_1.getNearestNodeFrom)(parent,
|
|
307
|
+
if ((0, get_nearest_node_from_1.getNearestNodeFrom)(parent, isElementOrNgTemplateWithI18n)) {
|
|
308
308
|
return [];
|
|
309
309
|
}
|
|
310
310
|
const tagName = getTagName(parent);
|
|
@@ -348,20 +348,20 @@ function isBoundTextAllowed(allowedBoundTextPattern, { value: { ast: { strings }
|
|
|
348
348
|
const text = strings.join('').trim();
|
|
349
349
|
return !PL_PATTERN.test(text) || allowedBoundTextPattern.test(text);
|
|
350
350
|
}
|
|
351
|
-
function
|
|
352
|
-
return ast instanceof bundled_angular_compiler_1.TmplAstTemplate;
|
|
351
|
+
function isNgTemplate(ast) {
|
|
352
|
+
return ast instanceof bundled_angular_compiler_1.TmplAstTemplate && ast.tagName === 'ng-template';
|
|
353
353
|
}
|
|
354
|
-
function
|
|
355
|
-
return Boolean(
|
|
354
|
+
function isNgTemplateWithI18n(ast) {
|
|
355
|
+
return Boolean(isNgTemplate(ast) && ast.i18n);
|
|
356
356
|
}
|
|
357
|
-
function
|
|
358
|
-
return isElementWithI18n(ast) ||
|
|
357
|
+
function isElementOrNgTemplateWithI18n(ast) {
|
|
358
|
+
return isElementWithI18n(ast) || isNgTemplateWithI18n(ast);
|
|
359
359
|
}
|
|
360
360
|
function getTagName(node) {
|
|
361
361
|
if (isElement(node)) {
|
|
362
362
|
return node.name;
|
|
363
363
|
}
|
|
364
|
-
if (
|
|
364
|
+
if (isNgTemplate(node)) {
|
|
365
365
|
return node.tagName;
|
|
366
366
|
}
|
|
367
367
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin-template",
|
|
3
|
-
"version": "17.2.1-alpha.
|
|
3
|
+
"version": "17.2.1-alpha.3",
|
|
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.2.1-alpha.
|
|
21
|
-
"@angular-eslint/utils": "17.2.1-alpha.
|
|
20
|
+
"@angular-eslint/bundled-angular-compiler": "17.2.1-alpha.3",
|
|
21
|
+
"@angular-eslint/utils": "17.2.1-alpha.3",
|
|
22
22
|
"@typescript-eslint/type-utils": "6.18.0",
|
|
23
23
|
"@typescript-eslint/utils": "6.18.0",
|
|
24
24
|
"aria-query": "5.3.0",
|