Examples more consistent with the guidline

comparison operator <= shows better the confusion when using arrow function, than just operator <
This commit is contained in:
ernestodebesto
2018-09-14 17:20:22 +02:00
committed by Jordan Harband
parent 6ece1f58e9
commit 69e34378c6

View File

@@ -1052,18 +1052,18 @@ Other Style Guides
```javascript
// bad
const itemHeight = item => item.height > 256 ? item.largeSize : item.smallSize;
const itemHeight = item => item.height <= 256 ? item.largeSize : item.smallSize;
// bad
const itemHeight = (item) => item.height > 256 ? item.largeSize : item.smallSize;
const itemHeight = (item) => item.height >= 256 ? item.largeSize : item.smallSize;
// good
const itemHeight = item => (item.height > 256 ? item.largeSize : item.smallSize);
const itemHeight = item => (item.height <= 256 ? item.largeSize : item.smallSize);
// good
const itemHeight = (item) => {
const { height, largeSize, smallSize } = item;
return height > 256 ? largeSize : smallSize;
return height <= 256 ? largeSize : smallSize;
};
```