mirror of
https://github.com/ritz078/transform.git
synced 2026-11-21 00:32:56 +03:00
* feat(init): added EditorPanel with prettier, copy and settings support * chore(static): ignore static * feat: added navigator * feat: * feat(settings): added sessionStorage support for settings * feat(message): add messaging support in editors * feat(preview): added support for preview panel * fix(settings): use localstorage for settings instead of session storage * feat: * feat(css-to-js): implemented React section * feat(schema): add json to schema conversions * feat(others): implemented xml, yaml and markdown conversions * feat(babel): added flow to typescript converter * feat(graphql): implemented graphql to typescript * feat(graphql): added some transformations * fix: add support for different default value in one language * feat(graphql): added components, resolver signatures and mongodb * feat: * scala case class * fix(memory): worker-loader patch applied to fix memory overflow crash * feat: added json schema to typescript * icon: <GraphQLIcon />, * feat(navigator): shorter naming and new categories * route fixes * navigator * perf(workers): create separate file and remove fallback * fix(navigator): completed * build(snack): * fixes * fixes * fix(safari): * added json-to-mobx-state tree * fix(native): snacksession * fixes * added logo * navigator * fixes * custom header * fixes * refactor(settings): move settings to left side * feat: set up redirects * feat(seo): added title and description * feat(error): added custom error page * ga-script * feat: * fixes * fixe * fixes * fixes * fix:
37 lines
824 B
TypeScript
37 lines
824 B
TypeScript
import prettier from "prettier/standalone";
|
|
|
|
const prettierParsers = {
|
|
css: "postcss",
|
|
javascript: "babel",
|
|
jsx: "babel",
|
|
svg: "html",
|
|
xml: "html",
|
|
typescript: "typescript"
|
|
};
|
|
|
|
const plugins = [
|
|
require("prettier/parser-babylon"),
|
|
require("prettier/parser-html"),
|
|
require("prettier/parser-postcss"),
|
|
require("prettier/parser-graphql"),
|
|
require("prettier/parser-markdown"),
|
|
require("prettier/parser-yaml"),
|
|
require("prettier/parser-flow"),
|
|
require("prettier/parser-typescript")
|
|
];
|
|
|
|
export async function prettify(language: string, value: string) {
|
|
let result;
|
|
|
|
if (language === "json") {
|
|
result = JSON.stringify(JSON.parse(value), null, 2);
|
|
} else {
|
|
result = prettier.format(value, {
|
|
parser: prettierParsers[language] || language,
|
|
plugins
|
|
});
|
|
}
|
|
|
|
return result;
|
|
}
|