You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/style-guides/javascript/README.md
+73-24Lines changed: 73 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -69,7 +69,7 @@ Hopefully, most of the conventions outlined below will help enable you to do so.
69
69
70
70
##### Reason
71
71
72
-
Tab indentation allows the developer to specify the space indentation equivalent in her editor. For example, in [Sublime Text][sublime-text], you can specify in your user preferences
72
+
Tab indentation allows a developer to specify the space indentation equivalent in her editor. For example, in [Sublime Text][sublime-text], you can specify in your user preferences
73
73
74
74
```text
75
75
"tab_width": 4
@@ -91,7 +91,7 @@ This project contains an [`.editorconfig`][editorconfig] file to be used in conj
91
91
92
92
<!-- <rule> -->
93
93
94
-
### Rule: Include space before leading brace
94
+
### Rule: Include a space before leading brace
95
95
96
96
##### Reason
97
97
@@ -525,7 +525,7 @@ TODO: ESLint rule
525
525
526
526
##### Reason
527
527
528
-
While semicolons are [not required][ecma-262] in most cases due to [automatic semicolon insertion][ecma-262], prefer to be explicit in specifying when a statement ends. Additionally, inREPL environments, semicolons acquire special meaning; notably, they silence return value output.
528
+
While semicolons are [not required][ecma-262] in most cases due to [automatic semicolon insertion][ecma-262], prefer to be explicit in specifying when a statement ends. Additionally, incertain REPL environments, semicolons acquire special meaning; notably, they silence return value output.
529
529
530
530
##### Bad Example
531
531
@@ -915,7 +915,7 @@ Code review.
915
915
916
916
<!--<rule>-->
917
917
918
-
### Rule: Use for loop to convert array-like objects
918
+
### Rule: Use a for loop to convert array-like objects
919
919
920
920
##### Reason
921
921
@@ -1079,7 +1079,7 @@ Code review.
1079
1079
1080
1080
##### Reason
1081
1081
1082
-
Trailing commas in `objects` is not valid JSON.
1082
+
An object which includes a trailing comma is not valid JSON.
1083
1083
1084
1084
##### Bad Example
1085
1085
@@ -1234,7 +1234,7 @@ Code review. Look for excessive indentation.
1234
1234
1235
1235
##### Reason
1236
1236
1237
-
Declaring within loops and conditions may result in repeated function creation and variables in the outer scope may change leading to subtle bugs.
1237
+
Declaring within loops and conditions may result in repeated function creation, and variables in the outer scope may change leading to subtle bugs.
A library should `throw` and provide tailored `error` messages if expected conditions are not met. Doing so facilitates debugging and eases code maintenance (see [programmer errors](https://www.joyent.com/developers/node/design/errors)).
2177
+
Throw and provide tailored `error` messages if expected conditions are not met. Doing so facilitates debugging and eases code maintenance (see [programmer errors](https://www.joyent.com/developers/node/design/errors)).
2135
2178
2136
2179
##### Bad Example
2137
2180
@@ -2428,6 +2471,7 @@ function transform( str ) {
2428
2471
##### Notes
2429
2472
2430
2473
* Be sure to include parameters, parameter types, returntypes (if any), errors (if any can be thrown), and examples.
2474
+
* Use Markdown syntax for extended comments.
2431
2475
2432
2476
##### Enforcement
2433
2477
@@ -2551,7 +2595,7 @@ function factorial( x ) {
2551
2595
2552
2596
##### NOTE
2553
2597
2554
-
Use `// NOTE:` to annotate questions, comments, or anything which does not fit under `TODO`/`FIXME`/`HACK`/`WARNING`/`OPTIMIZE` which should be brought to a user's attention.
2598
+
Use `// NOTE:` to annotate questions, comments, or anything which does not fit under `TODO`, `FIXME`, `HACK`, `WARNING`, `OPTIMIZE` which should be brought to a user's attention.
2555
2599
2556
2600
``` javascript
2557
2601
// NOTE: consider optimizing this for large arrays (len > 64K).
@@ -2763,13 +2807,15 @@ request({
2763
2807
##### Bad Example
2764
2808
2765
2809
```javascript
2810
+
// Do not...
2766
2811
var arr = [ 1, 2, 3 ];
2767
2812
var out =arr.map( x=> x * x );
2768
2813
```
2769
2814
2770
2815
##### Good Example
2771
2816
2772
2817
```javascript
2818
+
// Do...
2773
2819
functionsquare( x ) {
2774
2820
return x * x;
2775
2821
}
@@ -2808,12 +2854,14 @@ var VALUE = 3.14;
2808
2854
##### Bad Example
2809
2855
2810
2856
```javascript
2857
+
// Do not...
2811
2858
constvalue=3.14;
2812
2859
```
2813
2860
2814
2861
##### Good Example
2815
2862
2816
2863
```javascript
2864
+
// Do...
2817
2865
constVALUE=3.14;
2818
2866
```
2819
2867
@@ -3177,6 +3225,7 @@ function autocorr( vector ) {
3177
3225
*
3178
3226
* @example
3179
3227
* var arr = [ 1, 6, 5, 4, 7, 2, 3, 1 ];
3228
+
* var v =autocorr( arr );
3180
3229
*/
3181
3230
functionautocorr( vector ) {
3182
3231
// Calculate...
@@ -3401,7 +3450,7 @@ Code review.
3401
3450
3402
3451
##### Reason
3403
3452
3404
-
Any dependency you use becomes your responsibility. Demand the same level of robustness and correctness in your dependencies as you do in your code.
3453
+
Any dependency you use becomes __your__ responsibility. Demand the same level of robustness and correctness in your dependencies as you do in your code.
0 commit comments