Skip to content

Remove valibot dependency and implement manual validation#79

Merged
bartveneman merged 4 commits intomainfrom
claude/simplify-validation-ninFo
Mar 12, 2026
Merged

Remove valibot dependency and implement manual validation#79
bartveneman merged 4 commits intomainfrom
claude/simplify-validation-ninFo

Conversation

@bartveneman
Copy link
Member

Summary

Removed the valibot schema validation library and replaced it with manual validation logic. This simplifies the codebase by eliminating an external dependency while maintaining the same validation behavior.

Key Changes

  • Removed valibot dependency from package.json

  • Refactored argument parsing (src/cli/arguments.ts):

    • Replaced valibot schemas with simple TypeScript type definitions using as const arrays
    • Merged parse_arguments() and validate_arguments() into a single parse_arguments() function that handles both parsing and validation
    • Implemented manual validation logic for each CLI argument with clear error messages
    • Made min-file-coverage a required field (always returns a number, defaults to 0)
  • Refactored coverage parsing (src/cli/parse-coverage.ts):

    • Replaced valibot schema validation with a custom type guard function is_valid_coverage()
    • Implemented manual object shape validation with proper type narrowing
    • Maintains the same validation behavior with improved type safety
  • Updated CLI entry point (src/cli/cli.ts):

    • Simplified to call only parse_arguments() instead of chaining parse_arguments() then validate_arguments()
  • Updated tests (src/cli/arguments.test.ts):

    • Removed calls to validate_arguments() wrapper function
    • Updated test descriptions to be more descriptive (e.g., "missing --min-file-coverage defaults to 0")
    • Simplified test assertions by removing unnecessary expect.soft() calls

Implementation Details

  • Type safety is maintained through TypeScript's as const for enum-like values and custom type guards
  • Error messages are now collected and joined with newlines for better readability
  • The validation logic is more explicit and easier to understand compared to schema-based validation

https://claude.ai/code/session_018N1GFSHdC3AunmZM98wwG9

@codecov-commenter
Copy link

codecov-commenter commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.56%. Comparing base (4dd0694) to head (1efbd28).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
+ Coverage   96.52%   96.56%   +0.04%     
==========================================
  Files          14       14              
  Lines        1035     1020      -15     
  Branches      120      136      +16     
==========================================
- Hits          999      985      -14     
  Misses         34       34              
+ Partials        2        1       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codecov-commenter
Copy link

codecov-commenter commented Mar 12, 2026

Bundle Report

Changes will decrease total bundle size by 516 bytes (-1.95%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
cli.js-esm 13.8kB 2 bytes (0.01%) ⬆️
index.js-esm 12.13kB -518 bytes (-4.09%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: cli.js-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
cli.mjs 2 bytes 13.8kB 0.01%

Files in cli.mjs:

  • ./src/cli/arguments.ts → Total Size: 1.8kB

  • ./src/cli/cli.ts → Total Size: 746 bytes

  • ./src/lib/parse-coverage.ts → Total Size: 558 bytes

view changes for bundle: index.js-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js 36 bytes 10.77kB 0.34%
index.d.ts -554 bytes 1.36kB -28.96%

Files in index.js:

  • ./src/lib/parse-coverage.ts → Total Size: 558 bytes

claude added 2 commits March 12, 2026 14:04
…into one step

- Remove valibot dependency from lib and CLI
- Replace valibot schemas in parse-coverage.ts with plain type guard functions
- Collapse parse_arguments + validate_arguments into a single parse_arguments
  function in arguments.ts, eliminating the two-step CLI flow
- Update cli.ts to call parse_arguments directly
- Simplify arguments.test.ts: remove validate_arguments import and update all
  call sites; merge redundant "not.toThrowError + value" tests into single assertions

https://claude.ai/code/session_018N1GFSHdC3AunmZM98wwG9
@bartveneman bartveneman force-pushed the claude/simplify-validation-ninFo branch from 405bbf4 to aca5f95 Compare March 12, 2026 14:06
@bartveneman bartveneman marked this pull request as ready for review March 12, 2026 14:59
@bartveneman bartveneman merged commit b0ea708 into main Mar 12, 2026
7 checks passed
@bartveneman bartveneman deleted the claude/simplify-validation-ninFo branch March 12, 2026 14:59
@bartveneman
Copy link
Member Author

refs #63

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.

3 participants