Skip to content

Commit da77ea5

Browse files
committed
Fix typos
1 parent 3435165 commit da77ea5

File tree

1 file changed

+73
-24
lines changed

1 file changed

+73
-24
lines changed

docs/style-guides/javascript/README.md

Lines changed: 73 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Hopefully, most of the conventions outlined below will help enable you to do so.
6969

7070
##### Reason
7171

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
7373

7474
``` text
7575
"tab_width": 4
@@ -91,7 +91,7 @@ This project contains an [`.editorconfig`][editorconfig] file to be used in conj
9191

9292
<!-- <rule> -->
9393

94-
### Rule: Include space before leading brace
94+
### Rule: Include a space before leading brace
9595

9696
##### Reason
9797

@@ -525,7 +525,7 @@ TODO: ESLint rule
525525

526526
##### Reason
527527

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, in REPL 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, in certain REPL environments, semicolons acquire special meaning; notably, they silence return value output.
529529

530530
##### Bad Example
531531

@@ -915,7 +915,7 @@ Code review.
915915

916916
<!-- <rule> -->
917917

918-
### Rule: Use for loop to convert array-like objects
918+
### Rule: Use a for loop to convert array-like objects
919919

920920
##### Reason
921921

@@ -1079,7 +1079,7 @@ Code review.
10791079

10801080
##### Reason
10811081

1082-
Trailing commas in `objects` is not valid JSON.
1082+
An object which includes a trailing comma is not valid JSON.
10831083

10841084
##### Bad Example
10851085

@@ -1234,7 +1234,7 @@ Code review. Look for excessive indentation.
12341234

12351235
##### Reason
12361236

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.
12381238

12391239
##### Bad Example
12401240

@@ -1357,7 +1357,7 @@ TODO: ESLint rule
13571357

13581358
<!-- <rule> -->
13591359

1360-
### Rule: Enclosed functions below return statement
1360+
### Rule: Declare enclosed functions below return statement
13611361

13621362
##### Reason
13631363

@@ -1426,7 +1426,7 @@ TODO: ESLint rule
14261426

14271427
<!-- <rule> -->
14281428

1429-
### Rule: Primitive expressions over functional counterparts
1429+
### Rule: Use primitive expressions over functional counterparts
14301430

14311431
##### Reason
14321432

@@ -1565,7 +1565,7 @@ request({
15651565

15661566
##### Notes
15671567

1568-
* If no errors; the `error` argument should be `null`.
1568+
* If no errors, the `error` argument should be `null`.
15691569

15701570

15711571
##### Enforcement
@@ -1590,7 +1590,7 @@ Code review.
15901590

15911591
<!-- <rule> -->
15921592

1593-
### Rule: Prefer closure and function factories
1593+
### Rule: Prefer closures and function factories
15941594

15951595
##### Reason
15961596

@@ -1646,6 +1646,49 @@ Code review.
16461646

16471647
<!-- </rule> -->
16481648

1649+
<!-- <rule> -->
1650+
1651+
### Rule: Name all functions
1652+
1653+
##### Reason
1654+
1655+
Named `functions` are easier to find in stack traces and consequently debug.
1656+
1657+
##### Bad Example
1658+
1659+
``` javascript
1660+
// Do not...
1661+
1662+
function beep( f ) {
1663+
f();
1664+
}
1665+
1666+
beep( function() {
1667+
console.log( 'boop' );
1668+
});
1669+
```
1670+
1671+
##### Good Example
1672+
1673+
``` javascript
1674+
// Do...
1675+
1676+
function beep( f ) {
1677+
f();
1678+
}
1679+
function boop() {
1680+
console.log( 'boop' );
1681+
}
1682+
1683+
beep( boop );
1684+
```
1685+
1686+
##### Enforcement
1687+
1688+
TODO: ESLint rule
1689+
1690+
<!-- </rule> -->
1691+
16491692
<!-- </rule-set> -->
16501693

16511694

@@ -1673,7 +1716,7 @@ NaN = null; // throws an Error
16731716

16741717
##### Notes
16751718

1676-
* Prefer [strict mode][strict-model] for a whole script. If not possible, use [strict mode][strict-mode] for each available `function`.
1719+
* Prefer [strict mode][strict-mode] for a whole script. If not possible, use [strict mode][strict-mode] for each available `function`.
16771720

16781721
``` javascript
16791722
function beep() {
@@ -1699,7 +1742,7 @@ TODO: ESLint rule
16991742

17001743
<!-- <rule> -->
17011744

1702-
### Rule: Never pass arguments variable to another function
1745+
### Rule: Never pass the arguments variable to another function
17031746

17041747
##### Reason
17051748

@@ -1739,7 +1782,7 @@ TODO: ESLint rule
17391782

17401783
<!-- <rule> -->
17411784

1742-
### Rule: Reassign input arguments when using arguments variable
1785+
### Rule: Reassign input arguments when using the arguments variable
17431786

17441787
##### Reason
17451788

@@ -1810,28 +1853,28 @@ Ensures a regular expression is only created once and improves readability.
18101853

18111854
``` javascript
18121855
// Do not...
1813-
beep();
1814-
18151856
function beep( str ) {
18161857
if ( /\.+/.test( str ) ) {
18171858
// Do something...
18181859
}
18191860
}
1861+
1862+
beep();
18201863
```
18211864

18221865
##### Good Example
18231866

18241867
``` javascript
18251868
// Do...
1826-
var regex = /\.+/;
1827-
1828-
beep();
1869+
var RE = /\.+/;
18291870

18301871
function beep( str ) {
1831-
if ( regex.test( str ) ) {
1872+
if ( RE.test( str ) ) {
18321873
// Do something...
18331874
}
18341875
}
1876+
1877+
beep();
18351878
```
18361879

18371880
##### Enforcement
@@ -1842,7 +1885,7 @@ Code review.
18421885

18431886
<!-- <rule> -->
18441887

1845-
### Rule: Documentation
1888+
### Rule: Document regular expressions
18461889

18471890
##### Reason
18481891

@@ -1857,7 +1900,7 @@ Regular expressions are error prone and difficult to understand without thorough
18571900
* Regular expression: `/^\/((?:\\\/|[^\/])+)\/([imgy]*)$/`
18581901
*
18591902
* `/^\/`
1860-
* - match a string that begins with a /
1903+
* - match a string that begins with a `/`
18611904
* `()`
18621905
* - capture
18631906
* `(?:)+`
@@ -2131,7 +2174,7 @@ Code review.
21312174

21322175
##### Reason
21332176

2134-
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)).
21352178

21362179
##### Bad Example
21372180

@@ -2428,6 +2471,7 @@ function transform( str ) {
24282471
##### Notes
24292472

24302473
* Be sure to include parameters, parameter types, return types (if any), errors (if any can be thrown), and examples.
2474+
* Use Markdown syntax for extended comments.
24312475

24322476
##### Enforcement
24332477

@@ -2551,7 +2595,7 @@ function factorial( x ) {
25512595

25522596
##### NOTE
25532597

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.
25552599
25562600
``` javascript
25572601
// NOTE: consider optimizing this for large arrays (len > 64K).
@@ -2763,13 +2807,15 @@ request({
27632807
##### Bad Example
27642808

27652809
``` javascript
2810+
// Do not...
27662811
var arr = [ 1, 2, 3 ];
27672812
var out = arr.map( x => x * x );
27682813
```
27692814

27702815
##### Good Example
27712816

27722817
``` javascript
2818+
// Do...
27732819
function square( x ) {
27742820
return x * x;
27752821
}
@@ -2808,12 +2854,14 @@ var VALUE = 3.14;
28082854
##### Bad Example
28092855

28102856
``` javascript
2857+
// Do not...
28112858
const value = 3.14;
28122859
```
28132860

28142861
##### Good Example
28152862

28162863
``` javascript
2864+
// Do...
28172865
const VALUE = 3.14;
28182866
```
28192867

@@ -3177,6 +3225,7 @@ function autocorr( vector ) {
31773225
*
31783226
* @example
31793227
* var arr = [ 1, 6, 5, 4, 7, 2, 3, 1 ];
3228+
* var v = autocorr( arr );
31803229
*/
31813230
function autocorr( vector ) {
31823231
// Calculate...
@@ -3401,7 +3450,7 @@ Code review.
34013450

34023451
##### Reason
34033452

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.
34053454

34063455
##### Notes
34073456

0 commit comments

Comments
 (0)