Live data from Hacker News

Prettier 1.0

jlongster.com

1–10 of 78 posts

Re: Prettier 1.0

#2
Prettier goes such a long way to enforcing standards on a language and ecosystem which otherwise has none or few. What standards do exist are frequently arbitrary, or enforced by legacy code at random companies. For example, the Airbnb JS style guide [1] recommends single quotes in JS, but double quotes for JSX properties. Why the difference? Why not stick with double quotes everywhere, as they are required in JSX blocks? Answer: legacy code at Airbnb [2]

I'm hoping to see similar efforts on project file/folder structure at some point. How often do two node projects created by different engineering teams end up with the same folder/file structure? There's nearly no strong community convention, unlike many other languages/frameworks. Rails, for example, famously touts that any engineer can walk onto another Rails project and have a reasonable suspicion of where to find a particular piece of code.

1: https://github.com/airbnb/javascript 2: https://twitter.com/hshoff/status/784205839347232768

Re: Prettier 1.0

#3
It would be useful to compare with "eslint --fix" given Eslint can already reformat (on top of linting non-style things, and projects usually already have Eslint settings).

Re: Prettier 1.0

#4
I can't overstate how freeing coding with prettier has been -- often I'd find myself quickly grokking something and once I finally got it to "work," make sure it was all styled properly. Since using prettier, these things are one-and-the-same, which is a tremendous gain.

Re: Prettier 1.0

#6

It would be useful to compare with "eslint --fix" given Eslint can already reformat (on top of linting non-style things, and projects usually already have Eslint settings).

There's also prettier-eslint[1], which will run prettier and then eslint --fix on your code to try give you the best of both worlds.

[1] https://github.com/prettier/prettier-eslint

Re: Prettier 1.0

#9
Prettier is a code formatter for JavaScript, like the hugely popular "gofmt".

Highlights of the 1.0 announcement:

- production-ready (and used, eg; React, Oculus, Cloudflare, etc)

- --no-semi option

- --use-tabs option

- parens that help indicate precedence

- many formatting improvements

There are a ton of edge cases in this work that really matter (read through the announcement for a few). Speaking as a contributor, this is some of the hardest stuff I've ever done (beats building a JS superset, http://lightscript.org). I've been super impressed by the prettier team.

Re: Prettier 1.0

#10

It would be useful to compare with "eslint --fix" given Eslint can already reformat (on top of linting non-style things, and projects usually already have Eslint settings).

From the readme:

Unlike ESLint ... everything is fixable. This works because Prettier never "checks" anything; it ... parses your JavaScript into an AST (Abstract Syntax Tree) and pretty-prints the AST, completely ignoring any of the original formatting.

There's an extremely important piece missing from existing styling tools: the maximum line length ... (ESLint never knows how to fix it).

https://github.com/prettier/prettier

Post reply on HN