MCPcopy Create free account
hub / github.com/composify-js/composify / prettify

Function prettify

packages/react/src/editor/CodeEditor/CodeEditor.tsx:13–29  ·  view source on GitHub ↗
(value: string)

Source from the content-addressed store, hash-verified

11import styles from './CodeEditor.module.css';
12
13const prettify = async (value: string) => {
14 const formattedCode = await prettier
15 .format(value, {
16 parser: 'meriyah',
17 plugins: [meriyahParser, estreePlugin as Plugin],
18 printWidth: 120,
19 tabWidth: 2,
20 useTabs: false,
21 semi: false,
22 bracketSpacing: false,
23 arrowParens: 'avoid' as const,
24 endOfLine: 'lf' as const,
25 })
26 .catch(() => value);
27
28 return formattedCode.replace(/^;/, '').replace(/;$/, '');
29};
30
31export const CodeEditor = () => {
32 const editorRef = useRef<Parameters<OnMount>[0] | null>(null);

Callers 1

CodeEditorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected