You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ Currently, it ships the following checkers to help improve the boundaries betwee
6
6
- A `privacy` checker that ensures other packages are using your package's public API
7
7
- A `visibility` checker that allows packages to be private except to an explicit group of other packages.
8
8
- 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
10
10
11
11
## Installation
12
12
@@ -195,23 +195,26 @@ packs/c VIOLATION
195
195
```
196
196
197
197
## 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.
199
200
200
201
To enforce layers for your package, first define the `layers` in `packwerk.yml`, for example:
202
+
201
203
```
202
204
layers:
203
-
- package
205
+
- feature
206
+
- core
204
207
- utility
205
208
```
206
209
207
210
Then, turn on the checker in your package:
208
211
```yaml
209
212
# components/merchandising/package.yml
210
213
enforce_layers: true
211
-
layer: utility
214
+
layer: core
212
215
```
213
216
214
-
Now this pack can only depend on other utilitypackages.
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.
215
218
216
219
### Deprecated Architecture Checker
217
220
The "Layer Checker" was formerly named "Architecture Checker". The associated keys were:
0 commit comments