I recall the React team were discussing at what part of the build step they should include Prettier. I believe there was an idea of adding it as a pre-commit hook, a second one as a manual step and another one as a post-commit amend. Have we reached a consensus on that? Not up to date what they went with, what seems to be the best way to do this?
I run it at pre-commit and in CI before approving a PR. Basically my thought is to trust my team to do it whatever way they want to, in the editor, manually, or as a commit hook; and then verify it on the backend before committing.
Prettier 1.0
71–78 of 78 posts
Re: Prettier 1.0
#72Earlier quoted context omitted.
While I understand the reasons for this (especially with the culture, for lack of a better word, around Go), I feel like this is a step backward in general. The "standard" Haskell formatter, hindent, did something similar. I found the maintainer's behavior admirable -- the style that was agreed on was very different from his own, but it was what he saw after analyzing publicly available code -- but what's the problem…
What's the advantage of project specific, custom formats?
Re: Prettier 1.0
#73Earlier quoted context omitted.
We had configurability in early versions of gofmt but realized it was a mistake and kinda missed the whole point of having a code formatter, so we removed them.
While I understand the reasons for this (especially with the culture, for lack of a better word, around Go), I feel like this is a step backward in general. The "standard" Haskell formatter, hindent, did something similar. I found the maintainer's behavior admirable -- the style that was agreed on was very different from his own, but it was what he saw after analyzing publicly available code -- but what's the problem…
Re: Prettier 1.0
#74Going through all code at once would destroy all relevant vcs history and git blame. Maybe before each substantial edit on a file first run it through prettier and then make your real changes in a separate commit?
Re: Prettier 1.0
#75I'll never understand code formatters. For me the idea of my code passing through a formatter, is like if accidentally I lost part of it: there is a lot of care in the way you write your code, even in the part that the compiler does not care about: spaces. Spaces are the rhythm of the code... not sure why one would write code without rhythm and later add a synthetic one.
You might be surprised at the quality of the output (obviously I'm biased). We've tried to choose what most people consider to be the best way to style code, and many times prettier ends up formatting complex code better than I would have manually. Also, the biggest benefit that a lot of people don't realize is it allows you to quickly restructure your code easily: http://jlongster.com/s/refactor.gif I understand if…
Re: Prettier 1.0
#76What's the best way to add this to an existing project? Going through all code at once would destroy all relevant vcs history and git blame. Maybe before each substantial edit on a file first run it through prettier and then make your real changes in a separate commit?
Re: Prettier 1.0
#77I recall the React team were discussing at what part of the build step they should include Prettier. I believe there was an idea of adding it as a pre-commit hook, a second one as a manual step and another one as a post-commit amend. Have we reached a consensus on that? Not up to date what they went with, what seems to be the best way to do this?
We currently do the same thing Jest does: no hooks, but we offer it as `npm run prettier`, and we also run the comparison on CI (so if the prettier output is different, the PR fails). This means the code is always checked in formatted, but people need to remember to run `npm run prettier` or CI will fail.
Re: Prettier 1.0
#78Earlier quoted context omitted.
Can it handle escaped json string constants? For example this: http://whitneyland.com/2017/04/first-in-the-world-to-display...
You can try prettier online at https://prettier.github.io/prettier/ Not sure exactly what you mean, but here's an example with JSON: https://prettier.github.io/prettier/#%7B%22content%22%3A%22x... Prettier doesn't support JSON files per se (and doesn't currently plan to [0]), so you need to provide a leading `x = {...` or similar to ensure the { is parsed as an object instead of a block. [0] https://github.com/pretti…
If you have a constant like this, except really long and ugly, there's quite a bit that can be done to make the code more readable.
Maybe I'll add an issue and see if anyone else cares about it.
var simpleJson = '{ "DevelopersNeedUXToo": [ { "Color": "Red", "Name": "Lee" } ] }'