r/javascript • • Apr 08 '18

I don't like prettier

It seems like prettier is becoming very popular. https://github.com/prettier/prettier

I don't like it. I don't like the whole "rewrite from AST" approach. I prefer a formatter with a lighter touch, that fixes a my mistakes, but also trusts me.

Yes, wrap that long line. But no, don't unwrap those short lines, I did that on purpose. Or I wanted an extra new line there. Or these variables are a matrix, don't reformat them, and don't make me add an ugly comment to turn you off.

I'm starting to feel like I'm alone in this though, that there's a pro-prettier movement, but not an anti-prettier movement (or a pro some-other-tool movement).

Anyone feel the same way? What tools do you use instead, if any? How do you deal with teammates pressuring you to use prettier?

449 Upvotes

258 comments sorted by

View all comments

962

u/grensley Apr 08 '18

Nobody loves what prettier does to their syntax

Everyone loves what prettier does to their coworkers' syntax

36

u/[deleted] Apr 08 '18

I feel like I'm the only one here who doesn't lose their mind over their coworkers' code.

22

u/1-800-BICYCLE Apr 08 '18

I definitely lose my mind over it. Can't help it.

19

u/GrizzRich Apr 09 '18

It's like nails on a chalkboard when I see code that's formatted inconsistently.

Like some lines with semicolons and some without will drive me crazy. Same with single vs double quotes.

10

u/betterhelp Apr 09 '18

If someone can't take care to format their code correctly it just makes me second guess the care they took writing it in general, and how much they looked over it, especially before committing.

Its like when you see debug statements and added then removed lines in files which otherwise weren't effected by code changes. Obviously who ever committed did not review their own commit.

4

u/not_useful_at_all Apr 09 '18

A leftover debug statement is a clear mistake, not a formatting preference.

→ More replies (1)

5

u/the_strangemeister Apr 09 '18

Last thing that made my neck hair rise was no spaces after commas in argument lists, not just that the spaces were missing, it was inconsistently missing. Dear God NO!

4

u/GrizzRich Apr 09 '18

"bob,bobby, robert,bobert"

screams into a pillow

→ More replies (1)
→ More replies (1)
→ More replies (1)

8

u/Dedustern Apr 09 '18

Heh, try working as a consultant.. Every few months, new codebases, every single one has some weird shit.

Like, a project with several repositories in Java. Oh, this one? We'll indent with 4 spaces. The next? 2 spaces. Gotta configure your editor every time you open each repository in IntelliJ because who nobody could be arsed to set standards for the whole project because everybody has opinions.

→ More replies (6)
→ More replies (3)

45

u/the_strangemeister Apr 08 '18

I agree with this guy... But those are some wise words dude. I'm not anti prettier but that doesn't mean I'm for it. It can't be all black n white. Kinda obvious after thinking about it.

0

u/[deleted] Apr 09 '18

[deleted]

0

u/[deleted] Apr 09 '18

[deleted]

7

u/kayzzer Apr 09 '18

This . People who are anti-prettier generally all seem to think it’s about making code formatting consistent. I honestly don’t care about that. I love it cause of how it just magically throws everything into place after I’ve brain dumped into the terminal and hit save.

→ More replies (1)

7

u/neotorama Apr 09 '18

Maybe it's maybelline

5

u/SolidR53 Apr 09 '18

Yeah I absolutely love to commit a fix for this thing and the precommit hook prettifies some other code in the same file that somebody else did. Makes my commit look like garbage.

Prettier? No thanks. Eslint? Yes.

→ More replies (3)

53

u/looneysquash Apr 08 '18

Except, we're already using eslint to enforce the basics, so my coworkers' syntax is fine.

83

u/[deleted] Apr 08 '18

The point is ending arguments about nit-picky standards amongst developers, full stop. That's why you can barely even configure it much. My team uses ESLint, and honestly, we've configured it into a hot pile of shit. I'd rather we use Prettier, even if I don't love every setting.

18

u/kuenx Apr 09 '18

We just use Airbnb's eslint rules and didn't tweak it much. We checked couple different ones and Airbnb's was the most sane. Discussion over, everyone writes nicely formatted code. It works for Node, browser, React, FlowType. Eslint autoformats too if you want.

What's the advantage of prettier?

22

u/Bettina88 Apr 09 '18 edited Apr 09 '18

Agreed. My biggest beef is with newlines.

I tend to logically space things out with newlines, which makes code much less cluttered and keeps different concepts within the code distinct. It also allows me to group sets of functions into conceptual blocks of code that belong together -- or perform similar/related tasks.

Enforcing regular line spacing is uglier, not prettier. Jamming everything into one consistent soup of code while destroying logical/conceptual groupings is to elevate visual order over understanding.

IMHO it's pretty but dumb.

Eslint is smarter. It prevents syntactical mistakes and logical inconsistency without obliterating conceptual organization.

→ More replies (6)

5

u/vinnl Apr 09 '18

That's why you can barely even configure it much.

The funny thing is that we started with JSLint that was barely configurable for the same reason. People didn't like it and switched to JSHint and later ESLint, because they were more configurable.

→ More replies (14)

0

u/[deleted] Apr 09 '18

[deleted]

→ More replies (3)
→ More replies (3)

4

u/jaman4dbz Apr 09 '18

This is gonna sound asinine, but get better co workers.

Easy for me to say I suppose, because I work with two juniors who had to learn to program like me, because as far as they're concerned I know what I'm doing.

7

u/bitrider Apr 09 '18

is incredible how programmers always think their own code is tight and awesome but others code suck... this is the first symptom of the problem. Prettier comes to unified all the design conventions people got in their minds to produce one single pattern design, and yes some will love what it does to their code, some will hate, but in the end will give so much to the whole that in my mind it makes it worth.

→ More replies (18)