fix(playground): backward compatibility for --parser babylon (#5690)

master
Ika 2018-12-28 14:56:58 +08:00 committed by GitHub
parent 3a6c126f86
commit 284764f030
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,7 @@
export default function(parser) {
switch (parser) {
case "babel":
case "babylon": // backward compatibility for v1.15 playground
case "babylon": // backward compatibility
return [
'function HelloWorld({greeting = "hello", greeted = \'"World"\', silent = false, onMouseOver,}) {',
"",

View File

@ -36,6 +36,7 @@ function formatMarkdown(
function getMarkdownSyntax(options) {
switch (options.parser) {
case "babel":
case "babylon": // backward compatibility
case "flow":
return "jsx";
case "typescript":

View File

@ -11,7 +11,9 @@ export function getDefaults(availableOptions, optionNames) {
for (const option of availableOptions) {
if (optionNames.includes(option.name)) {
defaults[option.name] =
option.name === "parser" ? "babel" : option.default;
option.name === "parser"
? "babylon" // TODO(1.16): replace with `babel`
: option.default;
}
}
return defaults;

View File

@ -17,7 +17,7 @@ var parsers = {
importScriptOnce("lib/parser-babylon.js");
return prettierPlugins.babylon.parsers.babel;
},
// backward compatibility for v1.15 playground
// backward compatibility
get babylon() {
importScriptOnce("lib/parser-babylon.js");
return prettierPlugins.babylon.parsers.babylon;