prettier / eslint-config-prettier

Turns off all rules that are unnecessary or might conflict with Prettier.
MIT License
5.47k stars 255 forks source link

Conflict with recommended configuration of prettier #75

Closed AnmolMago closed 5 years ago

AnmolMago commented 5 years ago

As specified by https://prettier.io/docs/en/eslint.html I used

{
  "extends": ["plugin:prettier/recommended"]
}

with

  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-eslint": "^10.0.1",
    "babel-preset-flow": "^6.23.0",
    "eslint": "^5.12.1",
    "eslint-config-airbnb-base": "^13.1.0",
    "eslint-config-prettier": "^3.6.0",
    "eslint-plugin-flowtype": "^3.2.1",
    "eslint-plugin-import": "^2.14.0",
    "eslint-plugin-prettier": "^3.0.1",
    "flow-bin": "^0.91.0",
    "flow-typed": "^2.5.1",
    "prettier": "1.16.0"
  }

and eslintrc

{
  "env": {
    "browser": true,
    "es6": true,
    "node": true
  },
  "parser": "babel-eslint",
  "plugins": ["flowtype"],
  "extends": [
    "plugin:prettier/recommended",
    "plugin:flowtype/recommended",
    "prettier/babel",
    "prettier/flowtype"
  ],
  "parserOptions": {
    "ecmaVersion": 2018,
    "sourceType": "module"
  },
  "rules": {
    "indent": ["error", "tab"],
    "linebreak-style": ["error", "unix"],
    "quotes": ["error", "single"],
    "semi": ["error", "always"],
    "flowtype/no-types-missing-file-annotation": 0
  }
}

The problem is that eslint's indent rule expects a tab and prettier's recommended configuration expects two spaces. This leads to a conflict. To be clear, the eslint website specifies only the use of "extends": ["plugin:prettier/recommended"] only. When removing this and using prettier extension with airbnb it works just fine.

j-f1 commented 5 years ago

This error is occurring because rules configured in plugins are overridden by rules configured in your ESLint config.

lydell commented 5 years ago

Yes, the rules you specify under rules always win over configs in extends. So the solution is simple – remove all conflicting rules, such as indent! You can use the CLI helper tool to find them all.