How to use the prettier/standalone.format function in prettier

To help you get started, we’ve selected a few prettier examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neo-one-suite / neo-one / packages / neo-one-smart-contract-codegen / src / formatFile.ts View on Github external
const formatSingleFile = (value: string, browserify: boolean) => {
  const result = `// tslint:disable\n/* eslint-disable */\n${prettier.format(value, {
    arrowParens: 'always',
    parser: 'typescript',
    plugins: [parser],
    printWidth: 120,
    singleQuote: true,
    trailingComma: 'all',
  })}`;

  return browserify ? result.replace(/'@neo-one\/client'/gu, "'@neo-one/client-browserify'") : result;
};
github pmt-mcpe-fun / website / components / PMFDecoder.jsx View on Github external
this.setState({
      loading: false
    })

    if (response.headers.get('Content-Type') !== 'application/json') {
      return this.setState({
        error: await response.text()
      })
    }

    const json = await response.json()
    let plugin = { ...json }
    plugin.code = `
github GitbookIO / slate-hyperprint / src / index.js View on Github external
optionsParam?: Options = DEFAULT_OPTIONS
) {
    if (!model) {
        throw new Error('slate-hyperprint: Expected a Slate model');
    }

    const options = {
        ...DEFAULT_OPTIONS,
        ...optionsParam
    };

    const printed = parse(model, options)
        .map(tag => tag.print(options))
        .join('\n');

    const formatted = prettier.format(printed, {
        ...options.prettier,
        parser: 'babylon',
        plugins: [babylon]
    });

    const noSemi = formatted.trim().replace(/^;/, '');

    return noSemi;
}
github citycide / param.macro / playground / src / index.js View on Github external
)
}, 1000)

const syntaxPlugins = Object.keys(availablePlugins)
  .filter(it.startsWith('syntax') && it !== 'syntax-flow')
  .map(it === 'syntax-decorators' ? [it, { decoratorsBeforeExport: false }] : it)
  .map(it === 'syntax-pipeline-operator' ? [it, { proposal: 'minimal' }] : it)

const compilerPlugins = [...syntaxPlugins, plugin]

const compileSource = transform(_, {
  presets: [],
  plugins: compilerPlugins
}).code

const formatCompiled = prettier.format(_, {
  parser: 'babylon',
  plugins: [babylon],
  printWidth: 50,
  useTabs: false,
  tabWidth: 2,
  singleQuote: true,
  semi: false
})

const handleCodeChange = () => {
  const pos = editor.getSelection().getCursor()
  const source = editor.getValue()

  let initial
  try {
    initial = compileSource(source)
github prettier / prettier-chrome-extension / extension / src / content / index.js View on Github external
buttonElem.addEventListener("click", event => {
          event.preventDefault();
          const formattedText = prettier.format(textArea.value, {
            parser: "markdown",
            plugins: prettierPlugins
          });
          textArea.focus();
          textArea.select();
          document.execCommand("delete", false, null);
          document.execCommand("insertText", false, formattedText);
        });
      }
github dai-shi / react-tracked / website / custom_modules / docusaurus-remark-plugin-ts2js / src / index.js View on Github external
const format = (code) => prettier.format(code, {
  parser: 'typescript',
  plugins: [parserTypescript],
  singleQuote: true,
  trailingComma: 'all',
});
github saasify-sh / saasify / packages / react-saasify / src / components / ServiceForm / ServiceInputJSON.js View on Github external
const [value, setValue] = useState(() =>
    prettier.format(JSON.stringify(defaultValue), {
      parser: 'json',
      plugins: [prettierBabylon]
    })
  )
github tomjschuster / sequelize-ui / src / utils.js View on Github external
const zipFile = (zip, { name, content, config }) =>
  zip.file(name, prettier.format(content, config.prettier))
github bitcrowd / tickety-tick / src / common / format / pretty-print.js View on Github external
function format(text, width) {
  const options = { ...config, printWidth: width, proseWrap: 'always' };
  return prettier.format(text, options);
}
github webiny / webiny-js / packages / storybook-utils / src / CodeBlock / index.js View on Github external
return (
            
                
                    {this.props.copy && (
                        <div> this.copy(source)} className="container"&gt;
                            {this.state.copied ? (
                                <span>Copied!</span>
                            ) : (
                                <span>Copy</span>
                            )}
                        </div>
                    )}
                

                
                    {prettier
                        .format(source, { parser: "babylon", plugins: [babylon] })
                        .replace("&gt;;", "&gt;")}
                
            
        );
    }
}