@angular-eslint/eslint-plugin-template 18.0.2-alpha.0 → 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 +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.0",
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.0",
22
- "@angular-eslint/utils": "18.0.2-alpha.0",
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.0",
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
  },