mirror of
https://github.com/ritz078/transform.git
synced 2026-11-22 09:01:31 +03:00
fix(flow): disable syntax checking for flow until a parser is made (#116)
This commit is contained in:
1 parent
7d762c87eb
commit
12cb37783f
4 files changed
+29
-27
No files matched your search
@@ -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({
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{hasPrettier && (
|
||||
{hasPrettier && supportedLanguages.includes(language) && (
|
||||
<Button appearance="primary" onClick={prettify} height={28}>
|
||||
Prettify
|
||||
</Button>
|
||||
|
||||
@@ -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 (
|
||||
<ConversionPanel
|
||||
transformer={transformer}
|
||||
editorTitle="Flow"
|
||||
editorLanguage="flow"
|
||||
editorLanguage="plaintext"
|
||||
editorDefaultValue="flow"
|
||||
resultTitle="TypeScript"
|
||||
resultLanguage={"typescript"}
|
||||
/>
|
||||
|
||||
@@ -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)
|
||||
];
|
||||
+1
-22
@@ -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;
|
||||
|
||||
|
||||
Reference in new issue
Block a user