diff --git a/developer_manual/app/general/codingguidelines.rst b/developer_manual/app/general/codingguidelines.rst index 0b6690fd5..169203683 100644 --- a/developer_manual/app/general/codingguidelines.rst +++ b/developer_manual/app/general/codingguidelines.rst @@ -171,11 +171,11 @@ In general take a look at `JSLint `_ without th // set up namespace for sharing across multiple files var MyApp = MyApp || {}; - (function(window, $, exports){ + (function(window, $, exports) { 'use strict'; // if this function or object should be global, attach it to the namespace - exports.myGlobalFunction = function(params){ + exports.myGlobalFunction = function(params) { return params; }; @@ -189,7 +189,7 @@ In general take a look at `JSLint `_ without th // This does not only make everything global but you're programming // JavaScript like C functions with namespaces MyApp = { - myFunction:function(params){ + myFunction:function(params) { return params; }, ... @@ -204,17 +204,17 @@ This is how you'd do inheritance in JavaScript: .. code-block:: javascript // create parent object and bind methods to it - var ParentObject = function(name){ + var ParentObject = function(name) { this.name = name; }; - ParentObject.prototype.sayHello = function(){ + ParentObject.prototype.sayHello = function() { console.log(this.name); } // create childobject, call parents constructor and inherit methods - var ChildObject = function(name, age){ + var ChildObject = function(name, age) { ParentObject.call(this, name); this.age = age; }; @@ -222,7 +222,7 @@ This is how you'd do inheritance in JavaScript: ChildObject.prototype = Object.create(ParentObject.prototype); // overwrite parent method - ChildObject.prototype.sayHello = function(){ + ChildObject.prototype.sayHello = function() { // call parent method if you want to ParentObject.prototype.sayHello.call(this); console.log('childobject'); @@ -241,11 +241,11 @@ Use Pascal case for Objects, Camel case for functions and variables. .. code-block:: javascript - var MyObject = function(){ + var MyObject = function() { this.attr = "hi"; }; - var myFunction = function(){ + var myFunction = function() { return true; }; @@ -289,7 +289,7 @@ Control Structures .. code-block:: javascript // single line if - if(myVar === 'hi'){ + if(myVar === 'hi') { myVar = 'ho'; } else { myVar = 'bye'; @@ -299,17 +299,17 @@ Control Structures if( something === 'something' || condition2 && condition3 - ){ + ) { // your code } // for loop - for(var i=0; i<4; i++){ + for(var i=0; i<4; i++) { // your code } // switch - switch(value){ + switch(value) { case 'hi': // yourcode