关于vscode的prettier和eslint默认格式不兼容的解决方法
发布于 2 年前 作者 leigong 2692 次浏览 来自 分享

在配置vue脚手架调试过程中,遇到vscode自动保存格式prettier和eslint文件默认格式不兼容的问题

出现了以下几个常见问题,例如:
缩进符不匹配(规则是2字节但vscode的默认缩进符4字节)
行尾加不加空格,分号
js文件末尾要不要加一个空行等问题

下面贴出我调试好后的prettier规则和eslint文件rules设置,具体参数对应意思可以去eslint官方文档以及其他CSDN大佬博客进行查阅

package.json中

"prettier": {
        "singleQuote": true,
        "semi": true,
        "stylelintIntegration": true,
        "eslintIntegration": true,
        "insertPragma": false,
        "trailingComma": "all",
        "arrowParens": "avoid",
        "tabWidth": 4,
        "bracketSpacing": true

    }

.eslintrc.js中

rules: {
        "no-tabs": "off",
        "indent": 0,
        "eol-last": ["error", "never"]
    }
回到顶部