VSCode 版本
插件安裝列表
使用 yarn
全局安裝 prettier
gyw@gyw:~$ yarn -v
1.7.0
gyw@gyw:~$ yarn global add prettier
yarn global v1.7.0
(node:7222) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "prettier@1.13.7" with binaries:
- prettier
Done in 3.25s.
前端 vue 項目根目錄下添加 .prettierrc.json
文件, 配置如下就好了
{
"singleQuote": true,
"semi": false
}
singleQuote: true
使用單引號
semi: false
在語句末尾不打印分號
Missing space before function parentheses
? http://eslint.org/docs/rules/space-before-function-paren Missing space before function parentheses
src/views/home.vue:467:18
onUploadError(err, file, fileList) {
^
? 30 problems (30 errors, 0 warnings)
Errors:
30 http://eslint.org/docs/rules/space-before-function-paren
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
解決方式
使用 VSCode 自帶的 ts 格式化,配置以下內(nèi)容:
"vetur.format.defaultFormatter.js": "vscode-typescript"
"javascript.format.insertSpaceBeforeFunctionParenthesis": true
函數(shù)括號前插入空格
VSCode EXTENSIONS
VS Code 保存時自動格式化功能取消
User Settings 里面設置 editor.formatOnSave
屬性為 false
如果安裝了 JS-CS-HTML Formatter
這個擴展包,把上面的屬性配置設置可能無效,把這個擴展包禁用或卸載