Skip to content

Commit e4b887c

Browse files
author
Martii
committed
Some fixes for STYLEGUIDE.md
* Use `a` prefix on declared parameter lists... change all samples and mirror under naming * Use `www` for Wikipedia ... this allows Wikipedia to choose the language based off browser instead of us. * Miscellaneous sentence structure enhancement. * Whitespace adjustment Applies to OpenUserJS#262
1 parent b6d61f8 commit e4b887c

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

STYLEGUIDE.md

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# OpenUserJS.org Style Guide
2-
31

2+
# OpenUserJS.org Style Guide
43

54
### Preliminary Notes
65

@@ -26,7 +25,7 @@ To help with the above rules, we use [EditorConfig][editorconfig]. Install the p
2625

2726
### Variable Declarations
2827

29-
All variables should be declared before used. JavaScript does not require this, but doing so makes the program easier to read and makes it easier to detect undeclared variables that may become implied globals. Implied global variables should never be used.
28+
All variables should be declared before used. JavaScript does not require this by default, but doing so makes the program easier to read and makes it easier to detect undeclared variables that may become implied globals. Implied global variables should never be used.
3029
Variable declarations without value should be initialized to `null`
3130

3231
All variable statements should be the first statements within the function body.
@@ -52,13 +51,14 @@ All functions should be declared, before they are used, after the variable decla
5251
* There should be one space between the right-parenthesis and the left-curly-brace that begins the statement body.
5352
* The body itself is indented two spaces.
5453
* The right-curly-brace is aligned with the line containing the beginning of the function declaration.
54+
* Declared parameter lists variables should start with a lower case a, which stands for argument, and continue with [camel casing][camelcase] *(except if the phrase is an acronym like HTML)*.
5555

5656
```javascript
57-
function outer(c, d) {
58-
var e = c * d;
57+
function outer(aC, aD) {
58+
var e = aC * aD;
5959

60-
function inner(a, b) {
61-
return (e * a) + b;
60+
function inner(aA, aB) {
61+
return (e * aA) + aB;
6262
}
6363

6464
return inner(0, 1);
@@ -77,7 +77,7 @@ If a function literal is anonymous, there should be one space between the word `
7777
If the space is omitted, then it can appear that the function's name is `function`, which is incorrect.
7878

7979
```javascript
80-
div.onclick = function (e) {
80+
div.onclick = function (aE) {
8181
return false;
8282
};
8383

@@ -171,6 +171,13 @@ var rSelector = /^\*|^\.[a-z][\w\d-]*|^#[^ ]+|^[a-z]+|^\[a-z]+/i; // matches a
171171
var rHTML = /<[^>]+>/; // matches a string of HTML
172172
```
173173

174+
Declared parameter lists variables should start with a lower case a, which stands for argument, and continue with [camel casing][camelcase] *(except if the phrase is an acronym like HTML)*.
175+
176+
```javascript
177+
function foo(aName, aValue) {
178+
}
179+
```
180+
174181
---
175182

176183
### Statements
@@ -391,7 +398,7 @@ Read more on the [awful parts of JavaScript][awfulparts].
391398
[WIKIPEDIABOM]: http://www.wikipedia.org/wiki/Byte_order_mark
392399
[IETFRFC3629S4]: http://tools.ietf.org/html/rfc3629#section-4
393400
[awfulparts]: http://oreilly.com/javascript/excerpts/javascript-good-parts/awful-parts.html
394-
[camelcase]: http://en.wikipedia.org/wiki/CamelCase
401+
[camelcase]: http://www.wikipedia.org/wiki/CamelCase
395402
[codeconventions]: http://javascript.crockford.com/code.html
396403
[editorconfig]: http://editorconfig.org/
397404
[impliedglobals]: http://www.adequatelygood.com/Finding-Improper-JavaScript-Globals.html

0 commit comments

Comments
 (0)