欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

VScode格式化和vue脚手架中的eslint相冲突,总是在最后有个逗号

程序员文章站 2022-07-05 16:59:01
...

文件——>首选项——>设置
VScode格式化和vue脚手架中的eslint相冲突,总是在最后有个逗号
setting.json,这边只看跟vue相关的就行了,注意要把vue的默认格式设置位vetur

{
  "git.ignoreMissingGitWarning": true,
  "editor.tabSize": 2,
  //保存的时候格式化
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "fileheader.configObj": {
    "createFileTime": true,
    "dateFormat": "YYYY-MM-DD HH:mm:ss"
  },
  "fileheader.customMade": {
    "Author": "Meng Jiawei",
    "Date": "Do not edit",
    "LastEditTime": "Do not edit",
    "FilePath": "Do not edit"
  },
  "winopacity.opacity": 255,
  "git.enableSmartCommit": true,
  "files.associations": {
    "*.cjson": "jsonc",
    "*.wxss": "css",
    "*.wxs": "javascript"
  },
  "emmet.includeLanguages": {
    "wxml": "html"
  },
  "minapp-vscode.disableAutoConfig": true,
  "vetur.format.defaultFormatter.html": "prettier",
  "git.ignoreWindowsGit27Warning": true,
  "[dart]": {
    "editor.formatOnSave": true,
    "editor.formatOnType": true,
    "editor.rulers": [80],
    "editor.selectionHighlight": false,
    "editor.suggest.snippetsPreventQuickSuggestions": false,
    "editor.suggestSelection": "first",
    "editor.tabCompletion": "onlySnippets",
    "editor.wordBasedSuggestions": false
  },
  "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
  "dart.openDevTools": "flutter",
  "git.autofetch": true,
  "[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
  },
  "eslint.codeAction.showDocumentation": {
    "enable": true
  },
  "eslint.format.enable": true,
  // vetur格式配置
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "force-expand-multiline"
    },
    //html配置
    "prettyhtml": {
      "printWidth": 100,
      "singleQuote": false,
      "wrapAttributes": false,
      "sortAttributes": false
    },
    //js配置
    "prettier": {
      //设置分号
      "semi": true,
      //双引号变成单引号
      "singleQuote": false,
      //禁止末尾添加逗号!!!!!
      "trailingComma": "none"
    }
  },
  //配置vue组件的格式化用vetur
  "[vue]": {
    "editor.defaultFormatter": "octref.vetur"
  },
  "[jsonc]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}