Fix yaml comment in non-singleline items missing space before # (#16489)

Co-authored-by: SUZUKI Sosuke <aosukeke@gmail.com>
This commit is contained in:
Fu YuchenandSUZUKI Sosuke authored and GitHub committed 2024-10-01 20:54:46 +09:00
1 parent 834786591f
commit 1ce5eeea77
4 files changed
+53

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
#### Fix yaml comment in non-singleline items missing space before `#` (#16489 by @fyc09)
<!-- prettier-ignore -->
```yaml
# Input
123: # hello
# comment
# Prettier stable
123:# hello
# comment
# Prettier main
123: # hello
# comment
```
+2
View File
@@ -112,6 +112,8 @@ function printMappingItem(path, print, options) {
implicitMappingValueParts.push(hardline);
} else if (value.content) {
implicitMappingValueParts.push(line);
} else if (hasTrailingComment(value)) {
implicitMappingValueParts.push(" ");
}
implicitMappingValueParts.push(printedValue);
const implicitMappingValue = alignWithSpaces(
@@ -320,6 +320,39 @@ printWidth: 80
================================================================================
`;
exports[`comment-value-align.yml - {"tabWidth":4} format 1`] = `
====================================options=====================================
parsers: ["yaml"]
printWidth: 80
tabWidth: 4
| printWidth
=====================================input======================================
123: # hello
# comment
=====================================output=====================================
123: # hello
# comment
================================================================================
`;
exports[`comment-value-align.yml format 1`] = `
====================================options=====================================
parsers: ["yaml"]
printWidth: 80
| printWidth
=====================================input======================================
123: # hello
# comment
=====================================output=====================================
123: # hello
# comment
================================================================================
`;
exports[`common.yml - {"tabWidth":4} format 1`] = `
====================================options=====================================
parsers: ["yaml"]
@@ -0,0 +1,2 @@
123: # hello
# comment