Files
geg-gas-web/src/utils/codeformat.ts

20 lines
585 B
TypeScript
Raw Normal View History

import prettier from 'prettier/standalone';
import parserHtml from 'prettier/parser-html';
import parserTs from 'prettier/parser-typescript';
import parserBabel from 'prettier/parser-babel';
export const formatCode = (code: string, type = 'typescript'): string => {
return prettier.format(code, {
semi: true,
singleQuote: true,
printWidth: 100,
trailingComma: 'all',
proseWrap: 'never',
htmlWhitespaceSensitivity: 'strict',
endOfLine: 'auto',
paser: type,
plugins: [parserTs, parserBabel, parserHtml],
vueIndentScriptAndStyle: true,
});
};