DEV Community

Gloria Asuquo
Gloria Asuquo

Posted on

Javascript Style Guides

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.

Here is a list of JavaScript Style Guides to checkout:

●Google JavaScript Style Guide
πŸ”—https://google.github.io/styleguide/jsguide.html
●Airbnb JavaScript Style Guide
πŸ”—https://github.com/airbnb/javascript
●Idiomatic.JS
πŸ”—https://github.com/rwaldron/idiomatic.js
●StandardJS
πŸ”— https://standardjs.com/
Enter fullscreen mode Exit fullscreen mode

Discussion (11)

Collapse
darkwiiplayer profile image
π’Š©Wii πŸ’–πŸ’›πŸ’šπŸ’™πŸ’œπŸ’πŸ’Ÿ

I find it hard to take any style guide seriously that thinks spaces are a proper way of indenting code.

Collapse
lukeshiru profile image
Luke Shiru

This! Yet they dared to call one of those "standard" 🀣

Collapse
amiceli profile image
amiceli

I agree, but it's good basics. For example in my company we use AirBnB style guide but, without semi colon ;)

Collapse
glowreeyah profile image
Gloria Asuquo Author

I find it wild to not use semi colon in my code

Thread Thread
darkwiiplayer profile image
π’Š©Wii πŸ’–πŸ’›πŸ’šπŸ’™πŸ’œπŸ’πŸ’Ÿ

What's the point of typing extra clutter that adds no value to the code?

Collapse
joelbonetr profile image
JoelBonetR • Edited on
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 Author

Thank you for sharing

Collapse
amiceli profile image
amiceli

I did not know Iomatic.JS and there are very useful rules. Thanks for sharing ;)

Collapse
glowreeyah profile image
Gloria Asuquo Author

It's my pleasure

Collapse
yuridevat profile image
π•π•¦π•π•šπ•’ πŸ‘©πŸ»β€πŸ’» • Edited on

Thanks for sharing, Gloria. I didn't know about them, but they this is actually very useful at my current stage, so thank you!!

Collapse
glowreeyah profile image
Gloria Asuquo Author

You're welcome
I'm glad you find it helpful