@angular-eslint/eslint-plugin-template 20.5.1-alpha.0 → 20.5.1-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.
- package/README.md +1 -1
- package/dist/rules/attributes-order.js +1 -1
- package/dist/rules/elements-content.js +1 -1
- package/dist/rules/eqeqeq.js +4 -4
- package/dist/rules/no-inline-styles.js +3 -3
- package/dist/rules/prefer-at-empty.js +2 -2
- package/dist/rules/prefer-contextual-for-variables.js +3 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ Please see https://github.com/angular-eslint/angular-eslint for full usage instr
|
|
|
48
48
|
| [`click-events-have-key-events`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/click-events-have-key-events.md) | [Accessibility] Ensures that the click event is accompanied with at least one key event keyup, keydown or keypress. | | | | :accessibility: |
|
|
49
49
|
| [`conditional-complexity`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/conditional-complexity.md) | The conditional complexity should not exceed a rational limit | | | | |
|
|
50
50
|
| [`cyclomatic-complexity`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/cyclomatic-complexity.md) | Checks cyclomatic complexity against a specified limit. It is a quantitative measure of the number of linearly independent paths through a program's source code | | | | |
|
|
51
|
-
| [`elements-content`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/elements-content.md) | [Accessibility] Ensures that the heading, anchor and button elements have content in
|
|
51
|
+
| [`elements-content`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/elements-content.md) | [Accessibility] Ensures that the heading, anchor and button elements have content in them | | | | :accessibility: |
|
|
52
52
|
| [`eqeqeq`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/eqeqeq.md) | Requires `===` and `!==` in place of `==` and `!=` | :white_check_mark: | :wrench: | :bulb: | |
|
|
53
53
|
| [`i18n`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/i18n.md) | Ensures following best practices for i18n. Checks for missing i18n attributes on elements and attributes containing texts. Can also check for texts without i18n attribute, elements that do not use custom ID (@@) feature and duplicate custom IDs | | :wrench: | :bulb: | |
|
|
54
54
|
| [`interactive-supports-focus`](https://github.com/angular-eslint/angular-eslint/blob/main/packages/eslint-plugin-template/docs/rules/interactive-supports-focus.md) | [Accessibility] Ensures that elements with interactive handlers like `(click)` are focusable. | | | | :accessibility: |
|
|
@@ -252,7 +252,7 @@ function extractTemplateAttrs(node) {
|
|
|
252
252
|
* There may be multiple "attributes" for a structural directive even though
|
|
253
253
|
* there is only a single HTML attribute:
|
|
254
254
|
* e.g. `<ng-container *ngFor="let foo of bar"></ng-container>`
|
|
255
|
-
* will parsed as two attributes (`ngFor` and `ngForOf`)
|
|
255
|
+
* will be parsed as two attributes (`ngFor` and `ngForOf`)
|
|
256
256
|
*/
|
|
257
257
|
const attrs = node.parent.templateAttrs.map(toStructuralDirectiveOrderType);
|
|
258
258
|
let keyEnd = attrs[0].keySpan?.end;
|
|
@@ -21,7 +21,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
21
21
|
meta: {
|
|
22
22
|
type: 'suggestion',
|
|
23
23
|
docs: {
|
|
24
|
-
description: '[Accessibility] Ensures that the heading, anchor and button elements have content in
|
|
24
|
+
description: '[Accessibility] Ensures that the heading, anchor and button elements have content in them',
|
|
25
25
|
},
|
|
26
26
|
schema: [
|
|
27
27
|
{
|
package/dist/rules/eqeqeq.js
CHANGED
|
@@ -81,11 +81,11 @@ const getFix = ({ node, right, end, sourceCode, fixer, }) => {
|
|
|
81
81
|
const { source, ast } = (0, get_nearest_node_from_1.getNearestNodeFrom)(node, isASTWithSource);
|
|
82
82
|
if (!source)
|
|
83
83
|
return null;
|
|
84
|
-
let
|
|
85
|
-
while (!isInterpolation(ast) && isLeadingTriviaChar(source[
|
|
86
|
-
|
|
84
|
+
let startOffset = 0;
|
|
85
|
+
while (!isInterpolation(ast) && isLeadingTriviaChar(source[startOffset])) {
|
|
86
|
+
startOffset++;
|
|
87
87
|
}
|
|
88
|
-
const endRange = end -
|
|
88
|
+
const endRange = end - startOffset - getSpanLength(right) - 1;
|
|
89
89
|
let eqOffset = 0;
|
|
90
90
|
while (sourceCode.text[endRange - eqOffset] !== '=') {
|
|
91
91
|
eqOffset++;
|
|
@@ -71,20 +71,20 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
71
71
|
},
|
|
72
72
|
});
|
|
73
73
|
/**
|
|
74
|
-
* Check that
|
|
74
|
+
* Check that an element (for example `<img>`) has a `style` attribute or `attr.style` binding.
|
|
75
75
|
*/
|
|
76
76
|
function isNodeHasStyleAttribute(node) {
|
|
77
77
|
return (node.attributes.some(({ name }) => isStyle(name)) ||
|
|
78
78
|
node.inputs.some(({ name }) => isStyle(name)));
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
* Check that
|
|
81
|
+
* Check that an element (for example `<img>`) has a `ngStyle` attribute binding.
|
|
82
82
|
*/
|
|
83
83
|
function isNodeHasNgStyleAttribute(node) {
|
|
84
84
|
return node.inputs.some(({ name }) => isNgStyle(name));
|
|
85
85
|
}
|
|
86
86
|
/**
|
|
87
|
-
* Check that
|
|
87
|
+
* Check that an element (for example `<img>`) has a `[style.background-color]` attribute binding.
|
|
88
88
|
*/
|
|
89
89
|
function isNodeHasBindingToStyleAttribute(node) {
|
|
90
90
|
return node.inputs.some(({ keySpan }) => isStyleBound(keySpan));
|
|
@@ -70,7 +70,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
70
70
|
if (forInfo.node.empty) {
|
|
71
71
|
// There is already an `@empty` block. The contents of the
|
|
72
72
|
// `@if` block and the contents of the `@empty` block would
|
|
73
|
-
// both be shown
|
|
73
|
+
// both be shown if the collection is empty, so we need to
|
|
74
74
|
// combine the two blocks. The `@if` block would be rendered
|
|
75
75
|
// first, so it needs to be inserted before the existing
|
|
76
76
|
// contents of the `@empty` block.
|
|
@@ -187,7 +187,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
187
187
|
if (forBlock.empty?.endSourceSpan) {
|
|
188
188
|
// There is already an `@empty` block, but because the `@for`
|
|
189
189
|
// block was inside an `@else` block, the `@empty` block
|
|
190
|
-
//
|
|
190
|
+
// will never be rendered, so we can replace its contents.
|
|
191
191
|
yield fixer.replaceTextRange([
|
|
192
192
|
forBlock.empty.startSourceSpan.end.offset,
|
|
193
193
|
forBlock.empty.endSourceSpan.start.offset,
|
|
@@ -176,13 +176,13 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
|
|
|
176
176
|
}
|
|
177
177
|
},
|
|
178
178
|
PropertyRead(node) {
|
|
179
|
-
// Get the information for the
|
|
179
|
+
// Get the information for the innermost for loop (which will be
|
|
180
180
|
// the last one in the array) so that we can record the usage of
|
|
181
181
|
// aliases and expressions using contextual variables that can be
|
|
182
|
-
// simplified. We only need the
|
|
182
|
+
// simplified. We only need the innermost for loop because we
|
|
183
183
|
// don't remove aliases when there are nested for loops (meaning
|
|
184
184
|
// we don't need to record alias usage for the outer for loop), and
|
|
185
|
-
// any contextual variables will only reference the
|
|
185
|
+
// any contextual variables will only reference the innermost loop.
|
|
186
186
|
const forLoop = forLoops.at(-1);
|
|
187
187
|
if (!forLoop) {
|
|
188
188
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-eslint/eslint-plugin-template",
|
|
3
|
-
"version": "20.5.1-alpha.
|
|
3
|
+
"version": "20.5.1-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.1-alpha.
|
|
24
|
-
"@angular-eslint/utils": "20.5.1-alpha.
|
|
23
|
+
"@angular-eslint/bundled-angular-compiler": "20.5.1-alpha.2",
|
|
24
|
+
"@angular-eslint/utils": "20.5.1-alpha.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/aria-query": "5.0.4",
|
|
28
|
-
"@angular-eslint/test-utils": "20.5.1-alpha.
|
|
28
|
+
"@angular-eslint/test-utils": "20.5.1-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.1-alpha.
|
|
35
|
+
"@angular-eslint/template-parser": "20.5.1-alpha.2"
|
|
36
36
|
},
|
|
37
37
|
"gitHead": "e2006e5e9c99e5a943d1a999e0efa5247d29ec24"
|
|
38
38
|
}
|