@angular-eslint/eslint-plugin-template 18.0.2-alpha.1 → 18.0.2-alpha.10

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,17 +1,17 @@
1
1
  {
2
- "parser": "@angular-eslint/template-parser",
3
- "plugins": ["@angular-eslint/template"],
4
- "rules": {
5
- "@angular-eslint/template/alt-text": "error",
6
- "@angular-eslint/template/click-events-have-key-events": "error",
7
- "@angular-eslint/template/elements-content": "error",
8
- "@angular-eslint/template/interactive-supports-focus": "error",
9
- "@angular-eslint/template/label-has-associated-control": "error",
10
- "@angular-eslint/template/mouse-events-have-key-events": "error",
11
- "@angular-eslint/template/no-autofocus": "error",
12
- "@angular-eslint/template/no-distracting-elements": "error",
13
- "@angular-eslint/template/role-has-required-aria": "error",
14
- "@angular-eslint/template/table-scope": "error",
15
- "@angular-eslint/template/valid-aria": "error"
16
- }
2
+ "parser": "@angular-eslint/template-parser",
3
+ "plugins": ["@angular-eslint/template"],
4
+ "rules": {
5
+ "@angular-eslint/template/alt-text": "error",
6
+ "@angular-eslint/template/click-events-have-key-events": "error",
7
+ "@angular-eslint/template/elements-content": "error",
8
+ "@angular-eslint/template/interactive-supports-focus": "error",
9
+ "@angular-eslint/template/label-has-associated-control": "error",
10
+ "@angular-eslint/template/mouse-events-have-key-events": "error",
11
+ "@angular-eslint/template/no-autofocus": "error",
12
+ "@angular-eslint/template/no-distracting-elements": "error",
13
+ "@angular-eslint/template/role-has-required-aria": "error",
14
+ "@angular-eslint/template/table-scope": "error",
15
+ "@angular-eslint/template/valid-aria": "error"
16
+ }
17
17
  }
@@ -1,35 +1,35 @@
1
1
  {
2
- "parser": "@angular-eslint/template-parser",
3
- "plugins": ["@angular-eslint/template"],
4
- "rules": {
5
- "@angular-eslint/template/alt-text": "error",
6
- "@angular-eslint/template/attributes-order": "error",
7
- "@angular-eslint/template/banana-in-box": "error",
8
- "@angular-eslint/template/button-has-type": "error",
9
- "@angular-eslint/template/click-events-have-key-events": "error",
10
- "@angular-eslint/template/conditional-complexity": "error",
11
- "@angular-eslint/template/cyclomatic-complexity": "error",
12
- "@angular-eslint/template/elements-content": "error",
13
- "@angular-eslint/template/eqeqeq": "error",
14
- "@angular-eslint/template/i18n": "error",
15
- "@angular-eslint/template/interactive-supports-focus": "error",
16
- "@angular-eslint/template/label-has-associated-control": "error",
17
- "@angular-eslint/template/mouse-events-have-key-events": "error",
18
- "@angular-eslint/template/no-any": "error",
19
- "@angular-eslint/template/no-autofocus": "error",
20
- "@angular-eslint/template/no-call-expression": "error",
21
- "@angular-eslint/template/no-distracting-elements": "error",
22
- "@angular-eslint/template/no-duplicate-attributes": "error",
23
- "@angular-eslint/template/no-inline-styles": "error",
24
- "@angular-eslint/template/no-interpolation-in-attributes": "error",
25
- "@angular-eslint/template/no-negated-async": "error",
26
- "@angular-eslint/template/no-positive-tabindex": "error",
27
- "@angular-eslint/template/prefer-control-flow": "error",
28
- "@angular-eslint/template/prefer-ngsrc": "error",
29
- "@angular-eslint/template/prefer-self-closing-tags": "error",
30
- "@angular-eslint/template/role-has-required-aria": "error",
31
- "@angular-eslint/template/table-scope": "error",
32
- "@angular-eslint/template/use-track-by-function": "error",
33
- "@angular-eslint/template/valid-aria": "error"
34
- }
2
+ "parser": "@angular-eslint/template-parser",
3
+ "plugins": ["@angular-eslint/template"],
4
+ "rules": {
5
+ "@angular-eslint/template/alt-text": "error",
6
+ "@angular-eslint/template/attributes-order": "error",
7
+ "@angular-eslint/template/banana-in-box": "error",
8
+ "@angular-eslint/template/button-has-type": "error",
9
+ "@angular-eslint/template/click-events-have-key-events": "error",
10
+ "@angular-eslint/template/conditional-complexity": "error",
11
+ "@angular-eslint/template/cyclomatic-complexity": "error",
12
+ "@angular-eslint/template/elements-content": "error",
13
+ "@angular-eslint/template/eqeqeq": "error",
14
+ "@angular-eslint/template/i18n": "error",
15
+ "@angular-eslint/template/interactive-supports-focus": "error",
16
+ "@angular-eslint/template/label-has-associated-control": "error",
17
+ "@angular-eslint/template/mouse-events-have-key-events": "error",
18
+ "@angular-eslint/template/no-any": "error",
19
+ "@angular-eslint/template/no-autofocus": "error",
20
+ "@angular-eslint/template/no-call-expression": "error",
21
+ "@angular-eslint/template/no-distracting-elements": "error",
22
+ "@angular-eslint/template/no-duplicate-attributes": "error",
23
+ "@angular-eslint/template/no-inline-styles": "error",
24
+ "@angular-eslint/template/no-interpolation-in-attributes": "error",
25
+ "@angular-eslint/template/no-negated-async": "error",
26
+ "@angular-eslint/template/no-positive-tabindex": "error",
27
+ "@angular-eslint/template/prefer-control-flow": "error",
28
+ "@angular-eslint/template/prefer-ngsrc": "error",
29
+ "@angular-eslint/template/prefer-self-closing-tags": "error",
30
+ "@angular-eslint/template/role-has-required-aria": "error",
31
+ "@angular-eslint/template/table-scope": "error",
32
+ "@angular-eslint/template/use-track-by-function": "error",
33
+ "@angular-eslint/template/valid-aria": "error"
34
+ }
35
35
  }
@@ -1,9 +1,9 @@
1
1
  {
2
- "parser": "@typescript-eslint/parser",
3
- "parserOptions": {
4
- "ecmaVersion": 2020,
5
- "sourceType": "module"
6
- },
7
- "plugins": ["@angular-eslint/template"],
8
- "processor": "@angular-eslint/template/extract-inline-html"
2
+ "parser": "@typescript-eslint/parser",
3
+ "parserOptions": {
4
+ "ecmaVersion": 2020,
5
+ "sourceType": "module"
6
+ },
7
+ "plugins": ["@angular-eslint/template"],
8
+ "processor": "@angular-eslint/template/extract-inline-html"
9
9
  }
@@ -1,9 +1,9 @@
1
1
  {
2
- "parser": "@angular-eslint/template-parser",
3
- "plugins": ["@angular-eslint/template"],
4
- "rules": {
5
- "@angular-eslint/template/banana-in-box": "error",
6
- "@angular-eslint/template/eqeqeq": "error",
7
- "@angular-eslint/template/no-negated-async": "error"
8
- }
2
+ "parser": "@angular-eslint/template-parser",
3
+ "plugins": ["@angular-eslint/template"],
4
+ "rules": {
5
+ "@angular-eslint/template/banana-in-box": "error",
6
+ "@angular-eslint/template/eqeqeq": "error",
7
+ "@angular-eslint/template/no-negated-async": "error"
8
+ }
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"prefer-self-closing-tags.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-self-closing-tags.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,0BAA0B,CAAC;AAClD,eAAO,MAAM,SAAS,6BAA6B,CAAC;;AAEpD,wBA2HG"}
1
+ {"version":3,"file":"prefer-self-closing-tags.d.ts","sourceRoot":"","sources":["../../src/rules/prefer-self-closing-tags.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,0BAA0B,CAAC;AAClD,eAAO,MAAM,SAAS,6BAA6B,CAAC;;AAEpD,wBAkIG"}
@@ -22,6 +22,11 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
22
22
  defaultOptions: [],
23
23
  create(context) {
24
24
  const parserServices = (0, utils_1.getTemplateParserServices)(context);
25
+ // angular 18 doesnt support self closing tags in index.html
26
+ if (context.physicalFilename.endsWith('src/index.html')) {
27
+ // If it is, return an empty object to skip this rule
28
+ return {};
29
+ }
25
30
  return {
26
31
  'Element$1, Template, Content'(node) {
27
32
  if (isContentNode(node)) {
@@ -65,17 +70,20 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
65
70
  const { sourceSpan } = node;
66
71
  const ngContentCloseTag = '</ng-content>';
67
72
  if (sourceSpan.toString().includes(ngContentCloseTag)) {
68
- // content nodes can only contain whitespaces
69
- const content = sourceSpan
73
+ const whiteSpaceContent = sourceSpan
70
74
  .toString()
71
75
  .match(/>(\s*)</m)
72
- ?.at(1) ?? '';
76
+ ?.at(1);
77
+ const hasContent = typeof whiteSpaceContent === 'undefined';
78
+ if (hasContent) {
79
+ return;
80
+ }
73
81
  const openingTagLastChar =
74
82
  // This is more than the minimum length of a ng-content element
75
83
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
76
84
  sourceSpan
77
85
  .toString()
78
- .at(-2 - ngContentCloseTag.length - content.length);
86
+ .at(-2 - ngContentCloseTag.length - whiteSpaceContent.length);
79
87
  const closingTagPrefix = getClosingTagPrefix(openingTagLastChar);
80
88
  context.report({
81
89
  // content nodes don't have information about startSourceSpan and endSourceSpan,
@@ -94,7 +102,7 @@ exports.default = (0, create_eslint_rule_1.createESLintRule)({
94
102
  fix: (fixer) => fixer.replaceTextRange([
95
103
  sourceSpan.end.offset -
96
104
  ngContentCloseTag.length -
97
- content.length -
105
+ whiteSpaceContent.length -
98
106
  1,
99
107
  sourceSpan.end.offset,
100
108
  ], closingTagPrefix + '/>'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-eslint/eslint-plugin-template",
3
- "version": "18.0.2-alpha.1",
3
+ "version": "18.0.2-alpha.10",
4
4
  "description": "ESLint plugin for Angular Templates",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -18,17 +18,17 @@
18
18
  "LICENSE"
19
19
  ],
20
20
  "dependencies": {
21
- "@angular-eslint/bundled-angular-compiler": "18.0.2-alpha.1",
22
- "@angular-eslint/utils": "18.0.2-alpha.1",
21
+ "@angular-eslint/bundled-angular-compiler": "18.0.2-alpha.10",
22
+ "@angular-eslint/utils": "18.0.2-alpha.10",
23
23
  "aria-query": "5.3.0",
24
24
  "axobject-query": "4.0.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@angular-eslint/test-utils": "18.0.2-alpha.1",
27
+ "@angular-eslint/test-utils": "18.0.2-alpha.10",
28
28
  "@types/aria-query": "5.0.4"
29
29
  },
30
30
  "peerDependencies": {
31
- "@typescript-eslint/utils": "^7.11.0 || ^8.0.0-alpha.20",
31
+ "@typescript-eslint/utils": "^7.11.0 || ^8.0.0-alpha.37",
32
32
  "eslint": "^8.57.0 || ^9.0.0",
33
33
  "typescript": "*"
34
34
  },