VScode 保存代码自动格式化
首先在vscode商店下载ESLint接下来就是进行将下面的代码配置到 .vscode 中{"eslint.autoFixOnSave": true,"eslint.validate": [{"language": "vue","autoFix": true},{...
·
- 首先在vscode商店下载ESLint
- 接下来就是进行将下面的代码配置到 .vscode 中
{
"eslint.autoFixOnSave": true,
"eslint.validate": [
{
"language": "vue",
"autoFix": true
},
{
"language": "html",
"autoFix": true
},
{
"language": "javascript",
"autoFix": true
}
],
"git.autofetch": true,
"editor.tabSize": 2,
"files.associations": {
"*.vue": "vue"
},
"eslint.autoFixOnSave": true,
"eslint.options": {
"extensions": [
".js",
".vue"
]
},
"eslint.validate": [
"javascript",{
"language": "vue",
"autoFix": true
},"html",
"vue"
],
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/dist": true
},
"emmet.syntaxProfiles": {
"javascript": "jsx",
"vue": "html",
"vue-html": "html"
},
"git.confirmSync": false,
"window.zoomLevel": 0,
"editor.renderWhitespace": "boundary",
"editor.cursorBlinking": "smooth",
"editor.minimap.enabled": true,
"editor.minimap.renderCharacters": false,
"window.title": "${dirty}${activeEditorMedium}${separator}${rootName}",
"editor.codeLens": true,
"editor.snippetSuggestions": "top",
"search.location": "panel",
"explorer.confirmDelete": false
}
- 最后重启vscode,不规范代码会有红色下划线提示,command+s 连续保存即可
注意事项:
1.低版本的vscode如下点击配置
2.高版本vscode按如下操作,将配置代码放入即可
由于2020 新版本更新,需要在setting中替换成以下代码
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
},
更多推荐
已为社区贡献5条内容
所有评论(0)