#####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 格式化,配置以下内容:
"vetur.format.defaultFormatter.js": "vscode-typescript"
"javascript.format.insertSpaceBeforeFunctionParenthesis": true
函数括号前插入空格
VSCode EXTENSIONS
VS Code 保存时自动格式化功能取消
User Settings 里面设置 editor.formatOnSave
属性为 false
如果安装了 JS-CS-HTML Formatter
这个扩展包,把上面的属性配置设置可能无效,把这个扩展包禁用或卸载