Skip to content

Commit 3aabe2c

Browse files
author
Tomek Wiszniewski
committed
Upgrade half of 8.2 to another rule
1 parent 5b8b56e commit 3aabe2c

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,6 @@
602602
603603
- [8.2](#8.2) <a name='8.2'></a> If the function body consists of a single expression, feel free to omit the braces and use the implicit return. Otherwise use a `return` statement.
604604
605-
In case the expression spans over multiple lines, wrap it in parentheses for better readability.
606-
607605
> Why? Syntactic sugar. It reads well when multiple functions are chained together.
608606
609607
> Why not? If you plan on returning an object.
@@ -612,12 +610,6 @@
612610
// good
613611
[1, 2, 3].map(number => `A string containing the ${number}.`);
614612

615-
// good
616-
[1, 2, 3].map(number => (
617-
`As time went by, the string containing the ${number} became much ` +
618-
'longer. So we needed to break it over multiple lines.'
619-
));
620-
621613
// bad
622614
[1, 2, 3].map(number => {
623615
let nextNumber = number + 1;
@@ -631,7 +623,26 @@
631623
});
632624
```
633625
634-
- [8.3](#8.3) <a name='8.3'></a> If your function only takes a single argument, feel free to omit the parentheses.
626+
- [8.3](#8.3) <a name='8.3'></a> In case the expression spans over multiple lines, wrap it in parentheses for better readability.
627+
628+
> Why? It shows clearly where the function starts and ends.
629+
630+
```js
631+
// bad
632+
[1, 2, 3].map(number => 'As time went by, the string containing the ' +
633+
`${number} became much longer. So we needed to break it over multiple ` +
634+
'lines.'
635+
);
636+
637+
// good
638+
[1, 2, 3].map(number => (
639+
`As time went by, the string containing the ${number} became much ` +
640+
'longer. So we needed to break it over multiple lines.'
641+
));
642+
```
643+
644+
645+
- [8.4](#8.4) <a name='8.4'></a> If your function only takes a single argument, feel free to omit the parentheses.
635646
636647
> Why? Less visual clutter.
637648

0 commit comments

Comments
 (0)