Fix unstable yaml print (#8355)

This commit is contained in:
fisker Cheung authored and GitHub committed 2020-05-21 19:04:06 +08:00
1 parent 9c2e9d5eb3
commit 8ebda75fec
3 files changed
+37 -5

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
#### Fix unstable format with `prettier-ignore` ([#8355](https://github.com/prettier/prettier/pull/8355) by [@fisker](https://github.com/fisker))
<!-- prettier-ignore -->
```yaml
# Input
# prettier-ignore
---
prettier: true
...
hello: world
# Prettier stable
# prettier-ignore
---
prettier: true
---
hello: world
# Prettier stable (Second format)
# prettier-ignore
---
prettier: true
---
hello: world
# Prettier master
# prettier-ignore
---
prettier: true
---
hello: world
```
+3 -4
View File
@@ -107,10 +107,9 @@ function genericPrint(path, options, print) {
hasPrettierIgnore(path)
? concat(
replaceEndOfLineWith(
options.originalText.slice(
node.position.start.offset,
node.position.end.offset
),
options.originalText
.slice(node.position.start.offset, node.position.end.offset)
.trimEnd(),
literalline
)
)
-1
View File
@@ -39,7 +39,6 @@ const unstableTests = new Map(
(options) => options.proseWrap === "always",
],
["js/no-semi/comments.js", (options) => options.semi === false],
"yaml/prettier-ignore/document.yml",
].map((fixture) => {
const [file, isUnstable = () => true] = Array.isArray(fixture)
? fixture