Thanks for your interest in contributing to ts-enverify. This guide explains how to set up the project, make changes safely, and open high-quality pull requests.
- Code of Conduct
- Project Goals
- Tech Stack
- Getting Started
- Project Structure
- Development Workflow
- Coding Guidelines
- Testing Guidelines
- Pull Request Process
- Commit Message Suggestions
- Release Notes
- Reporting Issues
- Security
Please be respectful and constructive in all interactions. Assume good intent, give actionable feedback, and keep discussion focused on improving the project.
ts-enverify is intentionally small and focused. Core goals:
- Validate environment variables at startup.
- Keep runtime behavior explicit and predictable.
- Provide strong TypeScript inference without extra boilerplate.
- Stay dependency-light and easy to audit.
When proposing a change, prefer solutions that preserve these goals.
- Language: TypeScript
- Test runner: Vitest
- Build tool: tsup
- Output: CJS + ESM + type declarations
- Node.js 18+ (recommended)
- npm
git clone https://github.com/aradhyacp/ts-enverify.git
cd ts-enverify
npm installnpm run build # build dist artifacts with tsup
npm run typecheck # run TypeScript checks without emitting files
npm test # run tests once
npm run test:watch # run tests in watch mode
npm run dev # tsup watch buildsrc/
index.ts # public exports
validator.ts # main validation logic
types.ts # schema and inference types
errors.ts # custom error formatting
tests/
validator.test.ts
Guideline:
- Keep runtime validation behavior in
src/validator.ts. - Keep type-level behavior in
src/types.ts. - Keep user-facing error text centralized in
src/errors.ts.
- Create a branch from
main. - Make focused changes (one concern per PR where possible).
- Add or update tests with your change.
- Run checks locally:
npm run typecheck
npm test
npm run build- Open a pull request with a clear summary and rationale.
- Follow existing code style and naming conventions.
- Keep functions small and readable.
- Avoid introducing dependencies unless clearly justified.
- Prefer explicit behavior over implicit coercion.
- Preserve public API stability (
enverifyimport and current schema style) unless a breaking change is intentional.
Type and API safety:
- Do not weaken type inference for convenience.
- When changing schema typing, validate both runtime and inferred TypeScript behavior.
- If behavior changes, update README examples where relevant.
Tests should be behavior-focused and easy to read.
For validator changes, include tests for:
- Valid input path
- Invalid input path (error expectations)
- Edge cases (missing values, defaults, enum mismatch, invalid booleans/numbers)
- Error aggregation behavior where applicable
Tips:
- Use custom
sourceinputs in tests instead of mutating global environment state. - Keep test names descriptive and outcome-oriented.
Please include the following in your PR description:
- What changed
- Why it changed
- Any backward compatibility concerns
- How it was tested
PR checklist:
- Tests added or updated
-
npm run typecheckpasses -
npm testpasses -
npm run buildpasses - Docs updated when behavior or API changed
Review expectations:
- Small, focused PRs are reviewed faster.
- Maintainers may request changes for API consistency, type safety, or long-term maintainability.
Conventional commits are encouraged (not required), for example:
feat: add enum default narrowing testfix: improve boolean parser error messagedocs: clarify custom source usagerefactor: simplify infer field utility
Publishing is currently handled through npm.
The project has a prepublishOnly script that runs build before publish.
If you are preparing a release:
- Ensure all checks pass.
- Bump the package version in
package.json. - Verify changelog/release notes are accurate.
- Publish with npm credentials configured.
Please open issues with enough detail to reproduce. A strong issue report includes:
- Node.js version
- Package version
- Minimal reproduction
- Expected behavior
- Actual behavior
- Error output (if any)
Use the repository issues page:
If you discover a security issue, avoid public disclosure in a normal issue. Contact the maintainer privately first so a fix can be prepared responsibly.
Thanks again for contributing.