格式化全文代码
sudo npx prettier --write ./src
vscode插件
配置文件
.prettierrc.js
module.exports = {
/** 是否在语句末尾添加分号 */
semi: true,
/** 是否使用单引号而不是双引号 */
singleQuote: true,
/** 缩进的空格数 */
tabWidth: 4,
/** 每行的最大字符数 */
printWidth: 120,
/** object对象里面的key和value值和括号间的空格 */
bracketSameLine: true,
/** 箭头函数的参数是否总是用括号包裹 */
arrowParens: 'always',
/** 在JSX中是否使用单引号而不是双引号 */
jsxSingleQuote: true,
/** 在对象字面量中是否添加空格,例如 { foo: bar } */
bracketSpacing: true,
/** object对象中key值是否加引号 */
quoteProps: 'consistent',
/** 尾部逗号设置 */
trailingComma: 'es5',
};