Force JSON to no trailing comma in multiparser (#3182)

* Force JSON to no trailing comma in multiparser

* Switch to mutate next.options
This commit is contained in:
Lucas Azzola authored and GitHub committed 2017-11-07 22:01:40 +11:00
1 parent 9d616817be
commit e733a7706d
4 files changed
+25

No files matched your search

+3
View File
@@ -14,6 +14,9 @@ function printSubtree(subtreeParser, path, print, options) {
next.options = Object.assign({}, options, next.options, {
originalText: next.text
});
if (next.options.parser === "json") {
next.options.trailingComma = "none";
}
const ast = require("./parser").parse(next.text, next.options);
const astComments = ast.comments;
delete ast.comments;
@@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`trailing_comma.md 1`] = `
\`\`\`json
{
"foo": "bar"
}
\`\`\`
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\`\`\`json
{
"foo": "bar"
}
\`\`\`
`;
@@ -0,0 +1 @@
run_spec(__dirname, { parser: "markdown", trailingComma: "all" });
@@ -0,0 +1,5 @@
```json
{
"foo": "bar"
}
```