4 ms·
Tools like prettier have gone a long way to standardizing formatting in JS.
by fiddlerwoaroof 7y ago
Tools like prettier have gone a long way to standardizing formatting in JS.
- Aeolun 7y agoYeah, it’s just a matter of saying ‘we use prettier’ and that kills all discussion on coding standards.
- paulddraper 7y agoAgreed. Prettier is de facto standard for new projects. It lets you choose quote character, indentation size, and that basically it.
- michaelcampbell 7y agoWell... https://prettier.io/docs/en/options.html https://prettier.io/docs/en/options.html
- paulddraper 7y ago> --tab-width > --single-quote I mentioned. > --use-tabs Relates to the "indentation width." > --print-width Yes, that's another big user-configurable parameter. > --trailing-comma This exists only for JS version compatibility. > --no-semi > --no-bracket-spacing > --arrow-parens Yeah, those are there too. --- But that's really it for JavaScript formatting options. Like I said, this produces very standardized code in the ecosystem. Compare to clang-format (which suports JavaScript): http://releases.llvm.org/5.0.0/tools/clang/docs/ClangFormatStyleOptions.html http://releases.llvm.org/5.0.0/tools/clang/docs/ClangFormatS...
- onion2k 7y agoclang-format is nice but it's closer to eslint than Prettier. It does a lot more than just enforcing what the code looks like.
- 9935c101ab17a66 7y agoAs michaelcampbell pointed out, prettier has ~20 pretty robust configuration options, and it's not exactly obscure information. If you're already aware of this, what do you feel is missing?
- another-dave 7y agoI thought GP was saying "that's it" as in, "no more discussions about it" not "that's all it can do".
- HJain13 7y agoI recently had an idea, where a plugin could apply my coding style to code, when I open the code but when I save, it saves it back in coding style for whoever/organisation I'm working for. Didn't find a plugin that already did that, do you guys know of one?
- 9935c101ab17a66 7y agoYah prettier does this (the tool the person you are replying to mentioned). It's very commonly used in JS dev, alongside things like husky which lets you do things like format code on commit. If you need more info, I can try and point you in the right direction.
- rgoulter 7y agoI've seen Husky+Prettier used to format on the pre-commit hook. Is "format on checkout" common? That'd make 'git diff' quite noisy.