-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Description
[Explaning my problem]
Hello I am trying to use prettier as pre-commit git hook (along with WebStorm).
I had the problem that even after I commit my changes, my files are marked as changed and git status and git diff output something strange. I spent some time investigating the problem and I reproduce it directly from the command line, excluding WebStorm from the problem. Since the problem occurs only when prettier prettifies my files my conclusion was that the problem must be in prettier not git.
[If you are in a hurry]
Just go to My Simple Example
[The actual problem]
When I commit a file that is considered ugly by prettier, the git hook that i have defined invoke prettier on the file, makes it pretty and then git performs the commit. At that point my expectations are that there will be no changes in my working directory, however git does not think so.
[Why do I think the problem comes from prettier and not git]
- If the changed file is considered pretty by prettier, it seems that prettier does not process it and the problem does not reproduce.
- According to the internet changing the source code in pre-commit git hooks seems to be a practice and it should work fine.
[My Simple Example]
- Note that I am using the prettier pre-commit hook from https://github.com/prettier/prettier I only added some additional prettier options that I need.
- https://s1.postimg.org/20gmod0x73/With_Git_Attributes.png