5 ms·
I also recommend `prettier`. It can be configured to obey eslint and will reformat your code on the fly to fit standards so you can spend less time fighting spa
by vorpalhex 7y ago
I also recommend `prettier`. It can be configured to obey eslint and will reformat your code on the fly to fit standards so you can spend less time fighting spacing and more time just writing code. While `eslint --fix` is a thing, prettier parses the underlying AST to do it's transformations and it's a very impressive tool.
- tomduncalf 7y agoYeah, prettier rocks. I was skeptical for a long time and if I’m honest and think about it I still don’t like some of the formatting choices it makes, but I don’t notice because of how fluid and pleasant it makes writing code. As an aside, often the “workarounds” result in clearer code, e.g. long formulas getting split up weirdly leads to me splitting stages of the calculation into named variables, which actually reads much better when I return to it months later. No worrying about formatting code as I type, no worrying about checking style on PRs... definitely worth the trade offs for me, I enable it on every project I work on now.
- Drdrdrq 7y agoAnd if you are working in a team it makes those arguments about styling moot. One of the best aspects of JavaScript.
- tomduncalf 7y agoYeah that’s what I mean about PRs - such a time saver to not discuss trivial code style issues and be able to just focus on the code itself!
- _virtu 7y agoI'll never forget getting our team of 90+ devs to move to prettier because of this argument and then having team members proceed to strong arm me to change the configs to things that they preferred six months after we made the move and we had adopted it across over 10 different repos. Talk about counter to the whole point of using such a wonderful tool.
- tomduncalf 7y agoThat must have been frustrating - I do feel like perhaps they made a mistake adding configuration to prettier at all! But especially for matters of preference such as single vs double quotes where ultimately it makes very little difference. Luckily my team are happy with the defaults + slightly longer line length
- tracker1 7y agoyeah, I pretty much rely on eslint and prettier across the board... I do have a couple tweaks though[1]. 1. https://gist.github.com/tracker1/e6c2befae41856da27973cf22cf2f346 https://gist.github.com/tracker1/e6c2befae41856da27973cf22cf...
- gfxgirl 7y agoIt should be renamed 'uglier' or 'obfusticate' const normals = [ -1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1, ]; const positions = [ -1, -1, 0, 1, -1, 0, -1, -1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0, ] ctx.drawImage( image, srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight, ) becomes const normals = [-1, -1, -1, 1, -1, -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, 1, 1, 1]; const positions = [ -1, -1, 0, 1, -1, 0, -1, -1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0, ]; ctx.drawImage( image, srcX, srcY, srcWidth, srcHeight, dstX, dstY, dstWidth, dstHeight ); Those are less pretty and useful info is lost.
- hombre_fatal 7y agoYou can tell prettier to ignore the next node: https://prettier.io/docs/en/ignore.html https://prettier.io/docs/en/ignore.html
- iandev 7y agoIf your team consistently writes code that looks like your first example, you absolutely shouldn't use prettier. However, in my experience, your first example isn't what people regularly produce and the output is a wild improvement on a lot of things that I've seen people write.
- dr_zoidberg 7y agoThe use of code "prettifiers" (in general) helps save effort on having a code style guide, and people following it. As you, and others have said, it depends on the project. Clearly for projects where devs have the habit and follow a clear style, it's not necessary. However on mosy projects, you'll have the one guy who doesn't follow, or worse, the only one guy who follows the style. And so the prettifiers become absolutely necessary.
- secondaryditto 7y ago