Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.7k views
in Technique[技术] by (71.8m points)

vscode vue3格式化代码

使用了`interface`,保存的时候会默认把逗号去掉,要改哪里的配置?

interface date {
a: string,
b: any
}

例如会把上面a后面的string的逗号去掉,导致编译出错。
我的配置是这样的

{
  "[vue]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }, //vue格式化工具
  "editor.insertSpaces": false,
  "workbench.editor.enablePreview": false, //打开文件不覆盖
  "search.followSymlinks": false, //关闭rg.exe进程
  "editor.minimap.enabled": false, //关闭快速预览
  "editor.lineNumbers": "on", //开启行数提示
  "editor.quickSuggestions": {
    //开启自动显示建议
    "other": true,
    "comments": true,
    "strings": true
  },
  "editor.tabSize": 2, //制表符符号eslint
  "editor.formatOnSave": true, //每次保存自动格式化
  "prettier.semi": false, //去掉代码结尾的分号
  "prettier.trailingComma": "none", // 去掉逗号
  "prettier.singleQuote": true, //使用单引号替代双引号
  "prettier.tabWidth": 2,
  "prettier.printWidth": 120,
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true, //让函数(名)和后面的括号之间加个空格
  "vetur.format.defaultFormatter.html": "prettyhtml", //让vue中的js按编辑器自带的ts格式进行格式化
  "vetur.format.options.tabSize": 2,
  "vetur.format.defaultFormatter.js": "vscode-typescript",
  "vetur.format.defaultFormatterOptions": {
    "js-beautify-html": {
      "wrap_attributes": "force-aligned" //属性强制折行对齐
    },
    "prettyhtml": {
      "printWidth": 200,
      "semi": false,
      "singleQuote": true
    },
    "prettier": {
      "semi": false,
      "singleQuote": true
    },
    "vscode-typescript": {
      "semi": false,
      "singleQuote": true
    }
  },
  "eslint.validate": [
    "vue",
    "javascript",
    "typescript",
    "typescriptreact",
    "html"
  ],
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
  "files.insertFinalNewline": true
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

"prettier.trailingComma": "all"
试试这个


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...