News for hackers. Stuff that matters.
Re:Prettier 2.0 – Opinionated JavaScript formatter by Waterluvian on Sunday March 22, 2020 @05:22PM (#22658799)
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 who are so deeply engaged in the product.

It means either all my code now needs a config file added or all my code will need to be updated.

Re:Prettier 2.0 – Opinionated JavaScript formatter by greentrust on Sunday March 22, 2020 @05:48PM (#22659017)
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 by afshin on Sunday March 22, 2020 @06:22PM (#22659305)
Part of the calculus for the cost is losing the immediate utility of git blame once every file has been reformatted.
Re:Prettier 2.0 – Opinionated JavaScript formatter by lonelappde on Sunday March 22, 2020 @06:39PM (#22659435)
Configure your git blame to ignore cleanup changes.

https://www.moxio.com/blog/43/ignoring-bulk-change-commits-w...

Re:Prettier 2.0 – Opinionated JavaScript formatter by Waterluvian on Sunday March 22, 2020 @07:25PM (#22659778)
This changes everything. Thank you!!!
Re:Prettier 2.0 – Opinionated JavaScript formatter by davidmurdoch on Sunday March 22, 2020 @09:36PM (#22660483)
If GitHub doesn't automatically support the feature (article says it doesn't) I don't think it'll be very useful for many teams.
Re:Prettier 2.0 – Opinionated JavaScript formatter by capableweb on Monday March 23, 2020 @11:45AM (#22665129)
If you can use GitHub but not Git, I'm not sure you can really say that you know version control. Fine for designers who are just helping out in projects and don't really know to but developers who manages merges, backports and alike should really know the insides of Git, not just the GitHub GUI.
Re:Prettier 2.0 – Opinionated JavaScript formatter by nchase on Monday March 23, 2020 @03:22AM (#22661895)
git 2.23 isn’t that old - seems like something that GitHub could support in the future
Re:Prettier 2.0 – Opinionated JavaScript formatter by 29athrowaway on Monday March 23, 2020 @02:41AM (#22661768)
Thanks for sharing this. This issue is holding so many code bases behind.
Re:Prettier 2.0 – Opinionated JavaScript formatter by Groxx on Sunday March 22, 2020 @06:36PM (#22659412)
--ignore-rev: https://www.moxio.com/blog/43/ignoring-bulk-change-commits-w...

Personally tho I haven't had an issue navigating back another revision. UIs are good at handling that kind of interaction, and I rarely use blame without a UI. (nearly every other git interaction: CLI all the time. but not blame.)

Re:Prettier 2.0 – Opinionated JavaScript formatter by akiselev on Sunday March 22, 2020 @07:00PM (#22659569)
The loss is a bit of convenient tooling but it can be replaced with some slightly less convenient tooling. It's not going to be an architectural limitation and you can treat it as a relatively simple per company/team/project tradeoff.

Especially when working with syntax heavy compiled languages like Rust, autoformat on save frees me up enough mental capacity for me that the costs are well worth it for the extra development speed. I just use Git Lens and some custom git aliases to get around the messy logs, whereas my last team handled the payment frontend for a large company so tracing the history of changes was taken way more seriously and reformatting someone else's code outside of organized refactorings, let alone autoformat, was disqualified from the start.

Re:Prettier 2.0 – Opinionated JavaScript formatter by Waterluvian on Sunday March 22, 2020 @06:23PM (#22659313)
This used to have no value to me. But years into my career I discovered that I can't live without it. Detective work on the history of code is vital to truly groking why things are the way they are in code bases.
Re:Prettier 2.0 – Opinionated JavaScript formatter by random3 on Sunday March 22, 2020 @10:10PM (#22660643)
It will likely conflict most in-progress PR. For PRs that are large and long lived it will be a PITA to maintain and will further slow integration so, likely, yes.
Re:Prettier 2.0 – Opinionated JavaScript formatter by globular-toast on Monday March 23, 2020 @03:15AM (#22661861)
I ran formatters on a largish codebase over Christmas when all the PRs were done. You just have to pick your moment. If it's really hard then get everyone to agree on a date to do it and make it each developer's responsibility to either merge before or rebase after the change. It can be done.
Re:Prettier 2.0 – Opinionated JavaScript formatter by random3 on Monday March 23, 2020 @12:07PM (#22665334)
Some team in my old job use to have a term for this - "grabbing the virtual chicken". It was essentially a giant distributed lock :)
Re:Prettier 2.0 – Opinionated JavaScript formatter by mceachen on Sunday March 22, 2020 @06:33PM (#22659385)
Here's a .prettierrc config file to revert the new 2.0.0 config changes:

    {
      "trailingComma": "none",
      "arrowParens": "avoid"
    }
Know that you'll still have non-trivial diffs when switching from 1.x to 2.0 due to other changes (like "the `function` keyword should always have a space after it because consistency").

I just updated the PhotoStructure codebase, and even with that revert of those 2 defaults, almost 100 files and several thousand lines of diff resulted: https://twitter.com/mrm/status/1241792817338257409

Re:Prettier 2.0 – Opinionated JavaScript formatter by Groxx on Sunday March 22, 2020 @06:39PM (#22659438)
>Before version 2.0, Prettier was avoiding trailing commas by default where possible. This made the resulting JavaScript compatible with now very old environments such as IE8, but implied some missed opportunities.

Seems like a pretty good reason to change that one at least, since it seems to imply they've wanted trailing commas but didn't do it for compatibility reasons.

Re:Prettier 2.0 – Opinionated JavaScript formatter by davidmurdoch on Sunday March 22, 2020 @09:39PM (#22660496)
I find trailing commas annoying because every once in a while I need to copy some object to use as JSON and... it doesn't work since JSON doesn't support trailing commas.
Re:Prettier 2.0 – Opinionated JavaScript formatter by j-f1 on Monday March 23, 2020 @08:13AM (#22663250)
Fortunately, if you use Prettier to format your JSON files too, it’ll quote unquoted properties and remove trailing commas: https://prettier.io/playground/#N4Igxg9gdgLgprEAuEwA6UAEmDOE...
Re:Prettier 2.0 – Opinionated JavaScript formatter by amarshall on Monday March 23, 2020 @12:11AM (#22661193)
To be fair, that's more of a JSON problem than a JS one. FWIW, JSON is also missing quote-less keys, object literal shorthand, non-decimal numbers, values that are non-simple literals, and probably a bunch else from JS object syntax.

Just `JSON.stringify` whatever object it is instead.

Re:Prettier 2.0 – Opinionated JavaScript formatter by Groxx on Monday March 23, 2020 @12:45AM (#22661336)
No comments either, which is one major reason I strongly oppose JSON as a config-file language :|
Re:Prettier 2.0 – Opinionated JavaScript formatter by davidmurdoch on Sunday March 22, 2020 @11:03PM (#22660880)
Why the down vote? Prettier calls itself "an opinionated JavaScript formatter". It _had_ an opinion that I agreed with, and now it doesn't. I just offered a perspective on why I don't agree.
Re:Prettier 2.0 – Opinionated JavaScript formatter by tobr on Monday March 23, 2020 @03:56AM (#22662003)
That’s not going to work with object keys anyway, which need to be quoted in JSON. You can’t even configure Prettier to do that unless your keys are invalid JS identifiers.
Re:Prettier 2.0 – Opinionated JavaScript formatter by gkoberger on Sunday March 22, 2020 @06:08PM (#22659185)
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 by mpawelski on Sunday March 22, 2020 @07:14PM (#22659681)
I wouldn't call change of `arrowParens` to `always` as "incredibly sane". This is just a differt opinion about what is "better". I have different.
Re:Prettier 2.0 – Opinionated JavaScript formatter by gkoberger on Sunday March 22, 2020 @07:19PM (#22659728)
I like it, because it's consistent. If you remove or add a parameter to a function, you have parenthesis either way and don't have to think about it.
Re:Prettier 2.0 – Opinionated JavaScript formatter by jimmux on Sunday March 22, 2020 @10:15PM (#22660666)
We had to change the old default because of TypeScript complaining if the param has a type annotation and no parens. So it's more consistent with TypeScript now as well. I had to argue for this exception to be added to our config, so it's a nice bit of validation that Prettier has come around.
Re:Prettier 2.0 – Opinionated JavaScript formatter by dean177 on Sunday March 22, 2020 @05:54PM (#22659081)
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 by squeral on Sunday March 22, 2020 @06:33PM (#22659384)
You have the option of not using these sort of tools and styling the code yourself.