From 42ba638f37869be68a282a318b81db6a3dc5915a Mon Sep 17 00:00:00 2001 From: Ika Date: Fri, 3 Aug 2018 15:10:26 +0800 Subject: [PATCH] fix(yaml): update parser (#4931) * test: add tests * fix(yaml): update parser --- package.json | 4 +- .../__snapshots__/jsfmt.spec.js.snap | 8 +++ .../in-empty-item-without-newlline.yml | 2 + .../__snapshots__/jsfmt.spec.js.snap | 50 +++++++++++++++++++ tests/yaml_mapping/merge-twice.yml | 10 ++++ yarn.lock | 8 +-- 6 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 tests/yaml_comment/in-empty-item-without-newlline.yml create mode 100644 tests/yaml_mapping/merge-twice.yml diff --git a/package.json b/package.json index c4b980810c5e..55d41a9f3ec0 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "typescript-eslint-parser": "17.0.0", "unicode-regex": "1.0.1", "unified": "6.1.6", - "yaml": "1.0.0-rc.7", - "yaml-unist-parser": "1.0.0-rc.3" + "yaml": "ikatyang/yaml#a765c1ee16d6b8a5e715564645f2b85f7e04828b", + "yaml-unist-parser": "ikatyang/yaml-unist-parser#cd4f73325b3fc02a6d17842d0d9cee0dfc729c9b" }, "devDependencies": { "@babel/cli": "7.0.0-beta.55", diff --git a/tests/yaml_comment/__snapshots__/jsfmt.spec.js.snap b/tests/yaml_comment/__snapshots__/jsfmt.spec.js.snap index 556811bf126b..4a751f37a474 100644 --- a/tests/yaml_comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/yaml_comment/__snapshots__/jsfmt.spec.js.snap @@ -94,6 +94,14 @@ A: `; +exports[`in-empty-item-without-newlline.yml - yaml-verify 1`] = ` +a: + #123~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +a: + #123 + +`; + exports[`root.yml - yaml-verify 1`] = ` #hello world ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/yaml_comment/in-empty-item-without-newlline.yml b/tests/yaml_comment/in-empty-item-without-newlline.yml new file mode 100644 index 000000000000..d7c0055c31a2 --- /dev/null +++ b/tests/yaml_comment/in-empty-item-without-newlline.yml @@ -0,0 +1,2 @@ +a: + #123 \ No newline at end of file diff --git a/tests/yaml_mapping/__snapshots__/jsfmt.spec.js.snap b/tests/yaml_mapping/__snapshots__/jsfmt.spec.js.snap index ad044d6bee14..200f6d5069d1 100644 --- a/tests/yaml_mapping/__snapshots__/jsfmt.spec.js.snap +++ b/tests/yaml_mapping/__snapshots__/jsfmt.spec.js.snap @@ -206,6 +206,56 @@ key: `; +exports[`merge-twice.yml - yaml-verify 1`] = ` +.anchors: + - &anchor1 + key: value + - &anchor2 + another: prop + +foo: + bar: baz + <<: *anchor1 + <<: *anchor2 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.anchors: + - &anchor1 + key: value + - &anchor2 + another: prop + +foo: + bar: baz + <<: *anchor1 + <<: *anchor2 + +`; + +exports[`merge-twice.yml - yaml-verify 2`] = ` +.anchors: + - &anchor1 + key: value + - &anchor2 + another: prop + +foo: + bar: baz + <<: *anchor1 + <<: *anchor2 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.anchors: + - &anchor1 + key: value + - &anchor2 + another: prop + +foo: + bar: baz + <<: *anchor1 + <<: *anchor2 + +`; + exports[`middle-comment.yml - yaml-verify 1`] = ` !!map # comment a: 123 diff --git a/tests/yaml_mapping/merge-twice.yml b/tests/yaml_mapping/merge-twice.yml new file mode 100644 index 000000000000..809f9d5c4a2e --- /dev/null +++ b/tests/yaml_mapping/merge-twice.yml @@ -0,0 +1,10 @@ +.anchors: + - &anchor1 + key: value + - &anchor2 + another: prop + +foo: + bar: baz + <<: *anchor1 + <<: *anchor2 diff --git a/yarn.lock b/yarn.lock index d722294f6139..1fc9adbf50e1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6086,16 +6086,16 @@ yallist@^3.0.0, yallist@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" -yaml-unist-parser@1.0.0-rc.3: +yaml-unist-parser@ikatyang/yaml-unist-parser#cd4f73325b3fc02a6d17842d0d9cee0dfc729c9b: version "1.0.0-rc.3" - resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.0.0-rc.3.tgz#d7b396353da92c75bb471a9e65973ba967e0b4f6" + resolved "https://codeload.github.com/ikatyang/yaml-unist-parser/tar.gz/cd4f73325b3fc02a6d17842d0d9cee0dfc729c9b" dependencies: lines-and-columns "^1.1.6" tslib "^1.9.1" -yaml@1.0.0-rc.7: +yaml@ikatyang/yaml#a765c1ee16d6b8a5e715564645f2b85f7e04828b: version "1.0.0-rc.7" - resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.0.0-rc.7.tgz#7cf9dba3c78992542b7a2d7cb9a7eeacbff63f77" + resolved "https://codeload.github.com/ikatyang/yaml/tar.gz/a765c1ee16d6b8a5e715564645f2b85f7e04828b" yargs-parser@^7.0.0: version "7.0.0"