Skip to content

Commit a103ed5

Browse files
authored
docs: improve layer checker description and examples (#59)
1 parent 2950830 commit a103ed5

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Currently, it ships the following checkers to help improve the boundaries betwee
66
- A `privacy` checker that ensures other packages are using your package's public API
77
- A `visibility` checker that allows packages to be private except to an explicit group of other packages.
88
- A `folder_privacy` checker that allows packages to their sibling packs and parent pack (to be used in an application that uses folder packs)
9-
- A `layer` (formerly `architecture`) checker that allows packages to specify their "layer" and requires that each layer only communicate with layers below it.
9+
- A `layer` (formerly `architecture`) checker that allows packages to specify their "layer" and ensures they cannot use packages from higher layers
1010

1111
## Installation
1212

@@ -195,23 +195,26 @@ packs/c VIOLATION
195195
```
196196
197197
## Layer Checker
198-
The layer checker can be used to enforce constraints on what can depend on what.
198+
The layer checker can be used to define layers and then enforce constraints on the dependencies that packages can have.
199+
Dependencies are only allowed to packages in or below the same layer.
199200
200201
To enforce layers for your package, first define the `layers` in `packwerk.yml`, for example:
202+
201203
```
202204
layers:
203-
- package
205+
- feature
206+
- core
204207
- utility
205208
```
206209
207210
Then, turn on the checker in your package:
208211
```yaml
209212
# components/merchandising/package.yml
210213
enforce_layers: true
211-
layer: utility
214+
layer: core
212215
```
213216

214-
Now this pack can only depend on other utility packages.
217+
Now this pack can only depend on other packages from the `core` or `utility` layers. It cannot depend on packages from the higher `feature` layer.
215218

216219
### Deprecated Architecture Checker
217220
The "Layer Checker" was formerly named "Architecture Checker". The associated keys were:

0 commit comments

Comments
 (0)