-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
YAML: Apply
trailingComma
option (#9665)
- Loading branch information
Showing
11 changed files
with
753 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#### Apply `trailingComma` option (#9665 by @fisker) | ||
|
||
When `--trailing-comma=none`, should not add trailing comma to flowMapping and flowSequence. | ||
|
||
<!-- prettier-ignore --> | ||
```yaml | ||
# Input | ||
flow-mapping: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here" | ||
} | ||
flow-sequence: | ||
[ | ||
"object-does-not-fit-within-print-width", "------", | ||
"TEST", "comma IS added here" | ||
] | ||
|
||
# Prettier stable | ||
mapping: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here", | ||
} | ||
flow-sequence: | ||
[ | ||
"object-does-not-fit-within-print-width", | ||
"------", | ||
"TEST", | ||
"comma IS added here", | ||
] | ||
|
||
# Prettier master | ||
flow-mapping: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here" | ||
} | ||
flow-sequence: | ||
[ | ||
"object-does-not-fit-within-print-width", | ||
"------", | ||
"TEST", | ||
"comma IS added here" | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
184 changes: 184 additions & 0 deletions
184
tests/yaml/flow-mapping/trailing-comma/__snapshots__/jsfmt.spec.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`flow-mapping.yml - {"trailingComma":"all"} format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["yaml"] | ||
printWidth: 80 | ||
trailingComma: "all" | ||
| printWidth | ||
=====================================input====================================== | ||
failing: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here" | ||
} | ||
expected: | ||
{ | ||
"object-fits-within-print-width": "", | ||
"TEST": "comma NOT here" | ||
} | ||
--- | ||
does not suffice: > | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma NOT here — but object's now a string due to '>'" | ||
} | ||
=====================================output===================================== | ||
failing: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here", | ||
} | ||
expected: { "object-fits-within-print-width": "", "TEST": "comma NOT here" } | ||
--- | ||
does not suffice: > | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma NOT here — but object's now a string due to '>'" | ||
} | ||
================================================================================ | ||
`; | ||
|
||
exports[`flow-mapping.yml - {"trailingComma":"es5"} format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["yaml"] | ||
printWidth: 80 | ||
trailingComma: "es5" | ||
| printWidth | ||
=====================================input====================================== | ||
failing: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here" | ||
} | ||
expected: | ||
{ | ||
"object-fits-within-print-width": "", | ||
"TEST": "comma NOT here" | ||
} | ||
--- | ||
does not suffice: > | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma NOT here — but object's now a string due to '>'" | ||
} | ||
=====================================output===================================== | ||
failing: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here", | ||
} | ||
expected: { "object-fits-within-print-width": "", "TEST": "comma NOT here" } | ||
--- | ||
does not suffice: > | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma NOT here — but object's now a string due to '>'" | ||
} | ||
================================================================================ | ||
`; | ||
|
||
exports[`flow-mapping.yml - {"trailingComma":"none"} format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["yaml"] | ||
printWidth: 80 | ||
trailingComma: "none" | ||
| printWidth | ||
=====================================input====================================== | ||
failing: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here" | ||
} | ||
expected: | ||
{ | ||
"object-fits-within-print-width": "", | ||
"TEST": "comma NOT here" | ||
} | ||
--- | ||
does not suffice: > | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma NOT here — but object's now a string due to '>'" | ||
} | ||
=====================================output===================================== | ||
failing: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here" | ||
} | ||
expected: { "object-fits-within-print-width": "", "TEST": "comma NOT here" } | ||
--- | ||
does not suffice: > | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma NOT here — but object's now a string due to '>'" | ||
} | ||
================================================================================ | ||
`; | ||
|
||
exports[`flow-mapping.yml format 1`] = ` | ||
====================================options===================================== | ||
parsers: ["yaml"] | ||
printWidth: 80 | ||
| printWidth | ||
=====================================input====================================== | ||
failing: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here" | ||
} | ||
expected: | ||
{ | ||
"object-fits-within-print-width": "", | ||
"TEST": "comma NOT here" | ||
} | ||
--- | ||
does not suffice: > | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma NOT here — but object's now a string due to '>'" | ||
} | ||
=====================================output===================================== | ||
failing: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here", | ||
} | ||
expected: { "object-fits-within-print-width": "", "TEST": "comma NOT here" } | ||
--- | ||
does not suffice: > | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma NOT here — but object's now a string due to '>'" | ||
} | ||
================================================================================ | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
failing: | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma IS added here" | ||
} | ||
|
||
expected: | ||
{ | ||
"object-fits-within-print-width": "", | ||
"TEST": "comma NOT here" | ||
} | ||
|
||
--- | ||
|
||
does not suffice: > | ||
{ | ||
"object-does-not-fit-within-print-width": "------", | ||
"TEST": "comma NOT here — but object's now a string due to '>'" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
run_spec(__dirname, ["yaml"]); | ||
run_spec(__dirname, ["yaml"], { trailingComma: "none" }); | ||
run_spec(__dirname, ["yaml"], { trailingComma: "es5" }); | ||
run_spec(__dirname, ["yaml"], { trailingComma: "all" }); |
Oops, something went wrong.