vscode格式化不符合预期

vscode 的 setting.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"workbench.colorTheme": "Dracula Soft",
"editor.formatOnSave": true,//保存时使用VSCode 自身格式化程序格式化
"javascript.format.enable": false,//关闭编辑器对 js 文件的格式化,交给 ESLint 来做格式化,否则会格式化两次,解决editor.formatOnSave的兼容问题
"editor.codeActionsOnSave": {
"source.fixAll": true,
// For ESLint
"source.fixAll.eslint": true,
// For TSLint
"source.fixAll.tslint": true,
// For Stylelint
"source.fixAll.stylelint": true
},
"eslint.probe": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
}

.editorconfig

1
2
3
4
5
6
7
8
9
10
11
12
13
# http://editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2 # 用两个空格代替制表符;
end_of_line = lf # win用cr lf,linux/unix用lf,mac用cr。统一window和mac
charset = utf-8
trim_trailing_whitespace = true# 在保存时删除尾部的空白字符;
insert_final_newline = true# 在文件结尾添加一个空白行;
max_line_length = 160# 每行代码最大宽度 160
[*.md]
trim_trailing_whitespace = false