eslint prettier配置

发布时间 2023-03-22 21:09:25作者: Echo的前端空间
.eslinttrc.js配置如下
module.exports = {
  root: true,
  env: {
    node: true
  },
  extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
  parserOptions: {
    parser: 'babel-eslint'
  },
  rules: {
    'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
    'no-unused-vars': 'off', //意思就是不让eslint校验我定义有没有用了。
    "prettier/prettier": [  
      "error",
      // 如果插件配置中修改了相关选项,
      // 则必须在此添加相对应的自定义规则否则就会出现编辑器格式化后ESlint检查无法通过的情况。
      {
        "semi": false,
        "singleQuote": true,
        "printWidth": 200,
        "trailingComma": "none",
        "arrowParens": "avoid",
        "htmlWhitespaceSensitivity": "ignore",
        "endOfLine": "auto"
      }
    ]
  }
}

.prettierrc文件配置如下

{
  "semi": false,
  "singleQuote": true,
  "printWidth": 200,
  "trailingComma": "none",
  "arrowParens": "avoid",
  "htmlWhitespaceSensitivity": "ignore",
  "endOfLine": "auto"
}