在项目根目录新建一个JSON文件,文件名要保持一致
分别在设置与根目录的settings.json文件中写入以下代码
{
"git.autofetch": true,
"editor.fontFamily": "'Courier New', Consolas, monospace",
"editor.fontSize": 16,
"files.autoGuessEncoding": true,
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
},
"editor.tabSize": 2,
"eslint.autoFixOnSave": true,
"prettier.eslintIntegration": true,
"prettier.semi": false,
"prettier.singleQuote": true,
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"vetur.format.defaultFormatter.html": "js-beautify-html",
"vetur.format.defaultFormatter.js": "vscode-typescript",
"vetur.format.defaultFormatterOptions": {
"js-beautify-html": {
"wrap_line_length": 140,
"wrap_attributes": "auto",
"end_with_newline": false
}
},
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "html",
"autoFix": true
},
{
"language": "vue",
"autoFix": true
}
],
"emmet.triggerExpansionOnTab": true,
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"git.enableSmartCommit": true,
"liveServer.settings.donotShowInfoMsg": true,
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
配置完成之后在随便在文件中写一些代码,如果格式与设定的不一致就会出现虚点下划线进行提示,保存的时候会把错误的代码格式自行更正