prettier常用配置项

7/27/2022 prettier格式化

# 常用配置

"tabWidth": 2,
"printWidth": 100,
"semi": true,
"singleQuote": true,
"arrowParens": "always",
"bracketSpacing": true,
"trailingComma": "all"
1
2
3
4
5
6
7
复制代码

# 配置项详解

配置项 描述
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,
};
1
2
3
4
5
6
7
8
9
复制代码

# .prettierignore 配置

# 忽略的文件夹:
build/
coverage/
.vscode/
docker/
node_modules/
.temp/

# 忽略的文件
*.html
*.js
1
2
3
4
5
6
7
8
9
10
11
复制代码
上次更新: 2025/03/12 17:39:43
最近更新
01
Mac技巧之苹果电脑睡眠唤醒后 WiFi 网速变慢甚至连不上网的解决方法
07-17
02
2024最新国内外手机短信验证码接码平台收集汇总(可免费用)
03-18
03
千股千炒
03-7
Powered By Valine
v1.4.18