Disable reformat code on commit

Answered

Hello,

My team and I have recently made the decision to use Prettier to format our code, as some of our devs are on Jetbrain products, and others are on VS Code, and so it harmonizes things.

Prettier is all set up and makes the correct formatting, however whenever I commit, all of the Prettier changes are undone and IntelliJ's formatting is done. When making a commit, I have unchecked Reformat Code and Rearrange Code, but this doesn't seem to change anything. IntelliJ still formats things back. I have looked online but surprisingly there is no clear solution for disabling the formatter when committing. 

Surely there is something simple that I'm missing? Any help would be hugely appreciated, as it is really getting quite frustrating.

Thank you very much.

4 comments
Comment actions Permalink

What exactly is changed with the code formatting when you commit the changes? Do you use any third-party plug-ins that can trigger code reformat, such as Save Actions or Eclipse Code formatter?

Are there any pre-commit hooks that can change the formatting again?

0
Comment actions Permalink

When a commit is made, the alignment is all changed back to IntelliJ's standard formatting (option + cmd + L). We have a package.json script which constantly auto formats with Prettier, which works great, and then right on commit, IntelliJ is changing everything back.

We have very minimal plugins. I looked for Save Actions and Eclipse Code - didn't see them.. 

Any suggestions would be greatly appreciated, this has caused quite a bit of pain during PR's, as formatting is constantly switching back and forth depending on who commits.

0
Comment actions Permalink

Issue has been resolved. I was under the impression that Organize Imports only removed unused imports, where Reformat Code would be spacing. My bad!

Thank you for your time Serge.

0

Please sign in to leave a comment.