vscode 配置

配置 ESLint 自动修复

  1. vscode安装 eslint + vuter + prettier 插件;
  2. 设置 —> 用户设置 —> 扩展 —> ESlint —> 点击“在setting.json”中编辑;
  3. 添加下列代码
{
  "vetur.format.defaultFormatter.js": "vscode-typescript",
  "vetur.format.defaultFormatter.html": "js-beautify-html",
  "editor.formatOnSave": false,
  "prettier.singleQuote": true,
  "javascript.format.enable": false,
  "prettier.eslintIntegration": true,
  "eslint.enable": true,
  "eslint.run": "onType",
  "eslint.autoFixOnSave": true,
 "eslint.options": {
    "extensions": [".js",".vue"]
  },
  "eslint.validate": [
    "javascript",
    "javascriptreact",
    {
      "language": "html",
      "autoFix": true
    },
    {
      "language": "vue",
      "autoFix": true
    }
  ]
}

配置 KoroFileHeader

快捷命令

  • 文件注释:control + command + .

  • 函数注释:option + command + /

  • cursorTip

  • fileheader

配置

"fileheader.configObj": {
  "autoAdd": false,
  "autoAlready": true,
  "prohibitAutoAdd": [
    "json",
    "md"
  ],
  "wideSame": false,
  "wideNum": 13
},
"fileheader.customMade": {
  "Author": "name",
  "Date": "",
  "Description": "",
  "LastEditors": "name",
  "LastEditTime": "",
},
"fileheader.cursorMode": {
  "description": "",
  "param": "",
  "return": ""
},

配置 Code Spell Checker

"cSpell.ignoreWords": [
 "fengling"
],

配置用户代码片段

1、command + shift + p,打开面板; 2、输入 > snippet,选择 “首选项:配置用户代码片段”; 3、快速生成代码片段配置:https://snippet-generator.app/open in new window

// 配置示例
"mockjs": {
  "prefix": "mockjs",
  "body": [
    "module.exports = {",
    "  code: 1,",
    "  timestamp: '1647750273.739',",
    "  result: true,",
    "  data: {",
    "",
    "  }",
    "}"
  ],
  "description": "mockjs"
}