vscode保存自动格式化代码配置

插件:vetur,eslint
由于vetur版本更新,导致一个规则:先从源代码中查找有没有.prettierrc.json文件,如果有的话再读取settingjson中的prettier设置

.prettierrc.json

{
  "semi": true,
  "singleQuote": true,
  "tabWidth": 2
}

setting.json

{
    "workbench.colorTheme": "Monokai",
    // "editor.fontSize": 14,
    "workbench.editor.enablePreview": false, //预览模式关闭
    "editor.formatOnSave": true, // #每次保存的时候自动格式化
    // 自动修复
    "editor.codeActionsOnSave": {
        "source.fixAll.eslint": true,
    },
    "eslint.enable": true, //是否开启vscode的eslint
    // 配置 ESLint 检查的文件类型
    "eslint.validate": [
        "javascript",
        "vue",
        "html",
        ".ts",
        ".tsx"
    ],
    "eslint.options": { //指定vscode的eslint所处理的文件的后缀
        "extensions": [
            ".js",
            ".vue",
            ".ts",
            ".tsx"
        ]
    },
    "files.associations": {
        "*.wpy": "vue",
        "*.wxml": "wxml",
        "*.cjson": "jsonc",
        "*.wxss": "css",
        "*.wxs": "javascript",
        "*.html": "html"
    },
    "emmet.includeLanguages": {
        "wxml": "html"
    },
    "minapp-vscode.disableAutoConfig": true,
    // vscode默认启用了根据文件类型自动设置tabsize的选项
    "editor.detectIndentation": false,
    // 重新设定tabsize
    "editor.tabSize": 2,
    //  #让函数(名)和后面的括号之间加个空格
    "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
    // #让vue中的js按编辑器自带的ts格式进行格式化 
    "vetur.format.defaultFormatter.js": "vscode-typescript",
    "git.enableSmartCommit": true,
    "editor.quickSuggestions": {
        "strings": true
    },
    //一定要在vutur.defaultFormatterOptions参数中设置,单独修改prettier扩展的设置是无法解决这个问题的,因为perttier默认忽略了vue文件(事实上从忽略列表移除vue也不能解决这个问题)
    "vetur.format.defaultFormatterOptions": {
      "prettier": {
        "semi": true,
        "singleQuote": true
      },
        "js-beautify-html": {
            // force-aligned | force-expand-multiline
            "wrap_attributes": "force-aligned"
        },
        "prettyhtml": {
            "printWidth": 100,
            "wrapAttributes": false,
            "sortAttributes": true
        },
    },
    // 插件KoroFileHeader
    // 文件头部注释-快捷键crtl+alt+i(window),ctrl+cmd+t (mac)
    "fileheader.customMade": {
        "Descripttion": "",
        //"version": "",
        "Author": "voanit",
        "Date": "Do not edit",
        "LastEditors": "voanit",
        "LastEditTime": "Do not Edit"
    },
    //函数注释-快捷键ctrl+alt+t (window), ctrl+alt+t(mac)
    "fileheader.cursorMode": {
        "name": "",
        // "test": "test font",
        // "msg": "",
        "param": "",
        "return": ""
    },
    //安装live Server插件
    "liveServer.settings.donotVerifyTags": true,
    "liveServer.settings.donotShowInfoMsg": true,
    "liveServer.settings.NoBrowser": true,
    "liveServer.settings.CustomBrowser": "chrome", //设置默认打开的浏览器
    "liveServer.settings.host": "127.0.0.1",
    "liveServer.settings.port": 5000, //设置本地服务的端口号
    "liveServer.settings.root": "/distserver",
    "[vue]": {
        "editor.defaultFormatter": "octref.vetur"
    },
    "javascript.updateImportsOnFileMove.enabled": "never",
    "javascript.implicitProjectConfig.experimentalDecorators": true,
    "workbench.editor.showTabs": true,
    "terminal.integrated.rendererType": "dom",
    "sync.gist": "396472a5bb443e3680d5a0e2ffccefe8",
    "window.zoomLevel": 0,
    "diffEditor.ignoreTrimWhitespace": false,
    "launch": {},
    "[jsonc]": {
        "editor.defaultFormatter": "prettier-vscode"
    },
    "[typescript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "json.schemas": [
        {
            "fileMatch": [
                "/myfile"
            ],
            "url": "schemaURL"
        }
    ],
    "vetur.ignoreProjectWarning": true,
    "[json]": {

        "editor.quickSuggestions": {
            "strings": true
        },
        "editor.suggest.insertMode": "replace",
        "gitlens.codeLens.scopes": [
            "document"
        ]
    },
    "[typescriptreact]": {
      "editor.formatOnSave": true
    },
    "[typescript]": {
      "editor.formatOnSave": true
    },
    "editor.fontLigatures": null,
    "vetur.format.defaultFormatter.js": "vscode-typescript",
    "vetur.format.defaultFormatter.ts": "prettier-tslint",
    "editor.defaultFormatter": "esbenp.prettier-vscode"
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值