docs(style-guide): make barrels a consider

closes #1482
This commit is contained in:
Foxandxss 2016-05-23 15:39:55 +02:00 committed by Ward Bell
parent 743540363d
commit 0a0f78f144
1 changed files with 12 additions and 4 deletions

View File

@ -1175,13 +1175,13 @@ a(href="#toc") Back to top
<a id="04-10"></a> <a id="04-10"></a>
#### Style 04-10 #### Style 04-10
.s-rule.do .s-rule.consider
:marked :marked
**Do** create a file that imports, aggregates, and re-exports items. We call this technique a **barrel**. **Consider** creating a file that imports, aggregates, and re-exports items. We call this technique a **barrel**.
.s-rule.do .s-rule.consider
:marked :marked
**Do** name this barrel file `index.ts`. **Consider** naming this barrel file `index.ts`.
.s-why .s-why
:marked :marked
@ -1190,6 +1190,14 @@ a(href="#toc") Back to top
.s-why .s-why
:marked :marked
**Why?** A barrel reduces the number of imports a file may need. **Why?** A barrel reduces the number of imports a file may need.
.s-why
:marked
**Why?** A barrel provides a consistent pattern to import everything exported in the barrel from a folder.
.s-why
:marked
**Why?** This is consistent with a pattern from Node, which imports the index.js|ts file from a folder.
.s-why.s-why-last .s-why.s-why-last
:marked :marked