Skip to content

Convert env config from JSON to YAML so users can comment out lines - #224

Merged
charneykaye merged 5 commits into
mainfrom
vibrator/issue-222-env-yaml-not-env-json
Jun 30, 2026
Merged

Convert env config from JSON to YAML so users can comment out lines#224
charneykaye merged 5 commits into
mainfrom
vibrator/issue-222-env-yaml-not-env-json

Conversation

@charneykaye

@charneykaye charneykaye commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Replaces the JSON-based configuration with YAML to enable native comment support, resolving #222. JSON cannot contain comments, which forced workarounds like _comment fields. YAML's native comment syntax makes the configuration cleaner and more maintainable.

Changes

  • env.example.jsonenv.example.yaml: Converted to YAML format with native # comments replacing the old _comment/_key hack fields. Comments now annotate settings directly without cluttering the configuration structure.
  • .gitignore: Updated to ignore env.yaml instead of env.json.
  • src/env-config.ts:
    • Added js-yaml import to parse YAML files
    • loadEnvConfig() now parses with loadYaml() instead of JSON.parse()
    • Default config path is env.yaml
    • Updated error messages to reference env.yaml and env.example.yaml
  • test/env-config.test.ts:
    • Renamed writeEnvJson()writeEnvYaml()
    • Tests now write fixtures using js-yaml's dump() function
    • Added a new test verifying YAML comments are correctly ignored when loading
    • Updated the invalid-syntax test to use malformed YAML instead of JSON
  • package.json / package-lock.json:
    • Added js-yaml (v5.2.0) as a runtime dependency
    • Removed @types/js-yaml (it was redundant — js-yaml v5 ships with bundled TypeScript declarations)

Testing

All 34 unit tests pass, including a new test verifying that YAML comments are properly ignored during config loading.

Closes #222

Switch the environment configuration file from env.json to env.yaml so
users can comment out individual lines. Changes:

- Replace env.example.json with env.example.yaml using real YAML comments
  instead of _comment hack fields
- .gitignore now ignores env.yaml
- src/env-config.ts: use js-yaml load() instead of JSON.parse, default
  path is now env.yaml, error messages updated throughout
- test/env-config.test.ts: writeEnvJson -> writeEnvYaml using js-yaml dump()
- Add js-yaml dependency and @types/js-yaml dev dependency

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@charneykaye

Copy link
Copy Markdown
Contributor Author

Reviewed code, no issues found.

charneykaye and others added 2 commits June 30, 2026 13:24
The entire motivation for this PR is comment support; without this test,
the feature has no regression coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@charneykaye

Copy link
Copy Markdown
Contributor Author

Reviewed code and pushed fixes.

@charneykaye

Copy link
Copy Markdown
Contributor Author

Reviewed code, no issues found.

js-yaml v5 ships its own bundled TypeScript declarations (dist/js-yaml.d.ts
via the package exports field). The @types/js-yaml package is the DefinitelyTyped
shim for the old v4 API and is entirely unused when moduleResolution is nodenext,
which resolves types from the package's own exports.types field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@charneykaye

Copy link
Copy Markdown
Contributor Author

Reviewed code and pushed fixes.

@charneykaye

Copy link
Copy Markdown
Contributor Author

Reviewed code, no issues found.

1 similar comment
@charneykaye

Copy link
Copy Markdown
Contributor Author

Reviewed code, no issues found.

@charneykaye
charneykaye marked this pull request as ready for review June 30, 2026 20:43
@charneykaye
charneykaye merged commit 89ba162 into main Jun 30, 2026
1 check passed
@charneykaye
charneykaye deleted the vibrator/issue-222-env-yaml-not-env-json branch June 30, 2026 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

env.yaml (not env.json)

1 participant