diff --git a/components/EditorPanel.tsx b/components/EditorPanel.tsx
index ea07a08..a33b7d8 100644
--- a/components/EditorPanel.tsx
+++ b/components/EditorPanel.tsx
@@ -18,6 +18,7 @@ import dynamic from "next-server/dynamic";
import copy from "clipboard-copy";
import { getWorker, Wrapper } from "@utils/workerWrapper";
import Npm from "@assets/svgs/Npm";
+import { supportedLanguages } from "@utils/prettier";
export interface EditorPanelProps {
editable?: boolean;
@@ -302,7 +303,7 @@ export default function({
)}
- {hasPrettier && (
+ {hasPrettier && supportedLanguages.includes(language) && (
diff --git a/pages/flow-to-typescript.tsx b/pages/flow-to-typescript.tsx
index 700341a..d89b1a0 100644
--- a/pages/flow-to-typescript.tsx
+++ b/pages/flow-to-typescript.tsx
@@ -2,22 +2,23 @@ import ConversionPanel from "@components/ConversionPanel";
import * as React from "react";
import { useCallback } from "react";
-let x;
+let flow2ts;
if (IN_BROWSER) {
require("flow-to-ts");
// @ts-ignore
- x = window.flow2ts;
+ flow2ts = window.flow2ts;
}
export default function() {
const transformer = useCallback(async ({ value }) => {
- return x(value);
+ return flow2ts(value);
}, []);
return (
diff --git a/utils/prettier.ts b/utils/prettier.ts
new file mode 100644
index 0000000..a41209f
--- /dev/null
+++ b/utils/prettier.ts
@@ -0,0 +1,21 @@
+export const prettierParsers = {
+ css: "postcss",
+ javascript: "babel",
+ jsx: "babel",
+ svg: "html",
+ xml: "html",
+ typescript: "typescript"
+};
+
+export const supportedLanguages = [
+ "json",
+ "babylon",
+ "html",
+ "postcss",
+ "graphql",
+ "markdown",
+ "yaml",
+ "typescript",
+ "flow",
+ ...Object.keys(prettierParsers)
+];
diff --git a/utils/prettify.ts b/utils/prettify.ts
index d41da42..896d137 100644
--- a/utils/prettify.ts
+++ b/utils/prettify.ts
@@ -1,13 +1,5 @@
import prettier from "prettier/standalone";
-
-const prettierParsers = {
- css: "postcss",
- javascript: "babel",
- jsx: "babel",
- svg: "html",
- xml: "html",
- typescript: "typescript"
-};
+import { prettierParsers, supportedLanguages } from "@utils/prettier";
const plugins = [
require("prettier/parser-babylon"),
@@ -20,19 +12,6 @@ const plugins = [
require("prettier/parser-typescript")
];
-const supportedLanguages = [
- "json",
- "babylon",
- "html",
- "postcss",
- "graphql",
- "markdown",
- "yaml",
- "typescript",
- "flow",
- ...Object.keys(prettierParsers)
-];
-
export async function prettify(language: string, value: string) {
let result;