Angular: Support comments in start tag (#19465)

This commit is contained in:
fisker Cheung authored and GitHub committed 2026-06-26 19:43:04 +08:00
1 parent 9ed48ccb14
commit af720efb42
19 files changed
+315 -47

No files matched your search

@@ -0,0 +1,144 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`merge-into-text.html format 1`] = `
====================================options=====================================
parsers: ["angular"]
printWidth: 80 (default) |
=====================================input======================================
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
"<strong>seddoeiusmod</strong>".
</div>
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
"<strong /*
comment
*/>seddoeiusmod</strong>".
</div>
=====================================output=====================================
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
"<strong>seddoeiusmod</strong>".
</div>
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, "<strong
/*
comment
*/
>seddoeiusmod</strong
>".
</div>
================================================================================
`;
exports[`start-tag-comments.html format 1`] = `
====================================options=====================================
parsers: ["angular"]
printWidth: 80 (default) |
=====================================input======================================
<div
// comment 0
/* comment 1 */
attr1="value1"
/*
comment 2
spanning multiple lines
*/
attr2="value2"
></div>
<div // line comment
></div>
<div // line comment
disabled
></div>
<div /* block comment */
></div>
<div /* block comment */
disabled
></div>
<div /* block comment */></div>
<div /* block comment */ disabled></div>
<div
/*
line 1
line 2
*/
></div>
<div><div>
<div /*
should not indent
*/></div>
</div></div>
<div><div>
<div /**
* TODO: This comment should aligned
*/></div>
</div></div>
=====================================output=====================================
<div
// comment 0
/* comment 1 */
attr1="value1"
/*
comment 2
spanning multiple lines
*/
attr2="value2"
></div>
<div
// line comment
></div>
<div
// line comment
disabled
></div>
<div /* block comment */></div>
<div /* block comment */ disabled></div>
<div /* block comment */></div>
<div /* block comment */ disabled></div>
<div
/*
line 1
line 2
*/
></div>
<div>
<div>
<div
/*
should not indent
*/
></div>
</div>
</div>
<div>
<div>
<div
/**
* TODO: This comment should aligned
*/
></div>
</div>
</div>
================================================================================
`;
@@ -0,0 +1 @@
runFormatTest(import.meta, ["angular"]);
@@ -0,0 +1,11 @@
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
"<strong>seddoeiusmod</strong>".
</div>
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
"<strong /*
comment
*/>seddoeiusmod</strong>".
</div>
@@ -0,0 +1,45 @@
<div
// comment 0
/* comment 1 */
attr1="value1"
/*
comment 2
spanning multiple lines
*/
attr2="value2"
></div>
<div // line comment
></div>
<div // line comment
disabled
></div>
<div /* block comment */
></div>
<div /* block comment */
disabled
></div>
<div /* block comment */></div>
<div /* block comment */ disabled></div>
<div
/*
line 1
line 2
*/
></div>
<div><div>
<div /*
should not indent
*/></div>
</div></div>
<div><div>
<div /**
* TODO: This comment should aligned
*/></div>
</div></div>
@@ -1,8 +0,0 @@
runFormatTest(import.meta, [
"html",
"vue",
"lwc",
"mjml",
// https://github.com/prettier/prettier/issues/18974
"angular",
]);
@@ -1,13 +1,5 @@
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
exports[`block-comment.html format[angular] 1`] = `
"Opening tag "div" not terminated. (1:1)
> 1 | <div /* block comment */></div>
| ^^^^^^
2 |
Cause: Opening tag "div" not terminated."
`;
exports[`block-comment.html format[html] 1`] = `
"Opening tag "div" not terminated. (1:1)
> 1 | <div /* block comment */></div>
@@ -40,15 +32,6 @@ exports[`block-comment.html format[vue] 1`] = `
Cause: Opening tag "div" not terminated."
`;
exports[`line-comment.html format[angular] 1`] = `
"Opening tag "div" not terminated. (1:1)
> 1 | <div // line comment
| ^^^^^^
2 | ></div>
3 |
Cause: Opening tag "div" not terminated."
`;
exports[`line-comment.html format[html] 1`] = `
"Opening tag "div" not terminated. (1:1)
> 1 | <div // line comment
@@ -0,0 +1 @@
runFormatTest(import.meta, ["html", "vue", "lwc", "mjml"]);