This repository has been archived by the owner on Aug 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Contributing
Kyle Smith edited this page Aug 9, 2015
·
7 revisions
When contributing by opening a pull request, please make sure you follow the style that already exists in the files. Some common examples:
- Braces on the same line
//bad
for(var i = 0; i < 11; i++)
{
console.log(i);
}
//good
for(var i = 0; i < 11; i++) {
console.log(i);
}
- Use 3 equal signs (using 2 is only acceptable in CERTAIN situations)
//bad
if(variable1 == variable2) {}
if(variable1 != variable2) {}
//good
if(variable1 === variable2) {}
if(variable1 !== variable2) {}
- Don't put semicolons after braces, put them after every other statement
//bad
if(variable1 === variable2) {
same = true
};
//good
if(variable1 === variable2) {
same = true;
}
- Put spaces after commas, after parentheses (not before), before braces, etc...
//bad
if(variable1===variable2){
same=true;
}
//good
if (variable1 === variable2) {
same = true;
}
- Don't create lines that are too long
//bad
console.log('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890987654321');
//good
console.log('ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
'abcdefghijklmnopqrstuvwxyz' +
'1234567890987654321');
- Use single quotes
//bad
console.log("Double quotes are BAD!");
//good
console.log('Single quotes are GOOD!");
- Don't put commas after a property if nothing follows
//bad
var object = {
this.first: 1,
this.second: 2,
this.third: 3,
}
//good
var object = {
this.first: 1,
this.second: 2,
this.third: 3
}
Alright, thanks the end of my rant. I'm only writing this since I just spent hours fixing codacy stuff. Basically, don't do anything that would upset codacy.
I would also recommend following this guide, which is where I got some of these from. Thanks, and happy coding!