codingguidelines: Always use one space in front of opening braces

This commit is contained in:
Stefan Herbrechtsmeier
2013-03-09 13:27:52 +01:00
parent db321e415a
commit f91d80f8c7

View File

@@ -171,11 +171,11 @@ In general take a look at `JSLint <http://www.jslint.com/lint.html>`_ 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 <http://www.jslint.com/lint.html>`_ 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