---初始化后台管理web页面项目
This commit is contained in:
19
src/utils/codeformat.ts
Normal file
19
src/utils/codeformat.ts
Normal file
@ -0,0 +1,19 @@
|
||||
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,
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user