Fix multiparser trailing comma regression (#3405)
* Fix multiparser trailing comma regression * Refactor trailing comma applicationmaster
parent
e09359d242
commit
829616dd6c
|
@ -26,12 +26,11 @@ function printSubtree(path, print, options) {
|
|||
function parseAndPrint(text, partialNextOptions, parentOptions) {
|
||||
const nextOptions = Object.assign({}, parentOptions, partialNextOptions, {
|
||||
parentParser: parentOptions.parser,
|
||||
trailingComma:
|
||||
partialNextOptions.parser === "json"
|
||||
? "none"
|
||||
: partialNextOptions.trailingComma,
|
||||
originalText: text
|
||||
});
|
||||
if (nextOptions.parser === "json") {
|
||||
nextOptions.trailingComma = "none";
|
||||
}
|
||||
const ast = require("./parser").parse(text, nextOptions);
|
||||
const astComments = ast.comments;
|
||||
delete ast.comments;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`trailing-comma.md 1`] = `
|
||||
### Some heading
|
||||
|
||||
\`\`\`js
|
||||
someFunctionCall(
|
||||
foo,
|
||||
bar,
|
||||
foobar,
|
||||
sometehingReallyLongAndHairy,
|
||||
somethingElse,
|
||||
breakNow,
|
||||
);
|
||||
\`\`\`
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
### Some heading
|
||||
|
||||
\`\`\`js
|
||||
someFunctionCall(
|
||||
foo,
|
||||
bar,
|
||||
foobar,
|
||||
sometehingReallyLongAndHairy,
|
||||
somethingElse,
|
||||
breakNow,
|
||||
);
|
||||
\`\`\`
|
||||
|
||||
`;
|
|
@ -0,0 +1 @@
|
|||
run_spec(__dirname, ["markdown"], { trailingComma: "all" });
|
|
@ -0,0 +1,12 @@
|
|||
### Some heading
|
||||
|
||||
```js
|
||||
someFunctionCall(
|
||||
foo,
|
||||
bar,
|
||||
foobar,
|
||||
sometehingReallyLongAndHairy,
|
||||
somethingElse,
|
||||
breakNow,
|
||||
);
|
||||
```
|
Loading…
Reference in New Issue