Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eslint 5.6.0 causes linter errors with prettier? #110

Closed
SuttonKyle opened this issue Sep 16, 2018 · 3 comments
Closed

Eslint 5.6.0 causes linter errors with prettier? #110

SuttonKyle opened this issue Sep 16, 2018 · 3 comments

Comments

@SuttonKyle
Copy link

What version of eslint are you using?
5.6.0

What version of prettier are you using?
1.14.2

What version of eslint-plugin-prettier are you using?
2.6.2

Please paste any applicable config files that you're using (e.g. .prettierrc or .eslintrc files)
.eslintrc.json

{
  "extends": ["airbnb", "plugin:prettier/recommended"],
  "env": {
    "browser": true,
    "jest": true
  },
  "parser": "babel-eslint",
  "rules": {
    "semi": ["error", "never"],
    "import/first": 0,
    "import/prefer-default-export": 0,
    "react/prop-types": 0,
    "react/jsx-filename-extension": 0,
    "react/prefer-stateless-function": 0,
    "react/no-unused-state": 0,
    "jsx-a11y/anchor-is-valid": [
      "error",
      {
        "components": ["Link"],
        "specialLink": ["to"],
        "aspects": ["noHref", "invalidHref", "preferButton"]
      }
    ],
    "import/no-extraneous-dependencies": [
      "error",
      {
        "devDependencies": [".storybook/**", "src/stories/**"]
      }
    ]
  }
}

.prettierrc

{
    "semi": false,
    "singleQuote": true
}

What source code are you linting?
A React-based web app

What did you expect to happen?
prettier/prettier rules on ESLint to behave as they did before

What actually happened?
I got a bunch of new (mostly small) errors from prettier when running ESLint after upgrading to ESLint 5.6 from 4.19. They almost exclusively had to do with spacing. Terminal output is below:
image
Any ideas what could be causing these new errors?

@alaycock
Copy link

alaycock commented Nov 14, 2018

I'm also encountering this issue with:
eslint@5.6.0
prettier@1.15.2
eslint-plugin-prettier@3.0.0

eslint --fix resolves the problem, but prettier --write conflicts with them, and reverses the change.

Did you find a solution or workaround @SuttonKyle?

@alaycock
Copy link

alaycock commented Nov 14, 2018

I ended up finding a solution.

The problem was because I had two different versions of prettier installed (1.15.2 and 1.13.4). Both were dependencies of packages within my project. When I was running prettier from the terminal with yarn prettier --version, it was running the 1.15.2 version. eslint-plugin-prettier was running 1.13.4, because that was the first one it could find in my node_modules I assume.

The resolution was to determine which packages depended on prettier and deduplicate their dependencies. Both of the packges defined their dependencies with a caret (^1.xx.x), so I could run yarn upgrade $PACKAGE_NAME on the package that depended on 1.13.4, and yarn deduplicated them to both use 1.15.2.

My solution might not work for all cases, such as if a package were to be tied to a specific version. The problem was because of duplicated dependencies, and yarn prettier and eslint-plugin-prettier running different versions of prettier.

I wouldn't be surprised if more people who are upgrading create-react-app 2 landed here. A dependant of react-scripts, @svgr/core@^2.4.1 includes prettier as a dependency, which could lead to duplicated versions of prettier being installed.

@BPScott
Copy link
Member

BPScott commented Nov 15, 2018

Thanks for the investigation @alaycock.

I'm going to close this as it seems to be an issue with conflicting prettier versions rather than anything to do with eslint-plugin-prettier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants