Hacker News new | past | comments | ask | show | jobs | submit login

I have been looking for, but haven't found, a similar package for Java projects. Ideally my team can add it as a save-hook for everyone using IDEA, then we can have a pre-commit hook that checks to ensure compliance. Would be eternally grateful for anyone that can point me in the right direction!




I'm very happy using this, coming from prettier with JS/VSCode and looking for a similar dev experience in Java/Intellij - it has an IntelliJ plugin that works well. Last time I looked I couldn't find any good IntelliJ plugins for the Java implementation of prettier which was a dealbreaker - I need the format on save. Anyway, this is a great tool, just works.

Only couple of issues it has is no 'ignore formatting for this piece of code' feature and it occasionally formats comments oddly (i.e. enough to make them unreadable) in certain edge cases like in ternary expressions, so you have to manually edit comments from time to time, but this hardly ever comes up.


> I need the format on save

Check out Preferences -> Tools -> File Watchers.


Great shout! Didn't know about this feature but this solves the problem elegantly. Will give it a try.


There’s https://github.com/jhipster/prettier-java, which expands Prettier to work with Java, but I’m not sure how complete or thoroughly-tested it is. It also requires that you have Node installed, which could be be a downside for people who only work with Java.


There exists a Java plugin for Prettier: https://github.com/jhipster/prettier-java

No idea how good it is though. Please tell us. :)


I've been using Spotless, which has been working well enough.



At work, we use clang-format for java and c++.

prettier for js, ts




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: