From 28dd59dcb46944a9d42e98712532397378319dec Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Wed, 6 Sep 2017 23:09:24 +0530 Subject: [PATCH] format code --- components/ConversionPanel.js | 86 +++--- components/Layout.js | 35 ++- pages/css-to-js.js | 4 +- pages/graphql-to-flow.js | 2 +- pages/graphql-to-typescript.js | 2 +- pages/html-to-jsx.js | 14 +- pages/index.js | 11 +- pages/js-object-to-json.js | 9 +- pages/json-to-flow-types.js | 4 +- pages/json-to-go.js | 6 +- pages/json-to-rust-serde.js | 9 +- pages/json-to-scala-case-class.js | 9 +- pages/json-to-ts-interface.js | 9 +- pages/xml-to-json.js | 10 +- ...babel-plugin-js-to-immutable-prop-types.js | 4 +- utils/graphql-schema.js | 2 +- utils/json-to-go.js | 282 ++++++++++-------- utils/routes.js | 14 +- 18 files changed, 285 insertions(+), 227 deletions(-) diff --git a/components/ConversionPanel.js b/components/ConversionPanel.js index 71627eb..5dcbd30 100644 --- a/components/ConversionPanel.js +++ b/components/ConversionPanel.js @@ -20,14 +20,14 @@ if (isBrowser) { } const prettierParsers = { - css: 'postcss', - javascript: 'babylon', - jsx: 'babylon', - graphql: 'graphql', - json: 'json', - typescript: 'typescript', - flow: 'flow' -} + css: "postcss", + javascript: "babylon", + jsx: "babylon", + graphql: "graphql", + json: "json", + typescript: "typescript", + flow: "flow" +}; const modeMapping = { javascript: { @@ -46,7 +46,7 @@ const modeMapping = { htmlMode: true }, flow: { - name: 'javascript', + name: "javascript", typescript: true }, mysql: "text/x-mysql", @@ -83,7 +83,7 @@ export default class ConversionPanel extends PureComponent { prettifyRightPanel: true, splitLeft: false, showFetchButton: true, - fetchButtonText: 'Fetch JSON from URL' + fetchButtonText: "Fetch JSON from URL" }; state = { @@ -97,16 +97,16 @@ export default class ConversionPanel extends PureComponent { componentDidMount() { const { defaultText, splitValue } = this.props; - this.onChange(defaultText, splitValue) + this.onChange(defaultText, splitValue); } fetchJSON = async () => { - const url = window.prompt('Enter URL to fetch JSON from a remote server.') - if (!url) return - const res = await unfetch(url) - const json = await res.json() - this.onChange(JSON.stringify(json, null, 2)) - } + const url = window.prompt("Enter URL to fetch JSON from a remote server."); + if (!url) return; + const res = await unfetch(url); + const json = await res.json(); + this.onChange(JSON.stringify(json, null, 2)); + }; onChange = async (newValue, leftSplitValue) => { const nValue = newValue || this.state.value; @@ -139,7 +139,7 @@ export default class ConversionPanel extends PureComponent { const checked = e.currentTarget.checked; if (this.props.onCheckboxChange) { this.props.onCheckboxChange(checked, () => { - this.onChange() + this.onChange(); }); } }; @@ -150,32 +150,36 @@ export default class ConversionPanel extends PureComponent { }); }; - setSplitValue = splitValue => this.setState({splitValue}) + setSplitValue = splitValue => this.setState({ splitValue }); prettifyCode = () => { const { leftMode } = this.props; const { value } = this.state; - this.setResult(prettier.format(value, {parser: prettierParsers[leftMode]})); + this.setResult( + prettier.format(value, { parser: prettierParsers[leftMode] }) + ); }; prettifySplitCode = () => { const { splitMode } = this.props; const { splitValue } = this.state; - this.setSplitValue(prettier.format(splitValue, {parser: prettierParsers[splitMode]})); - } + this.setSplitValue( + prettier.format(splitValue, { parser: prettierParsers[splitMode] }) + ); + }; copyCode = () => { const { rightMode } = this.props; const { resultValue } = this.state; - const parser = prettierParsers[rightMode] + const parser = prettierParsers[rightMode]; copy( parser ? prettier.format(resultValue, { - parser - }) + parser + }) : resultValue ); this.setState({ @@ -376,10 +380,17 @@ export default class ConversionPanel extends PureComponent {

{leftTitle}

- {leftMode === 'json' && showFetchButton && } - {prettierParsers[leftMode] && } + {leftMode === "json" && + showFetchButton && ( + + )} + {prettierParsers[leftMode] && ( + + )}
{isBrowser && (

{splitTitle}

- {prettierParsers[splitMode] && } + {prettierParsers[splitMode] && ( + + )}
@@ -434,8 +447,13 @@ export default class ConversionPanel extends PureComponent { {isBrowser && ( Router.prefetch(path)) + componentDidMount() { + routes.forEach(({ path }) => Router.prefetch(path)); } componentWillReceiveProps({ pathname }) { @@ -131,19 +131,24 @@ export default class Layout extends PureComponent { href="https://cdnjs.cloudflare.com/ajax/libs/font-mfizz/2.4.1/font-mfizz.min.css" /> - - - - - - - - - - - - - + + + + + + + + + + + +