Skip to content

Commit

Permalink
Add enforce_privacy: strict to README.md (#46)
Browse files Browse the repository at this point in the history
* Add `enforce_privacy: strict` to README.md

* Update README.md

Co-authored-by: Teal Stannard <[email protected]>

---------

Co-authored-by: Teal Stannard <[email protected]>
  • Loading branch information
iMacTia and tstannard authored Feb 2, 2024
1 parent 7f28586 commit 4acb4d6
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@ The privacy checker extension was originally extracted from [packwerk](https://g
A package's privacy boundary is violated when there is a reference to the package's private constants from a source outside the package.
To enforce privacy for your package, set `enforce_privacy` to `true` on your pack:
To enforce privacy for your package, set `enforce_privacy` to `true` or `strict` on your pack:

```yaml
# components/merchandising/package.yml
enforce_privacy: true
```

Setting `enforce_privacy` to true will make all references to private constants in your package a violation.
Setting `enforce_privacy` to `true` will make all references to private constants in your package a violation.

Setting `enforce_privacy` to `strict` will forbid all references to private constants in your package. **This includes violations that have been added to other packages' `package_todo.yml` files.**

Note: You will need to remove all existing privacy violations before setting `enforce_privacy` to `strict`.

### Using public folders
You may enforce privacy either way mentioned above and still expose a public API for your package by placing constants in the public folder, which by default is `app/public`. The constants in the public folder will be made available for use by the rest of the application.
Expand Down Expand Up @@ -84,7 +88,7 @@ module Foo
end
end
```
Now `Foo::Update` is considered public even though the `foo` package might be set to `enforce_private: (true || :strict)`.
Now `Foo::Update` is considered public even though the `foo` package might be set to `enforce_privacy: (true || strict)`.

It's important to note that when combining `public_api: true` with the declaration of `private_constants`,
`packwerk validate` will raise an exception if both are used for the same constant. This must be resolved by removing
Expand Down

0 comments on commit 4acb4d6

Please sign in to comment.