6
6
3 . [ Basics] ( #basics )
7
7
4 . [ Readability] ( #readability )
8
8
5 . [ Side Effects] ( #side-effects )
9
- 6 . [ User Input ] ( #user-input )
9
+ 6 . [ Limits ] ( #limits )
10
10
7 . [ Security] ( #security )
11
11
8 . [ Performance] ( #performance )
12
12
9 . [ Testing] ( #testing )
@@ -318,11 +318,57 @@ assert(date1 === '1/6/2017');
318
318
> George Bernard Shaw
319
319
320
320
### Null cases should be handled
321
+ If you have a list component for example, all is well and good if you display a
322
+ nice beautiful table that shows all its data. Your users love it and you get a
323
+ promotion! But what happens when no data comes back? What do you show in the
324
+ null case? Your code should be resilient to every case that can occur. If
325
+ there's something bad that can happen in your code, eventually it will happen.
326
+
327
+ ``` javascript
328
+ class InventoryList {
329
+ constructor (data ) {
330
+ this .data = data;
331
+ }
332
+
333
+ render () {
334
+ return (
335
+ < table>
336
+ < tbody>
337
+ < tr>
338
+ < th>
339
+ ID
340
+ < / th>
341
+ < th>
342
+ Product
343
+ < / th>
344
+ < / tr>
345
+ // We should should something for the null case here if there's
346
+ // nothing in the data inventory
347
+ {Object .keys (this .data .inventory ).map (itemId => (
348
+ < tr key= {i}>
349
+ < td>
350
+ {itemId}
351
+ < / td>
352
+
353
+ < td>
354
+ {this .state .inventory [itemId].product }
355
+ < / td>
356
+ < / tr>
357
+ ))}
358
+ < / tbody>
359
+ < / table>
360
+ );
361
+ }
362
+ }
363
+ ```
321
364
322
365
### Singular cases should be handled
366
+ ``` javascript
367
+ ```
323
368
324
369
### Large cases should be handled
325
370
371
+
326
372
### Commit messages should be clear and accurately describe new code
327
373
We've all written commit messages like "Changed some crap", "damn it",
328
374
"ugg one more to fix this stupid bug". These are funny and satisfying, but not
@@ -332,7 +378,7 @@ commit. Write commit messages that describe the code accurately, and include
332
378
a ticket number from your issue tracking system if you have one. That will make
333
379
searching through your commit log much easier.
334
380
335
- ### The code should what it's supposed to
381
+ ### The code should do what it's supposed to do
336
382
This seems obvious, but most reviewers don't have the time or take the time to
337
383
manually test every user-facing change. It's important to make sure the business
338
384
logic of every change is as per design. It's easy to forget that when you're
0 commit comments