Skip to content
This repository was archived by the owner on Nov 29, 2021. It is now read-only.

Commit 5797f54

Browse files
committed
[guide] Add array-bracket-newline (close airbnb#1338)
1 parent 321fb27 commit 5797f54

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,45 @@ Other Style Guides
417417
418418
**[⬆ back to top](#table-of-contents)**
419419
420+
<a name="arrays--bracket-newline"></a>
421+
- [4.6](#arrays--bracket-newline) Use line breaks after open and before close array brackets if an array has multiple lines
422+
423+
```javascript
424+
// bad
425+
const arr = [
426+
[0, 1], [2, 3], [4, 5],
427+
];
428+
429+
const objectInArray = [{
430+
id: 1,
431+
}, {
432+
id: 2,
433+
}];
434+
435+
const numberInArray = [
436+
1, 2,
437+
];
438+
439+
// good
440+
const arr = [[0, 1], [2, 3], [4, 5]];
441+
442+
const objectInArray = [
443+
{
444+
id: 1,
445+
},
446+
{
447+
id: 2,
448+
},
449+
];
450+
451+
const numberInArray = [
452+
1,
453+
2,
454+
];
455+
```
456+
457+
**[⬆ back to top](#table-of-contents)**
458+
420459
## Destructuring
421460
422461
<a name="destructuring--object"></a><a name="5.1"></a>

0 commit comments

Comments
 (0)