chore: enable glimmer parser on preview playground (#4915)

master
Ika 2018-08-01 15:44:37 +08:00 committed by GitHub
parent d83ca5a6c6
commit 1915cc3c46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 14 deletions

View File

@ -98,7 +98,7 @@ async function run(params) {
await execa("rm", ["-rf", ".cache"]);
}
const bundleCache = new Cache(".cache/", "v3");
const bundleCache = new Cache(".cache/", "v4");
await bundleCache.load();
console.log(chalk.inverse(" Building packages "));

View File

@ -55,7 +55,7 @@ const parsers = [
},
{
input: "src/language-handlebars/parser-glimmer.js",
target: "node",
target: "universal",
commonjs: {
namedExports: {
"node_modules/handlebars/lib/index.js": ["parse"],

View File

@ -629,6 +629,7 @@ function createOptionUsageType(option) {
return null;
case "choice":
return `<${option.choices
.filter(choice => choice.since !== null)
.filter(choice => !choice.deprecated)
.map(choice => choice.value)
.join("|")}>`;
@ -676,7 +677,9 @@ function getOptionWithLevenSuggestion(context, options, optionName) {
}
function createChoiceUsages(choices, margin, indentation) {
const activeChoices = choices.filter(choice => !choice.deprecated);
const activeChoices = choices.filter(
choice => !choice.deprecated && choice.since !== null
);
const threshold =
activeChoices
.map(choice => choice.value.length)

View File

@ -116,7 +116,12 @@ const options = {
{ value: "graphql", since: "1.5.0", description: "GraphQL" },
{ value: "markdown", since: "1.8.0", description: "Markdown" },
{ value: "vue", since: "1.10.0", description: "Vue" },
{ value: "yaml", since: "1.14.0", description: "YAML" }
{ value: "yaml", since: "1.14.0", description: "YAML" },
{
value: "glimmer",
since: null,
description: "Handlebars"
}
]
},
plugins: {

View File

@ -78,12 +78,7 @@ function getSupportInfo(version, opts) {
const languages = plugins
.reduce((all, plugin) => all.concat(plugin.languages || []), [])
.filter(
language =>
language.since
? semver.gte(version, language.since)
: language.since !== null
)
.filter(filterSince)
.map(language => {
// Prevent breaking changes
if (language.name === "Markdown") {

View File

@ -12,6 +12,7 @@ const internalPlugins = [
require("./src/language-js"),
require("./src/language-css"),
require("./src/language-graphql"),
require("./src/language-handlebars"),
require("./src/language-markdown"),
require("./src/language-vue"),
require("./src/language-yaml")

View File

@ -10,6 +10,7 @@ const sources = [
"parser-flow.js",
"parser-typescript.js",
"parser-postcss.js",
"parser-glimmer.js",
"parser-graphql.js",
"parser-markdown.js",
"parser-vue.js",

View File

@ -127,7 +127,7 @@ function read(filename) {
}
function skipStandalone(parser) {
return new Set(["parse5", "glimmer"]).has(parser);
return new Set(["parse5"]).has(parser);
}
/**

View File

@ -227,6 +227,15 @@ export default function(parser) {
" Billsmer @ 338-4338.",
""
].join("\n");
case "glimmer":
// modified from http://handlebarsjs.com/
return [
' <div class="entry" >',
" <h1>{{ title }}</h1>",
' <div class="body">',
" {{ body }}",
"</div> </div>"
].join("\n");
default:
return "";
}

View File

@ -40,6 +40,11 @@ function getMarkdownSyntax(options) {
return "jsx";
case "typescript":
return "tsx";
case "json":
case "json-stringify":
return "jsonc";
case "glimmer":
return "hbs";
default:
return options.parser;
}

View File

@ -7,15 +7,15 @@ importScripts("https://unpkg.com/sw-toolbox@3.6.0/sw-toolbox.js");
toolbox.precache([
// Scripts
"lib/index.js",
"lib/standalone.js",
"lib/parser-babylon.js",
"lib/parser-typescript.js",
"lib/parser-postcss.js",
"lib/parser-flow.js",
"lib/parser-json-stringify.js",
"lib/parser-glimmer.js",
"lib/parser-graphql.js",
"lib/parser-markdown.js",
"lib/parser-vue.js",
"lib/parser-yaml.js",
"playground.js",
"https://unpkg.com/sw-toolbox@3.6.0/sw-toolbox.js",

View File

@ -76,6 +76,12 @@ var parsers = {
get yaml() {
importScriptOnce("lib/parser-yaml.js");
return prettierPlugins.yaml.parsers.yaml;
},
// Handlebars
get glimmer() {
importScriptOnce("lib/parser-glimmer.js");
return prettierPlugins.glimmer.parsers.glimmer;
}
};
@ -94,7 +100,13 @@ function handleMessage(message) {
if (message.type === "meta") {
return {
type: "meta",
supportInfo: JSON.parse(JSON.stringify(prettier.getSupportInfo())),
supportInfo: JSON.parse(
JSON.stringify(
prettier.getSupportInfo(null, {
showUnreleased: /-pr\./.test(prettier.version)
})
)
),
version: prettier.version
};
}