Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
621 views
in Technique[技术] by (71.8m points)

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

请问如何解决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"
    ]
  }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

547k answers

4 comments

35.4k users

...