When it comes to open source, there are different ways you can contribute, all of which are valuable. Here's few guidelines that should help you as you prepare your contribution.
Before you start working on a contribution, create an issue describing what you want to build. It's possible someone else is already working on something similar, or perhaps there is a reason that feature isn't implemented. The maintainers will point you in the right direction.
The following steps will get you setup to contribute changes to this repo:
-
Fork this repo.
-
Clone your forked repo:
git clone git@github.com:{your_username}/zod.git -
Run
pnpm ito install dependencies. -
Start playing with the code! You can do some simple experimentation in
play.ts(seepnpm playbelow) or start implementing a feature right away.
For an officially supported isolated dev environment that automatically installs dependencies for you:
F1in VSCode and start typingDev Containers: Clone Repository in Named Container Volumeto run the command.- For the repo, paste
git@github.com:{your_username}/zod.gitif you're using ssh. - Click
Create a new volume...and name itzodand the folder name aszod.
Note: if you can't see Dev Containers in the F1 menu, follow this guide to install the needed extension.
In the OSS version of VSCode the extension may be not available.
pnpm build
- deletes
liband re-compilessrctolib
pnpm test
- runs all Vitest tests and generates coverage badge
pnpm test:watch
- runs all Vitest tests and
pnpm test <file>
- runs all test files that match
<file>
pnpm test --filter <ws> <file>
- runs all test files in
<ws>that match<file>(e.g."enum"will match"enum.test.ts")
pnpm dev:play
- executes
play.ts, watches for changes. useful for experimentation
Zod uses Vitest for testing. After implementing your contribution, write tests for it. Just create a new file in the tests directory of any workspace, or add additional tests to an existing file if appropriate.
Zod uses git hooks to execute tests before
git push. Before submitting your PR, runpnpm testto make sure there are no (unintended) breaking changes.
The Zod documentation lives in the README.md. Be sure to document any API changes you implement.
By contributing your code to the zod GitHub repository, you agree to license your contribution under the MIT license.