Fix playground (#4541)
parent
8f141bfafe
commit
f40b82d183
|
@ -10,7 +10,8 @@ export function getDefaults(availableOptions, optionNames) {
|
||||||
const defaults = {};
|
const defaults = {};
|
||||||
for (const option of availableOptions) {
|
for (const option of availableOptions) {
|
||||||
if (optionNames.includes(option.name)) {
|
if (optionNames.includes(option.name)) {
|
||||||
defaults[option.name] = option.default;
|
defaults[option.name] =
|
||||||
|
option.name === "parser" ? "babylon" : option.default;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return defaults;
|
return defaults;
|
||||||
|
|
|
@ -92,7 +92,8 @@ function handleMessage(message) {
|
||||||
delete options.doc;
|
delete options.doc;
|
||||||
delete options.output2;
|
delete options.output2;
|
||||||
|
|
||||||
options.plugins = [{ parsers: parsers }];
|
var plugins = [{ parsers: parsers }];
|
||||||
|
options.plugins = plugins;
|
||||||
|
|
||||||
var response = {
|
var response = {
|
||||||
formatted: formatCode(message.code, options),
|
formatted: formatCode(message.code, options),
|
||||||
|
@ -115,7 +116,7 @@ function handleMessage(message) {
|
||||||
|
|
||||||
if (!errored) {
|
if (!errored) {
|
||||||
try {
|
try {
|
||||||
ast = formatCode(ast, { parser: "json" });
|
ast = formatCode(ast, { parser: "json", plugins: plugins });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ast = JSON.stringify(ast, null, 2);
|
ast = JSON.stringify(ast, null, 2);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +128,7 @@ function handleMessage(message) {
|
||||||
try {
|
try {
|
||||||
response.debug.doc = prettier.__debug.formatDoc(
|
response.debug.doc = prettier.__debug.formatDoc(
|
||||||
prettier.__debug.printToDoc(message.code, options),
|
prettier.__debug.printToDoc(message.code, options),
|
||||||
{ parser: "babylon" }
|
{ parser: "babylon", plugins: plugins }
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
response.debug.doc = String(e);
|
response.debug.doc = String(e);
|
||||||
|
|
Loading…
Reference in New Issue