DEV Community

Discussion on: Javascript Style Guides

Collapse
 
joelbonetr profile image
JoelBonetR πŸ₯‡ • Edited
A style guide contains general rules about how to write code. They could include a better way to indent, where to place a function etc.

I'd better define them like that:

Style guides contain general rules about how the code should look like. Those rules are opinionated with few to zero basis on anything. They are not meant to solve any issue other than having a project's entire codebase looking the same way, thus reducing the fatigue of devs involved on it.

As personal opinion on that, you should just stick to what the project states for the reason above, use Prettier (VSCode extension) with format on save enabled to avoid having to learn the style guides on each project you jump into, thus being released of that styling job which can be automated easily.

This way you code once with your own style and it gets formatted when saving according to the defined styles (usually in a Prettier.rc or an ESLint.rc file).

i.e. If your opinion is that using tabs is better than using spaces then use tabs always, if the project has spaces in the config, prettier will handle that for you. In your own projects you can set it to tabs and code the same way.


Didn't bring a linter but a lantern πŸ€·πŸ½β€β™‚οΈπŸ˜…

Collapse
 
glowreeyah profile image
Gloria Asuquo

Thank you for sharing