打开vetur的settings.json文件,这些问题都是为了把格式化的代码和ESLint格式对上
增加如下配置
"vetur.format.defaultFormatterOptions": { "prettier": {
// 分号
"semi": false,
//引号
"singleQuote": true,
// 逗号
"trailingComma": "none"
} },
"vetur.format.defaultFormatter.js": "vscode-typescript",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
贴一张我用的设置,有些东西没用,但我没去细究
{
"window.zoomLevel": 1,
"files.autoSave": "onFocusChange",
// prettier:每行在这个字符数内整合代码,如果你的屏幕较宽分辨率较高可以适当加大
"prettier.printWidth": 120,
"vetur.format.defaultFormatterOptions": { "prettier": {
// 分号
"semi": false,
//引号
"singleQuote": true,
// 逗号
"trailingComma": "none"
} },
"vetur.format.defaultFormatter.js": "vscode-typescript",
"javascript.format.insertSpaceBeforeFunctionParenthesis": true,
"typescript.format.insertSpaceBeforeFunctionParenthesis": true,
// vetur:对html的内容使用js-beautify-html
"vetur.format.defaultFormatter.html": "js-beautify-html",
"files.autoSave":"off",
"emmet.syntaxProfiles": {
"vue-html": "html",
"vue": "html"
},
"eslint.validate": [
"javascript",
"javascriptreact",
"html",
{ "language": "vue", "autoFix": true }
],
"eslint.options": {
"plugins": ["html"]
},
"grunt.autoDetect": "on",
"eslint.codeActionsOnSave.rules": null,
"explorer.confirmDelete": false,
"Codegeex.Privacy": true,
"Codegeex.Comment.LanguagePreference": "中文",
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
},
"prettier.bracketSameLine": true,
"prettier.jsxSingleQuote": true,
"vetur.completion.scaffoldSnippetSources": {
"workspace": "💼",
"user": "🗒️",
"vetur": "✌"
},
"Codegeex.EnableExtension": false
}