Skip to content

Commit 7ca4e69

Browse files
committed
fix: update parser
1 parent 9e60e80 commit 7ca4e69

19 files changed

Lines changed: 114 additions & 197 deletions

File tree

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
"typescript-eslint-parser": "16.0.0",
5959
"unicode-regex": "1.0.1",
6060
"unified": "6.1.6",
61-
"yaml": "1.0.0-beta.5",
62-
"yaml-unist-parser": "1.0.0-beta.3"
61+
"yaml": "1.0.0-beta.7",
62+
"yaml-unist-parser": "1.0.0-beta.4"
6363
},
6464
"devDependencies": {
6565
"@babel/cli": "7.0.0-beta.49",

src/language-yaml/printer-yaml.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,7 @@ function _print(node, parentNode, path, options, print) {
314314
return join(hardline, path.map(print, "children"));
315315
case "mappingItem":
316316
case "flowMappingItem": {
317-
return ((node.type === "flowMappingItem" &&
318-
parentNode.type === "flowSequence") ||
319-
node.type === "mappingItem") &&
317+
return (node.type === "flowMappingItem" || node.type === "mappingItem") &&
320318
node.key.type === "null" &&
321319
node.value.type === "null"
322320
? concat([":", line])
@@ -338,6 +336,12 @@ function _print(node, parentNode, path, options, print) {
338336
options.bracketSpacing
339337
? line
340338
: softline;
339+
const isLastItemEmptyMappingItem =
340+
node.children.length !== 0 &&
341+
(lastItem =>
342+
lastItem.type === "flowMappingItem" &&
343+
lastItem.key.type === "null" &&
344+
lastItem.value.type === "null")(getLast(node.children));
341345
return concat([
342346
openMarker,
343347
indent(
@@ -365,20 +369,10 @@ function _print(node, parentNode, path, options, print) {
365369
"children"
366370
)
367371
),
368-
node.children.length !== 0 &&
369-
(lastChild =>
370-
(node.type === "flowMapping" &&
371-
lastChild.type === "flowMappingItem" &&
372-
lastChild.key.type === "null" &&
373-
lastChild.value.type === "null") ||
374-
(node.type === "flowSequence" &&
375-
lastChild.type === "flowSequenceItem" &&
376-
lastChild.node.type === "null"))(getLast(node.children))
377-
? "," // trailing empty item
378-
: ifBreak(",", "")
372+
ifBreak(",", "")
379373
])
380374
),
381-
bracketSpacing,
375+
isLastItemEmptyMappingItem ? "" : bracketSpacing,
382376
closeMarker
383377
]);
384378
}

tests/yaml_alias/__snapshots__/jsfmt.spec.js.snap

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,3 @@ exports[`common.yml 1`] = `
66
*abc
77
88
`;
9-
10-
exports[`middle-comment.yml 1`] = `
11-
!!str # comment
12-
*123
13-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14-
!!str # comment
15-
*123
16-
17-
`;
18-
19-
exports[`middle-comments.yml 1`] = `
20-
!!str # comment 1
21-
# comment 2
22-
*123
23-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24-
!!str
25-
# comment 1
26-
# comment 2
27-
*123
28-
29-
`;
30-
31-
exports[`props.yml 1`] = `
32-
!!str &anchor *123
33-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34-
!!str &anchor *123
35-
36-
`;
37-
38-
exports[`props-in-map.yml 1`] = `
39-
a: !!str &anchor *123
40-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
41-
a: !!str &anchor *123
42-
43-
`;

tests/yaml_alias/middle-comment.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/yaml_alias/middle-comments.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/yaml_alias/props-in-map.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/yaml_alias/props.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/yaml_flow_mapping/__snapshots__/jsfmt.spec.js.snap

Lines changed: 90 additions & 102 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{: [longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong],: [longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong],: [longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong]}
1+
{a: [longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong],b: [longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong],c: [longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong, longlonglonglonglonglonglonglonglonglonglong]}

tests/yaml_flow_mapping/empty-item.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)