Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.
Boris Yankov edited this page Jul 10, 2014 · 26 revisions

Coding guidelines

JSHint

We use JSHint to enforce certain coding principles.

Description of JSHint Options

JSHint Error Explanations

JSHInt Default Options

Anonymous closures

Use always, to prevent global variables:

(function () {
    // ... all vars and functions are in this scope only
    // still maintains access to all globals
}());

Strict Mode

Include at the beginning of each .js file:

"use strict";

It is important that each statement is put in a closure like this (so the strict mode does not extend when bundling to files that are not intended):

(function(){
    "use strict";

    // All other code here
})();

More details on strict mode:

ECMAScript 5 Strict Mode, JSON, and More

Strict Mode

It’s time to start using JavaScript strict mode

Naming conventions

Variables that contain jquery selected elements should start with a '$'.

Don't:

var due = $('#due');

Do:

var $due = $('#due');
Clone this wiki locally