Skip to content

Code Conventions

Tomás Veras edited this page Apr 24, 2016 · 10 revisions

General Rules

  • Strive to keep lines under 120 chars (everyone hates horizontal scroll). Atom has a ruler which helps to identify where is the limit, go to settings and set Preferred Line Length to 120.
  • If the code fits on one line and doesn't break our code conventions, strive to keep it on one line.
  • We use 4 spaces indentation. Atom can do this just go to settings and set Tab Length to 4

JS

Type of variables:

let: the variable may be reassigned.

const: the variable can’t be reassigned.

Naming variables:

We are using the Hungarian notation, Ex:

let carColor;

const houseDoorSize;

String:

For the string we use simple quotes ' ', Ex:

const myName = 'Mike Wazowski';

Formatting:

This how we're going to formatting our code. If one condition use brackets, all the conditions will need brackets too.

Ex #1:

if (condition) {
    //Multiple lines
} else {
    //One line
}

Ex #2:

 if (condition) 
    //One line 
 else 
    //One line

Spacing:

We are using four-character indents, Ex:

if( car.id == 79){
    car.color = blue;
    var wheels =  car.wheels;
}

Clone this wiki locally