Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tristan Cavelier
jio
Commits
a70dfbc1
Commit
a70dfbc1
authored
Feb 06, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style_guide.rst trailling spaces removed
parent
eddcb757
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
69 deletions
+68
-69
docs/style_guide.rst
docs/style_guide.rst
+68
-69
No files found.
docs/style_guide.rst
View file @
a70dfbc1
...
...
@@ -25,19 +25,19 @@ Good Example
.. code-block:: javascript
function sum(x, y) {
var result = x + y;
return result;
function sum(x, y) {
var result = x + y;
return result;
}
Bad Example
.. code-block:: javascript
function sum(x, y) {
// missing var declaration, implied global
result = x + y;
return result;
function sum(x, y) {
// missing var declaration, implied global
result = x + y;
return result;
}
...
...
@@ -61,7 +61,7 @@ In this project, JavaScript sources have to begin with the header:
.. code-block:: javascript
/*jslint indent: 2, maxlen: 80, nomen: true */
which means it uses two spaces indentation, 80
maximum characters per line and allows variable names starting with '_'.
Other JSLint options can be added in sub functions if necessary.
...
...
@@ -111,22 +111,22 @@ Good Example
};
};
}
return inner;
}
return inner;
}
Bad Example
.. code-block:: javascript
function outer(a, b) {
var c = 1,
d = 2,
inner;
if (a > b) {
inner = function () {
return {
r: c - d
function outer(a, b) {
var c = 1,
d = 2,
inner;
if (a > b) {
inner = function () {
return {
r: c - d
}}}};
...
...
@@ -170,12 +170,12 @@ Bad Example
.. code-block:: javascript
function func()
function func()
{
return
{
"name": "Batman"
};
return
{
"name": "Batman"
};
}
...
...
@@ -183,9 +183,9 @@ Good Example
.. code-block:: javascript
function func() {
return {
"name": "Batman"
function func() {
return {
"name": "Batman"
};
}
...
...
@@ -200,19 +200,20 @@ Bad Example
.. code-block:: javascript
function func() {
return {
"name": "Batman"
};
return {
"name": "Batman"
};
}
Good Example
.. code-block:: javascript
function func() {
return {
"name": "Batman"
};
function func() {
return {
"name": "Batman"
};
}
}
...
...
@@ -355,7 +356,7 @@ Example
test.setAttribute("id", "uniqueIdentifier");
// good example
test.setAttribute("id", "unique_identifier");
test.setAttribute("id", "unique_identifier");
Discuss - checked with jQuery UI/jQuery Mobile, they don't use written name conventions, only
...
...
@@ -374,29 +375,29 @@ Good Example
.. code-block:: javascript
var person = {
"getName": function () {
return this._getFirst() + " " + this._getLast();
},
"_getFirst": function () {
// ...
},
"_getLast": function () {
// ...
}
};
var person = {
"getName": function () {
return this._getFirst() + " " + this._getLast();
},
"_getFirst": function () {
// ...
},
"_getLast": function () {
// ...
}
};
Bad Example
.. code-block:: javascript
var person = {
"getName": function () {
return this.getFirst() + " " + this.getLast();
},
var person = {
"getName": function () {
return this.getFirst() + " " + this.getLast();
},
// private function
"getFirst": function () {
// ...
"getFirst": function () {
// ...
}
};
...
...
@@ -448,19 +449,19 @@ Good Example
var person = {
// returns full name string
"getName": function () {
return this._getFirst() + " " + this._getLast();
return this._getFirst() + " " + this._getLast();
}
};
};
Bad Example
.. code-block:: javascript
var person = {
"getName": function () {
return this._getFirst() + " " + this._getLast();
var person = {
"getName": function () {
return this._getFirst() + " " + this._getLast();
}
};
};
Documentation
...
...
@@ -474,14 +475,14 @@ Good Example
.. code-block:: javascript
/**
/**
* Reverse a string
*
* @param {String} input_string String to reverse
* @return {String} The reversed string
*/
function reverse(input_string) {
// ...
* @param {String} input_string String to reverse
* @return {String} The reversed string
*/
function reverse(input_string) {
// ...
return output_string;
};
...
...
@@ -489,10 +490,10 @@ Bad Example
.. code-block:: javascript
function reverse(input_string) {
// ...
function reverse(input_string) {
// ...
return output_string;
};
};
Additional Readings
...
...
@@ -504,5 +505,3 @@ Resources, additional reading materials and links:
* `JSLint <http://www.jslint.com/>`_, code quality tool.
* `JSLint Error Explanations <http://jslinterrors.com/>`_, a useful reference.
* `YUIDoc <http://yuilibrary.com/projects/yuidoc>`_, generate documentation from code.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment