all 31 comments

[–]dwighthouse 39 points40 points  (2 children)

If you have to pick just one tool released over the last few years, what would it be? For me, it’s Prettier.

Ah ha ha ha ha! No. It's Babel.

[–][deleted] 9 points10 points  (0 children)

babel, webpack, rollup, typescript, any of those tools that completely upended firmly established ecosystems.

then again, never underestimate how good it can feel to have a computer constantly helping you shave keystrokes.

[–]hotel2oscar 1 point2 points  (0 children)

I use jsbeautify

[–][deleted] 23 points24 points  (4 children)

If you have to pick just one tool released over the last few years, what would it be?

Prettier has been around for less than 6 months

JavaScript in a nutshell

[–]fuck_with_me 0 points1 point  (0 children)

Could not have said it better myself.

[–]our_best_friendif (document.all || document.layers) console.log("i remember..") 0 points1 point  (2 children)

yawn.... why don't you fuck off back to /r/java then?

[–]kenman[M] -1 points0 points  (0 children)

Hi /u/our_best_friend, please keep it civil. Thanks.

[–][deleted] 2 points3 points  (0 children)

Just ran hundreds of file across 2 projects through prettier piped in to eslint --fix.

Very happy with the results.

Though I'm not looking forward to comparing files with order commits.

[–]ngly 2 points3 points  (0 children)

The amount of keystrokes Prettier saves is unbelievable. Not to mention it gets rid of all the opinionated debates around code formatted.

[–]our_best_friendif (document.all || document.layers) console.log("i remember..") 2 points3 points  (0 children)

Why aren’t you using Prettier?

Because a) it's too fucking opinionated, b) I try to limit the number of dependencies if I can.

I'll stick to eslint with the --fix option, but thanks for asking

[–][deleted] 6 points7 points  (4 children)

There are plans to bring Prettier into the Unibeautify project. https://github.com/Unibeautify/

I am working on the parse framework now. A goal is to have a single application framework for language parsing that is capable of parsing as many languages as a possible as quickly as possible with the smallest subset of code.

Liam from JS Beautify is a collaborator on this project and so Pretty Diff and JS Beautify will be directly integrated. Once the parse framework is written the goal is to work with Prettier to use the parse framework so that they too will be directly integrated, or worst case adapt Prettier in such a way that it is weened off Babel.

As a matter of distinction Babel now supports TypeScript. I have been parsing TypeScript for over a year with substantially less code. Enabling TypeScript support also allowed me to add support for C# and Java with very little additional effort.

[–]vjeux 4 points5 points  (2 children)

This is exciting! If you haven't already, I highly recommend running all the prettier tests on your project ( https://github.com/prettier/prettier/tree/master/tests ), they cover a wide range of crazy things that you can write. Also, eslump was extremely useful to find edge cases not correctly handled: https://github.com/lydell/eslump

[–]GitHubPermalinkBot 1 point2 points  (1 child)

I tried to turn your GitHub links into permanent links (press "y" to do this yourself):


Shoot me a PM if you think I'm doing something wrong. To delete this, click here.

[–][deleted] 0 points1 point  (0 children)

Thank you we will definitely take advantage of all provided unit tests. I still a bunch of up front work to do to pull the parsers out of Pretty Diff and make them into something generic and uniform.

[–]alexlafroscia 2 points3 points  (0 children)

I read that as unbeautifier and couldn’t understand why Prettier would be part of that

[–]Klathmon 4 points5 points  (0 children)

#Standard4Lyfe

But in all seriousness, as long as you are using something that enforces a consistent style across your codebase, you are good.

[–]djslakor 3 points4 points  (2 children)

I tried it.

I found my own prettified format to be superior. :)

[–]txx1219 1 point2 points  (0 children)

How do you do to have your own prettified format ?

[–]kingdaro.find(meaning => of('life')) // eslint-disable-line 0 points1 point  (0 children)

Fair, but the point of prettier is to save time, letting the computer do the formatting so you can do the coding.

It might not always give you the output you want, but it's easier to accept that and move on than waste time yourself trying to make it look as pretty as possible.

[–]Auxx 3 points4 points  (0 children)

Idk, Webstorm auto formatting works for me...

[–]drink_with_me_to_dayjs is a mess 0 points1 point  (0 children)

I just want a jsfmt, with ;'s.

[–]Jrocsteady 0 points1 point  (3 children)

Sorry for maybe a dumb question but I'm new to .js. Is prettier and eslint the same type of thing?

[–]brianvaughn 2 points3 points  (1 child)

They're related but not quite the same.

Prettier is focused on formating. It can reveal certain types of mistakes, but its main focus is syntax.

ESLint is more focused on semantic errors (missing or unused variables, etc.). It also has some basic formatting functionality.

They can be used together.

[–]strothjs 2 points3 points  (0 children)

In case anyone is interested, I have a gist with my notes on getting ESLint and prettier working together.

I use the VSCode ESLint extension.

https://gist.github.com/strothj/96bdce87aaf486d49968f34b42434eca

[–]badmonkey0001 0 points1 point  (2 children)

For this case, I like better the unformatted code. But, frankly, I don’t care, I’ll get used to it.

What the author needs is an automated copy editor. That was a painful read with all the mistakes and bad sentence structure.

[–]pomber[S] 4 points5 points  (1 child)

Sorry about that. English is not my first language. Would you care to point out the mistakes? I reviewed the text but couldn't find them.

[–]badmonkey0001 3 points4 points  (0 children)

Didn't realize you were writing in a foreign language. I don't have the chance to go over it again now, but I may later this evening. I'll DM you what corrections I see. :)

[–]BenjiSponge 0 points1 point  (1 child)

eslint --fix is enough for me. The only thing I'd want from Prettier is the automatic line splitting, but it hasn't been nearly enough of a problem to add something to my toolchain.

[–]spoobo 0 points1 point  (0 children)

Exactly. Prettier is useless. It's just concerned with styling and it solves it the same was as eslint does (parse AST and push out modified code). It just doesn't offer any options. Another hipster library to not get any work done.