Fix playground (#4541)

master
Lucas Duailibe 2018-05-24 21:11:12 -03:00 committed by GitHub
parent 8f141bfafe
commit f40b82d183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -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;

View File

@ -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);