@@ -91,6 +91,8 @@ Other Style Guides
9191
9292 > Why? This ensures that you can' t reassign your references, which can lead to bugs and difficult to comprehend code.
9393
94+ eslint rules: [`prefer-const`](http://eslint.org/docs/rules/prefer-const.html), [`no-const-assign`](http://eslint.org/docs/rules/no-const-assign.html).
95+
9496 ```javascript
9597 // bad
9698 var a = 1;
@@ -105,6 +107,8 @@ Other Style Guides
105107
106108 > Why? `let` is block-scoped rather than function-scoped like `var`.
107109
110+ eslint rules: [`no-var`](http://eslint.org/docs/rules/no-var.html).
111+
108112 ```javascript
109113 // bad
110114 var count = 1;
@@ -137,6 +141,8 @@ Other Style Guides
137141
138142 - [3.1](#3.1) <a name=' 3.1 ' ></a> Use the literal syntax for object creation.
139143
144+ eslint rules: [`no-new-object`](http://eslint.org/docs/rules/no-new-object.html).
145+
140146 ```javascript
141147 // bad
142148 const item = new Object();
@@ -209,6 +215,8 @@ Other Style Guides
209215 < a name= " es6-object-shorthand" >< / a>
210216 - [3.5 ](#3.5 ) < a name= ' 3.5' >< / a> Use object method shorthand.
211217
218+ eslint rules: [` object-shorthand` ](http: // eslint.org/docs/rules/object-shorthand.html).
219+
212220 ` ` ` javascript
213221 // bad
214222 const atom = {
@@ -234,6 +242,8 @@ Other Style Guides
234242
235243 > Why? It is shorter to write and descriptive.
236244
245+ eslint rules: [` object-shorthand` ](http: // eslint.org/docs/rules/object-shorthand.html).
246+
237247 ` ` ` javascript
238248 const lukeSkywalker = 'Luke Skywalker';
239249
@@ -283,6 +293,8 @@ Other Style Guides
283293
284294 - [4.1](#4.1) <a name=' 4.1 ' ></a> Use the literal syntax for array creation.
285295
296+ eslint rules: [`no-array-constructor`](http://eslint.org/docs/rules/no-array-constructor.html).
297+
286298 ```javascript
287299 // bad
288300 const items = new Array();
@@ -399,6 +411,8 @@ Other Style Guides
399411
400412 - [6.1](#6.1) <a name=' 6.1 ' ></a> Use single quotes `' ' ` for strings.
401413
414+ eslint rules: [`quotes`](http://eslint.org/docs/rules/quotes.html).
415+
402416 ```javascript
403417 // bad
404418 const name = "Capt. Janeway";
@@ -431,6 +445,8 @@ Other Style Guides
431445
432446 > Why? Template strings give you a readable, concise syntax with proper newlines and string interpolation features.
433447
448+ eslint rules: [`prefer-template`](http://eslint.org/docs/rules/prefer-template.html).
449+
434450 ```javascript
435451 // bad
436452 function sayHi(name) {
@@ -601,7 +617,7 @@ Other Style Guides
601617- [7.11](#7.11) <a name="7.11"></a> Spacing in a function signature.
602618
603619 > Why? Consistency is good, and you shouldn’t have to add or remove a space when adding or removing a name.
604-
620+
605621 ` ` ` javascript
606622 // bad
607623 const f = function (){};
@@ -623,6 +639,8 @@ Other Style Guides
623639
624640 > Why not? If you have a fairly complicated function, you might move that logic out into its own function declaration.
625641
642+ eslint rules: [` prefer- arrow- callback` ](http://eslint.org/docs/rules/prefer-arrow-callback.html), [` arrow- spacing` ](http://eslint.org/docs/rules/arrow-spacing.html).
643+
626644 ` ` ` javascript
627645 // bad
628646 [1 , 2 , 3 ].map (function (x ) {
@@ -643,6 +661,8 @@ Other Style Guides
643661
644662 > Why not? If you plan on returning an object.
645663
664+ eslint rules: [` arrow- parens` ](http://eslint.org/docs/rules/arrow-parens.html), [` arrow- body- style` ](http://eslint.org/docs/rules/arrow-body-style.html).
665+
646666 ` ` ` javascript
647667 // good
648668 [1 , 2 , 3 ].map (number => ` A string containing the ${ number} .` );
@@ -683,6 +703,8 @@ Other Style Guides
683703
684704 > Why? Less visual clutter.
685705
706+ eslint rules: [` arrow- parens` ](http://eslint.org/docs/rules/arrow-parens.html).
707+
686708 ` ` ` js
687709 // good
688710 [1 , 2 , 3 ].map (x => x * x);
@@ -861,6 +883,8 @@ Other Style Guides
861883
862884 > Why? This enforces our immutable rule. Dealing with pure functions that return values is easier to reason about than side-effects.
863885
886+ eslint rules: [` no- iterator` ](http://eslint.org/docs/rules/no-iterator.html).
887+
864888 ` ` ` javascript
865889 const numbers = [1 , 2 , 3 , 4 , 5 ];
866890
@@ -893,6 +917,8 @@ Other Style Guides
893917
894918 - [12.1](#12.1) <a name='12.1'></a> Use dot notation when accessing properties.
895919
920+ eslint rules: [` dot- notation` ](http://eslint.org/docs/rules/dot-notation.html).
921+
896922 ` ` ` javascript
897923 const luke = {
898924 jedi: true ,
@@ -940,6 +966,8 @@ Other Style Guides
940966
941967 > Why? It' s easier to add new variable declarations this way, and you never have to worry about swapping out a `;` for a `,` or introducing punctuation-only diffs.
942968
969+ eslint rules: [`one-var`](http://eslint.org/docs/rules/one-var.html).
970+
943971 ```javascript
944972 // bad
945973 const items = getItems(),
@@ -1134,6 +1162,8 @@ Other Style Guides
11341162 - [15.1](#15.1) <a name='15.1'></a> Use ` === ` and ` !== ` over ` == ` and ` != ` .
11351163 - [15.2](#15.2) <a name='15.2'></a> Conditional statements such as the ` if ` statement evaluate their expression using coercion with the ` ToBoolean` abstract method and always follow these simple rules:
11361164
1165+ eslint rules: [` eqeqeq` ](http://eslint.org/docs/rules/eqeqeq.html).
1166+
11371167 + **Objects** evaluate to **true**
11381168 + **Undefined** evaluates to **false**
11391169 + **Null** evaluates to **false**
@@ -1206,6 +1236,8 @@ Other Style Guides
12061236 - [16.2](#16.2) <a name='16.2'></a> If you're using multi-line blocks with ` if ` and ` else ` , put ` else ` on the same line as your
12071237 ` if ` block's closing brace.
12081238
1239+ eslint rules: [` brace- style` ](http://eslint.org/docs/rules/brace-style.html).
1240+
12091241 ` ` ` javascript
12101242 // bad
12111243 if (test) {
@@ -1336,6 +1368,8 @@ Other Style Guides
13361368
13371369 - [18.1 ](#18.1 ) < a name= ' 18.1' >< / a> Use soft tabs set to 2 spaces.
13381370
1371+ eslint rules: [` indent` ](http: // eslint.org/docs/rules/indent.html).
1372+
13391373 ` ` ` javascript
13401374 // bad
13411375 function () {
@@ -1355,6 +1389,8 @@ Other Style Guides
13551389
13561390 - [18.2 ](#18.2 ) < a name= ' 18.2' >< / a> Place 1 space before the leading brace.
13571391
1392+ eslint rules: [` space-before-blocks` ](http: // eslint.org/docs/rules/space-before-blocks.html).
1393+
13581394 ` ` ` javascript
13591395 // bad
13601396 function test(){
@@ -1381,6 +1417,8 @@ Other Style Guides
13811417
13821418 - [18.3 ](#18.3 ) < a name= ' 18.3' >< / a> Place 1 space before the opening parenthesis in control statements (` if` , ` while` etc.). Place no space before the argument list in function calls and declarations.
13831419
1420+ eslint rules: [`space-after-keywords`](http : // eslint.org/docs/rules/space-after-keywords.html), [`space-before-keywords`](http://eslint.org/docs/rules/space-before-keywords.html).
1421+
13841422 ` ` ` javascript
13851423 // bad
13861424 if(isJedi) {
@@ -1405,6 +1443,8 @@ Other Style Guides
14051443
14061444 - [18.4 ](#18.4 ) < a name = ' 18.4' >< / a > Set off operators with spaces .
14071445
1446+ eslint rules : [` space-infix-ops` ](http: // eslint.org/docs/rules/space-infix-ops.html).
1447+
14081448 ` ` ` javascript
14091449 // bad
14101450 const x=y+5;
@@ -1536,6 +1576,8 @@ Other Style Guides
15361576
15371577 - [18.8 ](#18.8 ) < a name= ' 18.8' >< / a> Do not pad your blocks with blank lines.
15381578
1579+ eslint rules: [` padded-blocks` ](http: // eslint.org/docs/rules/padded-blocks.html).
1580+
15391581 ` ` ` javascript
15401582 // bad
15411583 function bar() {
@@ -1568,6 +1610,8 @@ Other Style Guides
15681610
15691611 - [18.9 ](#18.9 ) < a name= ' 18.9' >< / a> Do not add spaces inside parentheses.
15701612
1613+ eslint rules: [` space-in-parens` ](http: // eslint.org/docs/rules/space-in-parens.html).
1614+
15711615 ` ` ` javascript
15721616 // bad
15731617 function bar( foo ) {
@@ -1592,6 +1636,8 @@ Other Style Guides
15921636
15931637 - [18.10 ](#18.10 ) < a name= ' 18.10' >< / a> Do not add spaces inside brackets.
15941638
1639+ eslint rules: [` array-bracket-spacing` ](http: // eslint.org/docs/rules/array-bracket-spacing.html).
1640+
15951641 ` ` ` javascript
15961642 // bad
15971643 const foo = [ 1, 2, 3 ];
@@ -1604,6 +1650,8 @@ Other Style Guides
16041650
16051651 - [18.11 ](#18.11 ) < a name= ' 18.11' >< / a> Add spaces inside curly braces.
16061652
1653+ eslint rules: [` object-curly-spacing` ](http: // eslint.org/docs/rules/object-curly-spacing.html).
1654+
16071655 ` ` ` javascript
16081656 // bad
16091657 const foo = {clark: 'kent'};
@@ -1618,6 +1666,8 @@ Other Style Guides
16181666
16191667 - [19.1 ](#19.1 ) < a name= ' 19.1' >< / a> Leading commas: ** Nope.**
16201668
1669+ eslint rules: [` comma-style` ](http: // eslint.org/docs/rules/comma-style.html).
1670+
16211671 ` ` ` javascript
16221672 // bad
16231673 const story = [
@@ -1652,6 +1702,8 @@ Other Style Guides
16521702
16531703 - [19.2 ](#19.2 ) < a name= ' 19.2' >< / a> Additional trailing comma: ** Yup.**
16541704
1705+ eslint rules: [` no-comma-dangle` ](http: // eslint.org/docs/rules/no-comma-dangle.html).
1706+
16551707 > Why? This leads to cleaner git diffs . Also , transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don' t have to worry about the [trailing comma problem](es5/README.md#commas) in legacy browsers.
16561708
16571709 ```javascript
@@ -1700,6 +1752,8 @@ Other Style Guides
17001752
17011753 - [20.1](#20.1) <a name=' 20.1 ' ></a> **Yup.**
17021754
1755+ eslint rules: [`semi`](http://eslint.org/docs/rules/semi.html).
1756+
17031757 ```javascript
17041758 // bad
17051759 (function () {
@@ -1820,6 +1874,8 @@ Other Style Guides
18201874
18211875 - [22.2 ](#22.2 ) < a name= ' 22.2' >< / a> Use camelCase when naming objects, functions, and instances.
18221876
1877+ eslint rules: [` camelcase` ](http: // eslint.org/docs/rules/camelcase.html).
1878+
18231879 ` ` ` javascript
18241880 // bad
18251881 const OBJEcttsssss = {};
@@ -1857,6 +1913,8 @@ Other Style Guides
18571913
18581914 - [22.4 ](#22.4 ) < a name= ' 22.4' >< / a> Use a leading underscore ` _` when naming private properties.
18591915
1916+ eslint rules: [` no-underscore-dangle` ](http: // eslint.org/docs/rules/no-underscore-dangle.html).
1917+
18601918 ` ` ` javascript
18611919 // bad
18621920 this.__firstName__ = 'Panda';
@@ -1894,6 +1952,7 @@ Other Style Guides
18941952 ```
18951953
18961954 - [22.6](#22.6) <a name=' 22.6 ' ></a> If your file exports a single class, your filename should be exactly the name of the class.
1955+
18971956 ```javascript
18981957 // file contents
18991958 class CheckBox {
0 commit comments