- Use 2 spaces indentation (no tabs)
- Use utf-8 charset
- Use LF (
\n
) for end of lines (seeWikipedia
)
This config is available in a .editorconfig
Make sur your code pass the both with .jshintrc
and .eslintrc
.
There is many plugins to run those linter while saving on your favorite editor.
Line length must be 80 characters or less.
Always declare 'use strict';
at the top of your files.
If the file may be required by external code, bind it into a closure for example :
// bad
'use strict';
…
// good
/*eslint-disable strict */
(function() {
'use strict';
…
})();
- Use English only.
- Use camelCase for objects, functions, instances.
// bad var MYUSER = {} , user_uuid = '' ; // good var myUser = {} , userUuid = '' ;
- Use PascalCase for constructors or classes
// bad var user = new userObject(); // god var user = new UserObject();
// bad
var item = new Object();
// good
var item = {};
// bad
var items = new Array();
// good
var items = [];
Use single quotes ''
for strings.
// bad
var name = "Bob";
// good
var name = 'Bob';
// bad
var user = {
firstName: 'Robert',
lastName: 'MARTIN',
role: 'admin',
createdAt: '2015-04-14'
}
// good
var user = {
firstName: 'Robert'
, lastName: 'MARTIN'
, role: 'admin'
, createdAt: '2015-04-14'
}
OpenDena coding-style is under the MIT license. Please see
LICENSE