prettier格式化代码和eslint缩进规则冲突

鸿则
  • 2.3k

请问如何解决prettier格式化完的代码和eslint缩进规则冲突?

image.png

.prettierrc配置:

{
  "tabWidth": 2,
  "useTabs": false,
  "singleQuote": true,
  "arrowParens": "avoid"
}

.eslintrc配置:

{
  "env": {
    "es6": true,
    "browser": true
  },
  "globals": {
    "Atomics": "readonly",
    "SharedArrayBuffer": "readonly"
  },
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 11,
    "sourceType": "module"
  },
  "plugins": [
    "@typescript-eslint"
  ],
  "rules": {
    "indent": [
      "error",
      2
    ],
    "quotes": [
      "warn",
      "single",
      {
        "allowTemplateLiterals": true
      }
    ],
    "arrow-parens": [
      "warn",
      "as-needed"
    ],
    "comma-spacing": [
      "warn",
      {
        "after": true
      }
    ],
    "linebreak-style": [
      "error",
      "unix"
    ],
    "object-curly-spacing": [
      "error",
      "always"
    ],
    "@typescript-eslint/semi": [
      "warn"
    ]
  }
}
回复
阅读 3.6k
1 个回答
✓ 已被采纳

我把格式化代码的方法改成了prettier --write "**/*.ts" && eslint --fix "**/*.ts" ?

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏