Live data from Hacker News

A Prettier JavaScript Formatter

jlongster.com

21–30 of 159 posts

Re: A Prettier JavaScript Formatter

#21
post #7

Much better than "Standard JS" and its choice of no semicolons. I know about "Semi Standard JS", but I refuse to accept such a little difference that could be a configuration has to live in a entirely new project.

Note that Standard is a linter, this is a reformatter. Standard gives you errors but doesn't fix things for you.

Re: A Prettier JavaScript Formatter

#22
This has been the single biggest missing tool in the JS ecosystem. I never even realized until I experienced the magic of gofmt. It should honestly be a standard tool for new languages going forward. Kudos to the creator. I'll try it out later today - hopefully it works well for us.

Re: A Prettier JavaScript Formatter

#24
post #14

Nice attempt, but currently wrong. For example, it pretty-formats this code: function makeComponent() { return /*test*/ { a: 1 }; } into function makeComponent() { return /*test*/ { a: 1 }; } From my own experience writing a formatter, comments are very difficult (if one wants to preserve them). I guess the author should reparse the generated code to ensure the AST hasn't changed.

We do. The entire Flow test suite passes when pretty-printing and re-parsing and comparing ASTs. There are a very few subtle bugs like the one you mentioned above. As noted in the readme, this is a beta. It's certainly more than an attempt.

Don't let HN negativity get you down. This is an awesome project and I'll contribute bug fixes/test cases if we end up adopting it on our team (very likely based on your blog post).

Re: A Prettier JavaScript Formatter

#26

Earlier quoted context omitted.

We do. The entire Flow test suite passes when pretty-printing and re-parsing and comparing ASTs. There are a very few subtle bugs like the one you mentioned above. As noted in the readme, this is a beta. It's certainly more than an attempt.

Don't let HN negativity get you down. This is an awesome project and I'll contribute bug fixes/test cases if we end up adopting it on our team (very likely based on your blog post).

the parent gave an ill example and suggest a solution, how's that a negativity?

Re: A Prettier JavaScript Formatter

#28
How does this handle tabs vs spaces? I looked the post, the repo and the issues page and I didn't find anything. I'm specially concerned about not seeing this in the options of the API, since there are strong opinions on both sides.

Re: A Prettier JavaScript Formatter

#30
post #26

Earlier quoted context omitted.

Don't let HN negativity get you down. This is an awesome project and I'll contribute bug fixes/test cases if we end up adopting it on our team (very likely based on your blog post).

the parent gave an ill example and suggest a solution, how's that a negativity?

I believe it was the "Nice attempt, but currently wrong." at the start of the comment. "Nice attempt" could imply that this should be thrown out in favor of another attempt to solve the problem.
Post reply on HN