codeclimate/codeclimate-eslint

Consider upgrading prettier/eslint-config-prettier/eslint-plugin-prettier

davidkaneda opened this issue · 6 comments

My apologies for not including steps to reproduce and such, but my repo is private and I'm just getting started with codeclimate. Essentially, I'm getting a handful of linter errors in codeclimate that I'm not locally/in Circle, and I believe it's due to the mismatch in dependencies.

My local dependencies:

  "devDependencies": {
    "eslint": "^5.16.0",
    "eslint-config-prettier": "^4.2.0",
    "eslint-plugin-jest": "^22.5.1",
    "eslint-plugin-prettier": "^3.0.1",
    "eslint-plugin-react": "^7.13.0",
    "prettier": "^1.17.0"
  }

Here's a sample of the errors:

image

I have a sort of reverse reproduction in that if I go through and pin those 3 prettier-related deps to the versions in this repo, I get the lint errors (actually, the ones in my output plus a few more). Note that prettier itself actually resolves to the same version, as it hasn't had a major update like the two others.

Not sure if you have a policy on these sorts of upgrades (as I'm sure fixing for me will break others), but figured I'd give it a shot. Thanks!

Hi @davidkaneda ,

Can you post your .codeclimate.yml here? Happy to take a closer look. 👌 Thanks!

Thanks, here you go:

plugins:
  eslint:
    enabled: true
    channel: "eslint-5"
    config:
      extensions:
        - .js
        - .jsx

We actually have a quite similar issue.

For us space-before-function-paren rule seems not to be disabled by eslint-config-prettier.

Running this locally, gives no errors: eslint --fix '**/*.{js,vue}'
Whereas codeclimate fails.

Config:

package.json

"devDependencies": {
    "eslint": "5.16.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-html-erb": "^1.0.0",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-vue": "^6.2.2",
    ...
  },

aligned with https://github.com/codeclimate/codeclimate-eslint/blob/channel/eslint-5/package.json

.codeclimate.yml

...
eslint:
    enabled: true
    channel: 'eslint-5'
    config:
      config: .eslintrc.json
      extensions:
        - .js
        - .vue
    exclude_patterns:
      - '!**/spec/'
      - '!**/test/'

.eslintrc.json

{
  "extends": ["eslint:recommended", "plugin:vue/essential", "plugin:prettier/recommended"],
  "rules": {
    "no-console": 1,
    "no-debugger": 0,
    "no-param-reassign": 2,    
    "vue/order-in-components": [
      "error",
      {
        "order": [
          "el",
          "name",
          "parent",
          "functional",
          ["delimiters", "comments"],
          ["components", "directives", "filters"],
          "extends",
          "mixins",
          "inheritAttrs",
          "model",
          ["props", "propsData"],
          "data",
          "computed",
          "watch",
          "LIFECYCLE_HOOKS",
          "methods",
          ["template", "render"],
          "renderError"
        ]
      }
    ],
    "vue/no-use-v-if-with-v-for": [
      "error",
      {
        "allowUsingIterationVar": true
      }
    ]
  },
  ...
}

@davidkaneda could you resolve the issue at your end?
@efueger any recommendations?

Never mind. Issue seems fixed by adding "prettier": "^2.0.5", to devDependencies 💯

You need to install an exact Prettier version.
https://prettier.io/docs/en/install.html

Install an exact version of Prettier locally in your project. This makes sure that everyone in the project gets the exact same version of Prettier. Even a patch release of Prettier can result in slightly different formatting, so you wouldn’t want different team members using different versions and formatting each other’s changes back and forth.

And I suspect further complications related to eslint-plugin-prettier and/or eslint-config-prettier as well, but that's something I'm trying to verify.

When you set "prettier": "^1.17.0" it's going to periodically update and you'll have to reformat your code. Further, codeclimate-eslint itself is also using an unpinned prettier version so that's also going to periodically update, but at different points, leaving your local and Code Climate issues list out of sync. You should pin your version, but I think it will only work if this project also pins to the exact same version (?). There might be a fundamental problem here. I wish we could eliminate needing this project altogether so it CC would just take whatever Eslint/Prettier setup you have in your repo.