Skip to content

fix(eslint-plugin-template): [prefer-self-closing-tags] do not treat comments as whitespace #2256

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

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

reduckted
Copy link
Contributor

Fixes #1715

Due to a template parse error that was being suppressed, the valid test case for comments was incorrectly passing.

Comments do not appear in the syntax tree, so we cannot look at the child nodes to determine whether an element is empty. Instead, we need to look at the source code and get the text between the end of the start tag and the start of the end tag. If that is only whitespace, then the element is truly empty.

Copy link

nx-cloud bot commented Feb 22, 2025

View your CI Pipeline Execution ↗ for commit 996802f.

Command Status Duration Result
nx run-many -t e2e-suite --parallel 1 ✅ Succeeded 28s View ↗
nx run-many -t test --codeCoverage ✅ Succeeded 1m 15s View ↗
nx run-many -t build,typecheck,check-rule-docs,... ✅ Succeeded 47s View ↗
nx-cloud record -- pnpm nx sync:check ✅ Succeeded 4s View ↗
nx-cloud record -- pnpm format-check ✅ Succeeded 5s View ↗
nx run-many -t test ✅ Succeeded 22s View ↗
nx run-many -t build ✅ Succeeded 11s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-22 04:12:42 UTC

Copy link

codecov bot commented Feb 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.52%. Comparing base (53a2afe) to head (996802f).
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2256      +/-   ##
==========================================
- Coverage   90.53%   90.52%   -0.01%     
==========================================
  Files         179      179              
  Lines        3559     3557       -2     
  Branches      600      598       -2     
==========================================
- Hits         3222     3220       -2     
  Misses        183      183              
  Partials      154      154              
Flag Coverage Δ
unittest 90.52% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...gin-template/src/rules/prefer-self-closing-tags.ts 100.00% <100.00%> (ø)
...late/tests/rules/prefer-self-closing-tags/cases.ts 100.00% <ø> (ø)

Copy link
Member

@JamesHenry JamesHenry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[prefer-self-closing-tags] autofix removes comment between element tags
2 participants