Earlier quoted context omitted.
> 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.
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.
Prettier 2.0 – Opinionated JavaScript formatter
81–90 of 91 posts
Re: Prettier 2.0 – Opinionated JavaScript formatter
#82> Improved method chain breaking heuristic This is great! When I'm scripting in Node.js I tend to prefer either of these two styles, with the second one being normally a cleaned-up version of the first one: const res = base .map(a => a.b) .filter(b => /abc/.test(b)) .join('\n'); const res = base.map(extractB).filter(isAbc).join('\n'); The second one would be split into different lines with Prettier 1.x, which was ann…
I prefer Gofmt's strategy/philosophy, which is to mostly let the developer control breaking, and only format around it. Gofmt will format everthing strictly, but will leave decisions about "layout" to you. This is a wiser design because the formatter can't know what the best layout is, and a formatter really ought to only format something where there's is an unequivocally, universally correct way of formatting someth…
But I also have wished on multiple occasions that prettier was just an opinionated preset on top of a much more configurable core, which would make it less of a taboo to add options for what are obviously massively divisive formatting preferences.
Case in point, all the most popular issues in the repo are some form of people asking for options or changes to the current behavior: https://github.com/prettier/prettier/issues?q=is%3Aissue+is%...
And let's face it, that whole idea of a 1-size-fits all JS code formatting tool to end all formatting debates? That ship has sailed a long time ago. The debate just moved to what prettier options to use: https://prettier.io/docs/en/options.html
I think the real value of prettier these days is that we can debate as a team once, decide on an option, and then have that decision be enforced automatically moving forward. A configurable core + opinionated defaults can serve that use case just as well.
Re: Prettier 2.0 – Opinionated JavaScript formatter
#83Earlier quoted context omitted.
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.
Deno's approach on the other hand is doesn't force any of that indirection onto the user, and is analogous to (and compatible with) the model of modules on the web. Package management systems can be easily layered on top of that if the use case actually warrants that extra indirection, rather than having it baked into the core of the runtime.
Re: Prettier 2.0 – Opinionated JavaScript formatter
#84Doesn't it defeat the idea of "one formatting to rule them all" if they change the rules?
I don't think Prettier ever claimed to be the one true formatting everyone must use for it to be successful. It's a tool that formats code nicer then most other tools. Personally, I would rather a project use a formatting tool that outputs a format I don't like than not using a formatting tool at all. I just don't want to have to waste mental bandwidth on formatting ever again.
I had the impression Prettier follwed the spirit of Go fmt, which had that claim.
Re: Prettier 2.0 – Opinionated JavaScript formatter
#85Earlier quoted context omitted.
> 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.
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
#86 const identity = function (value) {
return value;
};
This change is really confusing to me. I've never seen anyone who puts a space after the `function` keyword in an anonymous function.Re: Prettier 2.0 – Opinionated JavaScript formatter
#87const identity = function (value) { return value; }; This change is really confusing to me. I've never seen anyone who puts a space after the `function` keyword in an anonymous function.
Re: Prettier 2.0 – Opinionated JavaScript formatter
#88Earlier quoted context omitted.
This changes everything. Thank you!!!
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
#89Earlier quoted context omitted.
I don't think Prettier ever claimed to be the one true formatting everyone must use for it to be successful. It's a tool that formats code nicer then most other tools. Personally, I would rather a project use a formatting tool that outputs a format I don't like than not using a formatting tool at all. I just don't want to have to waste mental bandwidth on formatting ever again.
Really? I had the impression Prettier follwed the spirit of Go fmt, which had that claim.
Re: Prettier 2.0 – Opinionated JavaScript formatter
#90Earlier quoted context omitted.
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.
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.