Live data from Hacker News

Prettier 2.0 – Opinionated JavaScript formatter

prettier.io

31–40 of 91 posts

Re: Prettier 2.0 – Opinionated JavaScript formatter

#31

A bit irritating that formatting zealots are changing the defaults. What can possibly drive the decision to change whatever option it is they landed on and deployed? It's contrary to everything they claimed Prettier was about: for better or worse, we have decided on X so we can all move on to more important issues. I feel like the cost of changing defaults is wildly underestimated because it's decided on by people wh…

Is the cost really that high? For the vast majority of projects, all developers will need to do is run "yarn prettier".

We can't expect everything to be perfect on day one, nor should we be stuck with the poor choices we made when starting a project. Maintainers should be allowed to change their mind after careful consideration and community consensus.

Re: Prettier 2.0 – Opinionated JavaScript formatter

#32
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

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.

Re: Prettier 2.0 – Opinionated JavaScript formatter

#33
post #11
post #6

Prettier is one of my favourite pieces of software! I only wish they had a binary that doesn’t rely on Node.js

Why? Are you avoiding NPM as well? Seems like a curious requirement for JS development

I avoid NPM if I can for JS development (after all not all JS/TS development requires NodeJS) so it is painful to see people use npm as the installation method for their projects or tools when I am trying to write something simple.

For what it is worth, the replacement for NodeJS (Deno) is removing the use of npm, so I am not alone in my dislike of the centralised registry idea it seems.

Re: Prettier 2.0 – Opinionated JavaScript formatter

#35

A bit irritating that formatting zealots are changing the defaults. What can possibly drive the decision to change whatever option it is they landed on and deployed? It's contrary to everything they claimed Prettier was about: for better or worse, we have decided on X so we can all move on to more important issues. I feel like the cost of changing defaults is wildly underestimated because it's decided on by people wh…

You can just not upgrade.

I think you are overstating how hard it is to add the config (pro tip: you can add it to package.json) and how painless it is to run the formatted for the whole project.

The changes to the defaults are small and (in my opinion, worth it).

Re: Prettier 2.0 – Opinionated JavaScript formatter

#36
post #6

Prettier is one of my favourite pieces of software! I only wish they had a binary that doesn’t rely on Node.js

Run it in Docker. https://jonathan.bergknoff.com/journal/run-more-stuff-in-doc...

Whoah, aliasing shell commands to Docker one-offs for ethereal runs. Super useful, never thought of that.

This comment was a hidden gem in this thread, I've bookmarked that blog post.

Re: Prettier 2.0 – Opinionated JavaScript formatter

#37

Earlier quoted context omitted.

I suggest https://github.com/google/google-java-format

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…

> I need the format on save

Check out Preferences -> Tools -> File Watchers.

Re: Prettier 2.0 – Opinionated JavaScript formatter

#38

Earlier quoted context omitted.

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…

> 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.

Re: Prettier 2.0 – Opinionated JavaScript formatter

#39

A bit irritating that formatting zealots are changing the defaults. What can possibly drive the decision to change whatever option it is they landed on and deployed? It's contrary to everything they claimed Prettier was about: for better or worse, we have decided on X so we can all move on to more important issues. I feel like the cost of changing defaults is wildly underestimated because it's decided on by people wh…

I'm not sure how you can say these are zealots making these changes? The three defaults things they changed all seemed incredibly sane, and were made for really good reasons.

I think there's another way to look at it. It's more "we have decided on X so YOU can move on to more important issues."

With Prettier, you just follow their opinions. Their opinions can change, and your code might look different, but it doesn't really matter. It might reformat a few lines, but the point is that it's still consistent across your team (without anyone having to memorize a bunch of rules).

Re: Prettier 2.0 – Opinionated JavaScript formatter

#40
post #11

Earlier quoted context omitted.

Why? Are you avoiding NPM as well? Seems like a curious requirement for JS development

I avoid NPM if I can for JS development (after all not all JS/TS development requires NodeJS) so it is painful to see people use npm as the installation method for their projects or tools when I am trying to write something simple. For what it is worth, the replacement for NodeJS (Deno) is removing the use of npm, so I am not alone in my dislike of the centralised registry idea it seems.

Deno will fail at this, they are fixing something that isn't broken.
Post reply on HN