eslint - vscode配套使用

143 阅读1分钟

1 vscode 安装eslint插件。 2 vscode - setting.json 我进行的配置:

{
  "editor.fontSize": 14,
  "bracketPairColorizer.depreciation-notice": false,
  "explorer.confirmDelete": false,
  "git.confirmSync": false,
  "git.autofetch": true,
  "[javascript]": {
    "editor.defaultFormatter": "HookyQR.beautify"
  },
  "editor.unicodeHighlight.allowedLocales": {
    "zh-hant": true
  },
  // 新增 eslint
  // 添加 vue 支持
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    "vue",
  ],
  "vetur.format.defaultFormatter.html": "js-beautify-html",
  // #让vue中的js按编辑器自带的ts格式进行格式化
  "vetur.format.defaultFormatter.js": "vscode-typescript",
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "force-aligned"
      // #vue组件中html代码格式化样式
    }
  },
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  }
}