Fix unstable yaml print (#8355)
This commit is contained in:
1 parent
9c2e9d5eb3
commit
8ebda75fec
3 files changed
+37
-5
No files matched your search
@@ -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
|
||||
|
||||
```
|
||||
@@ -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
|
||||
)
|
||||
)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user