diff --git a/changelog_unreleased/yaml/pr-9143.md b/changelog_unreleased/yaml/pr-9143.md index 9ddb644727ee..772e3f362e6d 100644 --- a/changelog_unreleased/yaml/pr-9143.md +++ b/changelog_unreleased/yaml/pr-9143.md @@ -1,27 +1,41 @@ -#### Fix printing doubles a blank line before a comment (#9143 by @sosukesuzuki) +#### Fix comment printing in mapping and sequence (#9143, #9169 by @sosukesuzuki, @fisker, fix in `yaml-unist-parser` by @ikatyang) ```yaml # Input -- foo: 0 - bar: 1 +- a + # Should indent +- bb - # baz: 2 -- quux: 3 +--- +- a: a + b: b + + # Should print one empty line before +- another # Prettier stable -- foo: 0 - bar: 1 +- a +# Should indent +- bb + +--- +- a: a + b: b - # baz: 2 -- quux: 3 + # Should print one empty line before +- another # Prettier master -- foo: 0 - bar: 1 +- a + # Should indent +- bb - # baz: 2 -- quux: 3 +--- +- a: a + b: b + # Should print one empty line before +- another ``` diff --git a/cspell.json b/cspell.json index c74e75d4340d..053c7f85c52e 100644 --- a/cspell.json +++ b/cspell.json @@ -399,6 +399,7 @@ "ignoreRegExpList": [ "\\n(`{3,})\\w*\\n[\\s\\S]+?\\1", "\\[(\\*{2})?@[-\\w]+?\\1\\]", + "by @[-\\w]+(?:, @[-\\w]+)?", "\\[`\\w+`\\]", "ve{2,}r{2,}y", "ve+r+y+long\\w*", diff --git a/package.json b/package.json index 822a4105a647..e41730820674 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "unicode-regex": "3.0.0", "unified": "9.2.0", "vnopts": "1.0.2", - "yaml-unist-parser": "1.3.0" + "yaml-unist-parser": "1.3.1" }, "devDependencies": { "@babel/core": "7.11.4", diff --git a/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap b/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap index 2217ba604a6d..9e899d762647 100644 --- a/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/yaml/comment/__snapshots__/jsfmt.spec.js.snap @@ -357,7 +357,7 @@ none(2): =====================================output===================================== before: -# before.comment + # before.comment after: # after.comment @@ -512,7 +512,7 @@ printWidth: 80 =====================================output===================================== - before -# before.comment + # before.comment - after # after.comment diff --git a/yarn.lock b/yarn.lock index f18d5b6975f5..ce41b55d0c44 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8469,10 +8469,10 @@ yallist@^4.0.0: resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yaml-unist-parser@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.3.0.tgz#f64f1af96171fe4d7eb462e94225d42a6009b60e" - integrity sha512-kF1OS6fi9BzqX+vVC5hp+R5mmrHLH4f19Nx8fAwb08VqUwgFDBPOOu24VZO06nSOur13CGUTgHuaw5RIzpRnCw== +yaml-unist-parser@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.3.1.tgz#4305a54d8f8750dfff782bb998ff93d0da538d1a" + integrity sha512-4aHBMpYcnByF8l2OKj5hlBJlxSYIMON8Z1Hm57ymbBL4omXMlGgY+pEf4Di6h2qNT8ZG8seTVvAQYNOa7CZ9eA== dependencies: lines-and-columns "^1.1.6" tslib "^1.10.0"