別人的那一堆配置、插件我就不寫了~javascript
首先進入官網下載並安裝。css
項目跟路徑增長配置文件 .vscode/settings.jsonhtml
將你的編輯器按照下面的配置進行設置,以免常見的代碼不一致和差別:vue
用兩個空格代替製表符(soft-tab 即用空格表明 tab 符)。
保存文件時,刪除尾部的空白符。
設置文件編碼爲 UTF-8。
在文件結尾添加一個空白行。java
{ "editor.tabSize": 2, "files.insertFinalNewline": true, "files.eol": "\n", "files.trimTrailingWhitespace": true, "eslint.autoFixOnSave": true, "editor.formatOnSave": true, "eslint.validate": [ "javascript", { "language": "vue", "autoFix": true }, "html" ], "prettier.stylelintIntegration": true, "prettier.eslintIntegration": true, "vetur.format.defaultFormatter.html": "prettier", "vetur.format.defaultFormatterOptions": { "prettier": { "semi": true, "singleQuote": true, "arrowParens": "always", "trailingComma": "es5" } }, "path-intellisense.mappings": { "@/": "${workspaceRoot}/src/" } }
增長 .editorconfig 文件react
# editorconfig.org root = true [*] charset = utf-8 end_of_line = lf indent_size = 2 indent_style = space insert_final_newline = true trim_trailing_whitespace = true
https://marketplace.visualstudio.com/webpack
"prettier.eslintIntegration": true,
"prettier.stylelintIntegration": true
Vetur:vue 開發工具,增長如下配置 https://vuejs.github.io/vetur/formatting.html#formattersgit
"eslint.validate": [ "javascript", "javascriptreact", { "language": "vue", "autoFix": true }, ], "vetur.validation.template": false, "vetur.format.defaultFormatter.html": "prettyhtml"
處理 prettier 格式化配置github
"vetur.format.defaultFormatterOptions": { "prettier": { "semi": true, "singleQuote": true, "arrowParens": "always" } },
若是須要,路徑 @/component/HelloWorld.vue eslint 解析出錯時增長一下配置:web
settings: { "import/resolver": { webpack: { config: { resolve: { alias: { '@': path.resolve('src'), } } } }, }, },
"importCost.javascriptExtensions": [ "\\.jsx?$", "\\.vue?$" ],
eslint 自動處理語法問題:
Ctrl+Shift+p
輸入:eslint:fix all
回車後 eslint 會自動處理一些語法問題