I’ve come to know of two popular style guides:
From what I’ve read, their eslint configs have some strange rules:
forEach.What do you think of these style guides.? Do you use any of these, or do you have your own custom style guide that you’ve crafted for use? Sharing your eslint config files in your answers would be super awesome! Thanks! 😃
We use Google style with some modifications:
After wasting 2 days of my life reading about over 9000 ESlint configurations and writing it, I decided just to use airbnb core and change whatever I don't like. Usually I have mix with Crockford's style guide and Google's.
At the end all those semicolons, spaces doesn't matter too much because good engineer same as a good teacher can read even very "bad handwriting". Discipline is, of course, important and might tell a lot about the person, but don't let anyone waste their time and focus on fighting which coding style is better. Better is always your team.
Our JS style guide is an ESLint config determined with a reasonably quick discussion between our frontend devs. We referred to Airbnb but didn't lift it directly, basically we just had a chat about what we thought was reasonable and someone did the work to codify it in the config and handle that painful first commit that brings the existing code into line.
Basically what I'd suggest - there's no universally right or wrong config (even though personally I think there are some universally right/wrong choices within the options ;)). It's about a workable standard that fits your team's needs.
I personally follow airbnb's style guide as much as possible and it serves me well so far.
I personally know of some pitfalls of no semicolon design, so Feross' would be a no-go. Nearly all languages require a semicolon or something similar, so a semicolon also increases recognizability for other developers who work with different languages.
From a pure performance viewpoint, the following loop is the most performant:
const arr = [1,2,3,4];
var i = 0;
const l = arr.length;
while (i < l) {
console.log(arr[i]);
i++;
}
It's very easy to adapt to all kinds of situations, so for me, it's my preferred kind of loop. Someone forcing me to use something else as part of a styleguide is giving me an unpleasant feeling, so I don't really like the second styleguide either.
I use the Google Styleguide with the addition that I leave a blank line after every opening curly bracket in order to leave more space in my code (see code snippet above for example). I like it when my code is not pressed together :)
Darshak Parikh
Front-end developer at Digitate
I use Standard in some projects and XO in others. Would love to try out the ones mentioned in other answers.