1 根据项目配置的eslint规则保存代码后,自动格式化代码

2 需要安装prettier 和 vetur

// settings.json
{
  "codestream.serverUrl": "https://api.codestream.com",
  "security.workspace.trust.untrustedFiles": "open",
  "editor.language.brackets": false,
  "editor.formatOnSave": true,
  // "eslint.autoFixOnSave": true,
  "eslint.packageManager": "yarn",
  "eslint.validate": [
    "javascript", //  用eslint的规则检测js文件
    {
      "language": "vue", // 检测vue文件
      "autoFix": true //  为vue文件开启保存自动修复的功能
    },
    {
      "language": "html",
      "autoFix": true
    }
  ],
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "editor.tabSize": 2,
  "diffEditor.ignoreTrimWhitespace": false,
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      // 超过120的部分换行
      "wrap_line_length": 120,
      "wrap_attributes": "auto",
      "end_with_newline": false
    },

    "prettier": {
      // 设置分号
      "singleQuote": true,
      // 双引号变成单引号
      "semi": false,
      // 超过120的部分换行
      "printWidth": 120,

      "wrapAttributes": true,

      "sortAttributes": false,
      // 禁止随时添加逗号
      "trailingComma": "none"
    }
  },
  // 设置编译器默认使用vetur方式格式化代码
  "[vue]": {
    "editor.defaultFormatter": "octref.vetur"
  }
}

GitHub 加速计划 / vu / vue
207.52 K
33.66 K
下载
vuejs/vue: 是一个用于构建用户界面的 JavaScript 框架,具有简洁的语法和丰富的组件库,可以用于开发单页面应用程序和多页面应用程序。
最近提交(Master分支:1 个月前 )
73486cb5 * chore: fix link broken Signed-off-by: snoppy <michaleli@foxmail.com> * Update packages/template-compiler/README.md [skip ci] --------- Signed-off-by: snoppy <michaleli@foxmail.com> Co-authored-by: Eduardo San Martin Morote <posva@users.noreply.github.com> 3 个月前
e428d891 Updated Browser Compatibility reference. The previous currently returns HTTP 404. 3 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐