vscode 配置 ¶
在项目根路径配置 项目/.vscode/settings.json
内容如下:
json
{
"editor.formatOnSave": true,
"editor.detectIndentation": false,
"editor.tabSize": 2,
"prettier.configPath": ".vscode/.prettierrc.yaml",
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[jsonc]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[less]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "yzhang.markdown-all-in-one"
}
}
在项目根路径配置 项目/.vscode/.prettierrc.yaml
内容如下:
yaml
#
# ========== ========== ==========
# 【prettier】格式化
# ========== ========== ==========
#
# requireConfig: false,
# tab缩进大小,默认为2,一个tab代表几个空格数
tabWidth: 2
# 是否使用tab进行缩进
useTabs: false
# 指定每行代码的最佳长度, 如果超出长度则换行。
printWidth: 130
#
# 标签 属性是否换行
# 超过tabWidth换行 [ always ]
# 不换行 [ never ]
# 按照文件原样换行 [ preserve ]
#
proseWrap: 'always'
# 开头标签的【>】结尾 单独一行
htmlWhitespaceSensitivity: 'ignore'
# 每行末尾自动添加分号
semi: true
# 单引号包裹字符串
# 末尾不需要逗号
trailingComma: 'none'
# 字符串使用单引号
singleQuote: true
# 在对象,数组括号与文字之间加空格 "{ foo: bar }"
bracketSpacing: true
# 让箭头函数保留括号
arrowParens: 'always'
# preserve 保留用户输入的情况
# quoteProps: "preserve"
# "parser": "flow"
# "usePrettierrc": false
# "withNodeModules": true
eslintIntegration: true
stylelintIntegration: true
# 让函数(名)和后面的括号之间加个空格
'javascript.format.insertSpaceBeforeFunctionParenthesis': true
'files.insertFinalNewline': true
endOfLine: 'auto'
ignorePath: '.ignore'