From 169faf39ac6a17d5bf90df8abde3dacb631a1c4f Mon Sep 17 00:00:00 2001 From: Georgii Dolzhykov Date: Sun, 14 Mar 2021 12:14:08 +0200 Subject: [PATCH] Update yaml to 1.10.2 (#10516) --- changelog_unreleased/yaml/10516.md | 24 +++ cspell.json | 1 + .../mapping/__snapshots__/jsfmt.spec.js.snap | 143 ++++++++++++++++++ tests/yaml/mapping/anchor.yml | 6 + tests/yaml/mapping/anchor2.yml | 7 + tests/yaml/mapping/anchor3.yml | 6 + yarn.lock | 6 +- 7 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 changelog_unreleased/yaml/10516.md create mode 100644 tests/yaml/mapping/anchor.yml create mode 100644 tests/yaml/mapping/anchor2.yml create mode 100644 tests/yaml/mapping/anchor3.yml diff --git a/changelog_unreleased/yaml/10516.md b/changelog_unreleased/yaml/10516.md new file mode 100644 index 000000000..3094ae3e3 --- /dev/null +++ b/changelog_unreleased/yaml/10516.md @@ -0,0 +1,24 @@ +#### Fix SyntaxError incorrectly thrown on anchors followed by empty lines (#10516 by @eemeli & @thorn0) + +Prettier couldn't parse this valid YAML. Thanks to Eemeli Aro for fixing this bug in the underlying parser. + + +```yaml +# Input +key1: &default + + subkey1: value1 + +key2: + <<: *default + +# Prettier stable +SyntaxError: Nested mappings are not allowed in compact mappings (1:7) + +# Prettier main +key1: &default + subkey1: value1 + +key2: + <<: *default +``` diff --git a/cspell.json b/cspell.json index 70cb29467..19e23479c 100644 --- a/cspell.json +++ b/cspell.json @@ -101,6 +101,7 @@ "duailibe", "Duperron", "editorconfig", + "eemeli", "ekkhus", "elektronik", "Eneman", diff --git a/tests/yaml/mapping/__snapshots__/jsfmt.spec.js.snap b/tests/yaml/mapping/__snapshots__/jsfmt.spec.js.snap index 1c854b823..37b1da0b2 100644 --- a/tests/yaml/mapping/__snapshots__/jsfmt.spec.js.snap +++ b/tests/yaml/mapping/__snapshots__/jsfmt.spec.js.snap @@ -53,6 +53,149 @@ printWidth: 80 ================================================================================ `; +exports[`anchor.yml - {"tabWidth":4} format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 +tabWidth: 4 + | printWidth +=====================================input====================================== +key1: &default + + subkey1: value1 + +key2: + <<: *default + +=====================================output===================================== +key1: &default + subkey1: value1 + +key2: + <<: *default + +================================================================================ +`; + +exports[`anchor.yml format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 + | printWidth +=====================================input====================================== +key1: &default + + subkey1: value1 + +key2: + <<: *default + +=====================================output===================================== +key1: &default + subkey1: value1 + +key2: + <<: *default + +================================================================================ +`; + +exports[`anchor2.yml - {"tabWidth":4} format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 +tabWidth: 4 + | printWidth +=====================================input====================================== +key1: &default + + # This key ... + subkey1: value1 + +key2: + <<: *default + +=====================================output===================================== +key1: &default # This key ... + subkey1: value1 + +key2: + <<: *default + +================================================================================ +`; + +exports[`anchor2.yml format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 + | printWidth +=====================================input====================================== +key1: &default + + # This key ... + subkey1: value1 + +key2: + <<: *default + +=====================================output===================================== +key1: &default # This key ... + subkey1: value1 + +key2: + <<: *default + +================================================================================ +`; + +exports[`anchor3.yml - {"tabWidth":4} format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 +tabWidth: 4 + | printWidth +=====================================input====================================== +key1: &default +# This key + subkey1: value1 + +key2: + <<: *default + +=====================================output===================================== +key1: &default # This key + subkey1: value1 + +key2: + <<: *default + +================================================================================ +`; + +exports[`anchor3.yml format 1`] = ` +====================================options===================================== +parsers: ["yaml"] +printWidth: 80 + | printWidth +=====================================input====================================== +key1: &default +# This key + subkey1: value1 + +key2: + <<: *default + +=====================================output===================================== +key1: &default # This key + subkey1: value1 + +key2: + <<: *default + +================================================================================ +`; + exports[`array-key.yml - {"tabWidth":4} format 1`] = ` ====================================options===================================== parsers: ["yaml"] diff --git a/tests/yaml/mapping/anchor.yml b/tests/yaml/mapping/anchor.yml new file mode 100644 index 000000000..89c0b8b5d --- /dev/null +++ b/tests/yaml/mapping/anchor.yml @@ -0,0 +1,6 @@ +key1: &default + + subkey1: value1 + +key2: + <<: *default diff --git a/tests/yaml/mapping/anchor2.yml b/tests/yaml/mapping/anchor2.yml new file mode 100644 index 000000000..8755d9e7d --- /dev/null +++ b/tests/yaml/mapping/anchor2.yml @@ -0,0 +1,7 @@ +key1: &default + + # This key ... + subkey1: value1 + +key2: + <<: *default diff --git a/tests/yaml/mapping/anchor3.yml b/tests/yaml/mapping/anchor3.yml new file mode 100644 index 000000000..85cb33395 --- /dev/null +++ b/tests/yaml/mapping/anchor3.yml @@ -0,0 +1,6 @@ +key1: &default +# This key + subkey1: value1 + +key2: + <<: *default diff --git a/yarn.lock b/yarn.lock index 7f13e37aa..719634f7b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7228,9 +7228,9 @@ yaml-unist-parser@1.3.1: yaml "^1.10.0" yaml@^1.10.0: - version "1.10.0" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e" - integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg== + version "1.10.2" + resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" + integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== yargs-parser@^18.1.2: version "18.1.3"