Live data from Hacker News

Prettier 2.0 – Opinionated JavaScript formatter

prettier.io

11–20 of 91 posts

Re: Prettier 2.0 – Opinionated JavaScript formatter

#12
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!

Re: Prettier 2.0 – Opinionated JavaScript formatter

#14
post #12

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've been using Spotless, which has been working well enough.

Re: Prettier 2.0 – Opinionated JavaScript formatter

#17
post #4

finally you can run `npx prettier --write .` and get a folder formatted without any installation or configuration. This is a great decision. Congratulations on the release team!

npx is fine, just remember not to use it for things like CI without pinning the version of Prettier (`npx prettier@2.0.1 ...`).

Re: Prettier 2.0 – Opinionated JavaScript formatter

#18
post #12

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 suggest https://github.com/google/google-java-format

Re: Prettier 2.0 – Opinionated JavaScript formatter

#19
post #3

Did they change an option to disable lineWidth? In 1.* it was not possible, which was my single biggest issue with Prettier. Many times it made code less coherent, due to forcing a few lines to be collapsed into one. See Prettier example in ESLint section of "How I Learned to Stop Worrying and Love the Types & Tests", https://p.migdal.pl/2020/03/02/types-tests-typescript.html#e... .

I’ve learned that the benefit of Prettier outweighs its cost in this regard.

At first I disliked things about Prettier. For example, indents violate eslint’s “indent” rule with multiline ternary alignment. However, I just turned off those eslint rules and stopped worrying about it b/c Prettier’s format is “good enough” and saves me a ton of keystrokes.

Re: Prettier 2.0 – Opinionated JavaScript formatter

#20
post #12

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!

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

prettier for js, ts

Post reply on HN