@@ -98,19 +98,19 @@ This project contains an [`.editorconfig`][editorconfig] file to be used in conj
9898
9999Including ` 1 ` space before a leading brace improves readability.
100100
101- ##### Examples
102-
103- __ Do not__
101+ ##### Bad Example
104102
105103``` javascript
104+ // Do not...
106105function query (){
107106 // Do something...
108107}
109108```
110109
111- __ Do __
110+ ##### Good Example
112111
113112``` javascript
113+ // Do...
114114function query () {
115115 // Do something...
116116}
@@ -130,19 +130,19 @@ TODO: ESLint rule
130130
131131Including ` 1 ` space before and after arguments improves readability.
132132
133- ##### Examples
134-
135- __ Do not__
133+ ##### Bad Example
136134
137135``` javascript
136+ // Do not...
138137function test (arg1 ,arg2 ,arg3 ) {
139138 // Do something...
140139}
141140```
142141
143- __ Do __
142+ ##### Good Example
144143
145144``` javascript
145+ // Do...
146146function test ( arg1 , arg2 , arg3 ) {
147147 // Do something...
148148}
@@ -162,17 +162,17 @@ TODO: ESLint rule
162162Including ` 1 ` space before and after ` array ` indices improves readability.
163163
164164
165- ##### Examples
166-
167- __ Do not__
165+ ##### Bad Example
168166
169167``` javascript
168+ // Do not...
170169var foo = bar[10 ];
171170```
172171
173- __ Do __
172+ ##### Good Example
174173
175174``` javascript
175+ // Do...
176176var foo = bar[ 10 ];
177177```
178178
@@ -199,17 +199,17 @@ TODO: ESLint rule
199199
200200Including ` 1` space before and after operators improves readability.
201201
202- ##### Examples
203-
204- __Do not__
202+ ##### Bad Example
205203
206204` ` ` javascript
205+ // Do not...
207206var a=1+1;
208207` ` `
209208
210- __Do__
209+ ##### Good Example
211210
212211` ` ` javascript
212+ // Do...
213213var a = 1 + 1;
214214` ` `
215215
@@ -239,18 +239,18 @@ TODO: ESLint rule
239239
240240Immediate juxtaposition makes evident what is being affected.
241241
242- ##### Examples
243-
244- __Do not__
242+ ##### Bad Example
245243
246244` ` ` javascript
245+ // Do not...
247246x = ++ y;
248247z = z ++;
249248` ` `
250249
251- __Do__
250+ ##### Good Example
252251
253252` ` ` javascript
253+ // Do...
254254x = ++y;
255255z = z++;
256256` ` `
@@ -269,11 +269,11 @@ TODO: ESLint rule
269269
270270Including ` 1` space after comment marks improves readability.
271271
272- ##### Examples
273-
274- __Do not__
272+ ##### Bad Example
275273
276274` ` ` javascript
275+ // Do not...
276+
277277//This is a single-line comment.
278278
279279/**
@@ -282,9 +282,11 @@ __Do not__
282282*/
283283` ` `
284284
285- __Do__
285+ ##### Good Example
286286
287287` ` ` javascript
288+ // Do...
289+
288290// This is a single-line comment.
289291
290292/**
@@ -307,21 +309,23 @@ TODO
307309
308310Some IDEs have a tendency to auto- indent based on the previous line, thus pushing all subsequent lines ` 1` character to the right.
309311
310- ##### Examples
311-
312- __Do not__
312+ ##### Bad Example
313313
314314` ` ` javascript
315+ // Do not...
316+
315317/**
316318 * This is a multi-line comment.
317319 * The comment continues and continues...
318320 * ...until it no longer does.
319321 */
320322` ` `
321323
322- __Do__
324+ ##### Good Example
323325
324326` ` ` javascript
327+ // Do...
328+
325329/**
326330* This is a multi-line comment.
327331* The comment continues and continues...
@@ -343,18 +347,17 @@ In general, hard to automatically enforce. Mostly enforced through code review.
343347
344348Indentation improves readability.
345349
346- ##### Examples
347-
348- __Do not__
350+ ##### Bad Example
349351
350352` ` ` javascript
353+ // Do not...
351354var svg = d3.select( '.main' ).append( 'svg:svg' ).attr( 'class', 'canvas' ).attr( 'data-id', Date.now() ).attr( 'width', 100 ).attr( 'height', 100 );
352355` ` `
353356
354- __Do__
357+ ##### Good Example
355358
356359` ` ` javascript
357- // Do:
360+ // Do...
358361var svg = d3.select( '.main' )
359362 .append( 'svg:svg' )
360363 .attr( 'class', 'canvas' )
@@ -377,11 +380,10 @@ Hard to automatically enforce. Mostly through code review.
377380
378381Newline is unnecessary.
379382
380- ##### Examples
381-
382- __Do not__
383+ ##### Bad Example
383384
384385` ` ` javascript
386+ // Do not...
385387if ( foo === bar ) {
386388 // Do something...
387389}
@@ -390,9 +392,10 @@ else {
390392}
391393` ` `
392394
393- __Do__
395+ ##### Good Example
394396
395397` ` ` javascript
398+ // Do...
396399if ( foo === bar ) {
397400 // Do something...
398401} else {
@@ -405,7 +408,7 @@ if ( foo === bar ) {
405408* Use discretion when faced with multiple conditions.
406409
407410 ` ` ` javascript
408- // Do:
411+ // Do...
409412 if ( foo === bar ) {
410413 // Do something...
411414 } else if ( foo === beep ) {
@@ -416,7 +419,7 @@ if ( foo === bar ) {
416419 // Do something different...
417420 }
418421
419- // Okay:
422+ // Okay...
420423 if ( foo === bar ) {
421424 // Do something...
422425 }
@@ -431,6 +434,29 @@ if ( foo === bar ) {
431434 }
432435 ` ` `
433436
437+ * Use discretion when documenting conditions.
438+
439+ ` ` ` javascript
440+ Okay...
441+
442+ // ` bar` can only equal ` foo` when...
443+ if ( foo === bar ) {
444+ // Do something...
445+ }
446+ // ` beep` can only equal ` foo` when...
447+ else if ( foo === beep ) {
448+ // Do something else...
449+ }
450+ // This pathway should rarely be taken...
451+ else if ( baz === bar ) {
452+ // Do something more...
453+ }
454+ // ` foo` equals ` bap`
455+ else {
456+ // Do something different...
457+ }
458+ ` ` `
459+
434460
435461##### Enforcement
436462
@@ -446,11 +472,10 @@ Code review.
446472
447473Indenting the ` case` keyword within ` switch` statements results in excessive indentation.
448474
449- ##### Examples
450-
451- __Do not__
475+ ##### Bad Example
452476
453477` ` ` javascript
478+ // Do not...
454479switch( foo ) {
455480 case 'bar':
456481 // Do something...
@@ -463,9 +488,10 @@ switch( foo ) {
463488}
464489` ` `
465490
466- __Do__
491+ ##### Good Example
467492
468493` ` ` javascript
494+ // Do...
469495switch( foo ) {
470496case 'bar':
471497 // Do something...
0 commit comments