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

prettier: A change in prettier causes problem in the recommendation of usage with lint-staged #6

Closed
ernscht opened this issue Jan 2, 2019 · 5 comments

Comments

@ernscht
Copy link
Member

ernscht commented Jan 2, 2019

Our usage recommendation for prettier-config with lint-staged does not work anymore with prettier 1.15.3.
In 1.15.3 they changed the status code to "0" in any case using the options --write and --list-different together. This leads to the fact that the commit now works despite errors. Another commit must therefore be appended. (discussion)

The solution worked perfect before ;-)
I'm unsure what we should do now.

I don't really like these ideas:

  • downgrade to prettier 1.15.2
  • adding git add to "lint-staged" config
  • using --list-different only will prevent the commit, but won't give us meaningful feedback

Any ideas?

@ernscht ernscht changed the title prettier: A change in prettier causes problem in our recommendation of usage with lint-staged prettier: A change in prettier causes problem in the recommendation of usage with lint-staged Jan 3, 2019
@jantimon
Copy link
Contributor

jantimon commented Jan 8, 2019

A possible workaround which is not as good as prettier 1.15.2 is the following:

"husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "*.js": [
      "pretty-quick --staged"
    ]
  },

It requires:

   "husky": "1.3.1"
    "lint-staged": "8.1.0"
    "prettier": "1.15.3"
    "pretty-quick": "1.8.0"

It will prettify even partial staged files correctly and commit them correctly.

However it does not allow to see the changes prettier did before the commit happens.

@smollweide
Copy link
Contributor

pretty-quick will fix our problem with unwanted changes which are not part of the commit right?

@jantimon
Copy link
Contributor

jantimon commented Jan 9, 2019

It is solved by the latest lint-staged version.

pretty-quick does git add under the hood so we don't have to do that manually.

@jantimon
Copy link
Contributor

By now pretty-quick does not work if .prettierignore is not in the repository root.
So we should probably not use it until prettier/pretty-quick#14 is fixed

@jantimon
Copy link
Contributor

prettier/pretty-quick#14 is fixed - pretty-quick now supports .prettierignore for the working directory too.

smollweide pushed a commit that referenced this issue Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants