Fix K3WX.yaml (comments in map key) bug in yaml-test-suite (#18324)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
1 parent
fad27abf37
commit
a14c44f30e
7 files changed
+108
-1
No files matched your search
@@ -0,0 +1,15 @@
|
||||
#### Use explicit key style for flow-mapping keys with trailing comments (#18324 by @kovsu, @fisker)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```yaml
|
||||
# Input
|
||||
{ "foo" # comment
|
||||
:bar }
|
||||
|
||||
# Prettier stable
|
||||
{ "foo": bar } # comment
|
||||
|
||||
# Prettier main
|
||||
{ ? "foo" # comment
|
||||
: bar }
|
||||
```
|
||||
@@ -135,6 +135,7 @@ function printMappingItem(path, options, print) {
|
||||
isAbsolutelyPrintedAsSingleLineNode(key.content, options) &&
|
||||
!hasLeadingComments(key.content) &&
|
||||
!hasMiddleComments(key.content) &&
|
||||
!hasTrailingComment(key.content) &&
|
||||
!hasEndComments(key)
|
||||
) {
|
||||
return conditionalGroup([[printedKey, implicitMappingValue]]);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`key.yml format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["yaml"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
{"key" # 1
|
||||
:value}
|
||||
---
|
||||
{["key"] # 2
|
||||
:value}
|
||||
---
|
||||
{
|
||||
# 3
|
||||
"key"
|
||||
:value}
|
||||
---
|
||||
{
|
||||
&[
|
||||
"key",
|
||||
# 4
|
||||
""]
|
||||
:value}
|
||||
---
|
||||
{"key": # 1
|
||||
value}
|
||||
|
||||
=====================================output=====================================
|
||||
{ ? "key" # 1
|
||||
: value }
|
||||
---
|
||||
{ ? ["key"] # 2
|
||||
: value }
|
||||
---
|
||||
{
|
||||
# 3
|
||||
"key": value,
|
||||
}
|
||||
---
|
||||
{ ? & [
|
||||
"key",
|
||||
# 4
|
||||
"",
|
||||
]
|
||||
: value }
|
||||
---
|
||||
{ ? "key" # 1
|
||||
: value }
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1 @@
|
||||
runFormatTest(import.meta, ["yaml"]);
|
||||
@@ -0,0 +1,20 @@
|
||||
{"key" # 1
|
||||
:value}
|
||||
---
|
||||
{["key"] # 2
|
||||
:value}
|
||||
---
|
||||
{
|
||||
# 3
|
||||
"key"
|
||||
:value}
|
||||
---
|
||||
{
|
||||
&[
|
||||
"key",
|
||||
# 4
|
||||
""]
|
||||
:value}
|
||||
---
|
||||
{"key": # 1
|
||||
value}
|
||||
@@ -3847,6 +3847,24 @@ printWidth: 80
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`snippet: K3WX.yaml - Colon and adjacent value after comment on next line format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["yaml"]
|
||||
printWidth: 80
|
||||
| printWidth
|
||||
=====================================input======================================
|
||||
---
|
||||
{ "foo" # comment
|
||||
:bar }
|
||||
|
||||
=====================================output=====================================
|
||||
---
|
||||
{ ? "foo" # comment
|
||||
: bar }
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`snippet: K4SU.yaml - Multiple Entry Block Sequence format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["yaml"]
|
||||
|
||||
@@ -20,7 +20,6 @@ const BUGS = new Set([
|
||||
"DE56-4.yaml",
|
||||
"JEF9-2.yaml",
|
||||
"JEF9-3.yaml",
|
||||
"K3WX.yaml",
|
||||
"L24T-2.yaml",
|
||||
]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user