Skip to content

1602/coding-style-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Naming

  • use camelCase everywhere, except constants which are UPPER_CASE_WITH_UNDERSCORE
  • start constructor name with upper case letter
  • do not use short variable names

Spaces

  • operators should be surrounded with spaces
  • anonyous function should not have space between function and (
  • maned function should have not have space between function name and (

Identation

We use 4 spaces for identation. No deep identation, i.e. use this way:

    do.something.awesome(function(imdone) {
        imdone();
    });

instead of this

    do.something.awesome(function(imdone) {
                             imdone();
                         });

Callback names

Use done, next, callback, cb or fn as callback param name.

Callback context binding, using self and that

Do not use bind, do not save this in self or that variable. Use meaningful variable name, for example:

Listing.prototype.update = function(done) {
    var listing = this;
    listing.products.update(function() {
        listing.update(done);
    });
};

Strings

Do not use ", use ' for strings.

Objects, arrays formatting

Right:

[
    'hello',
    'world',
    { foo: 'bar' }
];

Wrong:

[ 'hello' , 'world' , { 'foo': 'bar' , 'bar': 'baz' } ]

Chaining

Do not indent, start with dot:

$('#element')
.addClass('active')
.show();

Semicolons

Use them

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published