We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Frank Gutierrez • 8 years ago

I have a file that is formatted with prettier and committed in the repo.
After editing the file with vim and making some formatting craziness.
I use git to commit the file
pre-commit uses prettifier to format the file removing the craziness
the file is committed with proper formatting
if I do a git show, it will show that a commit was made without any changes to the file.

39digits • 8 years ago

If the only changes you've made to that already-committed file is to mess around with the formatting then the changes once Prettier is applied ends up to no change.

So if I commit `test.js` with good formatting, then edit the file in vi and the only changes I make are to mess around with changing quotes, removing semi-colons, etc then the file has been changed in git's context. But our precommit hook grabs the file and runs it through Prettier prior to the commit. The output is now exactly the same as the `test.js` file already under version control so effectively zero changes.

If you take that file and make an arbitrary change that isn't formatting related (and throw in some formatting changes too) and try commit again you'll find the file actually listed as being changed in your git history.

LucasAzzola • 8 years ago

I've just recently released `pretty-quick`, which can replace lint-staged with this approach:

https://github.com/azz/pret...

39digits • 8 years ago

Good to have alternatives :) Thank you for sharing - I'll check it out.

Niket Pathak • 6 years ago

For those who want to use eslint + stylelint instead of prettier => https://digitalfortress.tec...