1 vscode的编辑器--设置tab size: 空格设置为2
2 prettier扩展 -- 设置 tab width: 空格为2
3 配置编辑器 editorconfig文件
4 配置eslintrcjs 文件
5 配置prettierrc文件
6 如果自动格式化出问题,就选择手动格式化 右键--格式化文档--选择prettier工具
.eslintrc.js
module.exports = {
root: true,
env: {
node: true
},
extends: [
'plugin:vue/vue3-essential',
'eslint:recommended',
'plugin:prettier/recommended'
],
parserOptions: {
parser: '@babel/eslint-parser'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'vue/multi-word-component-names': 'off',
'no-unused-vars': 'off'
}
}
.editorconfig
# http://editorconfig.org
root = true
[*] # 表示所有文件适用
charset = utf-8 # 设置文件字符集为 utf-8
indent_style = space # 缩进风格(tab | space)
indent_size = 2 # 缩进大小
end_of_line = lf # 控制换行类型(lf | cr | crlf)
trim_trailing_whitespace = true # 去除行首的任意空白字符
insert_final_newline = true # 始终在文件末尾插入一个新行
[*.md] # 表示仅 md 文件适用以下规则
max_line_length = off
trim_trailing_whitespace = false
.prettierrc
{
"semi": false,
"singleQuote": true,
"trailingComma": "none"
}