Skip to content

[prefer-self-closing-tags] autofix removes comment between element tags #1715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
berkinsansal opened this issue Jan 29, 2024 · 2 comments · Fixed by #2229 or #2256
Closed
2 tasks done

[prefer-self-closing-tags] autofix removes comment between element tags #1715

berkinsansal opened this issue Jan 29, 2024 · 2 comments · Fixed by #2229 or #2256
Labels
package: eslint-plugin-template Angular Template rules triage This issue needs to be looked at and categorized by a maintainer

Comments

@berkinsansal
Copy link

berkinsansal commented Jan 29, 2024

Description and reproduction of the issue

The self-closing tag rule considers an element with a comment as an empty tag.
But this causes code and information loss, we need comments as a team in our development process.
The autofix removes the comment, example is below.

{
  "rules": {
    "@angular-eslint/template/prefer-self-closing-tags": ["error"]
  }
}
<!-- input -->
<ngx-datatable
  #table
  [rows]="rows"
  [columns]="columns">
  <!-- <commented-out-element
      [someAttribute]="string"
    ></commented-out-element> -->
  <!-- SOME OTHER COMMENTS -->
</ngx-datatable>
<!-- auto fixed output -->
<ngx-datatable
  #table
  [rows]="rows"
  [columns]="columns" />

Versions

package version
@angular-eslint/eslint-plugin-template 16.3.1
@angular-eslint/template-parser 16.3.1
@typescript-eslint/parser 6.19.1
ESLint 8.56.0
node 18.17.0
# Please run `npx ng version` in your project and paste the full output here:

Angular CLI: 16.2.12
Node: 18.17.0
Package Manager: npm 9.6.7
OS: win32 x64

Angular: 16.2.12
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1602.12
@angular-devkit/build-angular   16.2.12
@angular-devkit/core            16.0.6
@angular-devkit/schematics      16.0.6
@angular/cdk                    16.2.13
@schematics/angular             16.2.12
ng-packagr                      16.2.3
rxjs                            7.8.1
typescript                      5.0.4
zone.js                         0.13.3
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest supported version of the packages and checked my ng version output per the instructions given here.
@berkinsansal berkinsansal added package: eslint-plugin-template Angular Template rules triage This issue needs to be looked at and categorized by a maintainer labels Jan 29, 2024
@reduckted
Copy link
Contributor

This will be fixed by #2229

@reduckted
Copy link
Contributor

Actually, this wasn't fixed by #2229. It will be fixed by #2256.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: eslint-plugin-template Angular Template rules triage This issue needs to be looked at and categorized by a maintainer
Projects
None yet
2 participants