常用配置
"tabWidth": 2,
"printWidth": 100,
"semi": true,
"singleQuote": true,
"arrowParens": "always",
"bracketSpacing": true,
"trailingComma": "all"
配置项详解
配置项 |
值 |
描述 |
tabWidth |
2 |
缩进字节(2 空格代替 tab) |
printWidth |
100 |
屏幕显示宽度(一行做多容纳字节数,超过自动换行) |
semi |
true |
句尾添加分号 |
singleQuote |
false |
启用单引号 |
arrowParens |
always/avoid |
箭头函数单一参数是否省略括号 |
bracketSpacing |
true |
对象,数组括号与文字之间加空格 { foo: bar } |
trailingComma |
all |
对象或数组末尾加逗号 |
.prettierrc.js 配置
module.exports = {
printWidth: 100,
tabWidth: 2,
semi: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'always',
bracketSpacing: true,
};
.prettierignore 配置
# 忽略的文件夹:
build/
coverage/
.vscode/
docker/
node_modules/
.temp/
# 忽略的文件
*.html
*.js