Skip to content

rework config parsing, rewrite config tests#2015

Merged
beeequeue merged 31 commits into
nextfrom
valibot
May 25, 2026
Merged

rework config parsing, rewrite config tests#2015
beeequeue merged 31 commits into
nextfrom
valibot

Conversation

@beeequeue
Copy link
Copy Markdown
Contributor

@beeequeue beeequeue commented May 15, 2026

this PR reworks the config package to use Valibot for config shape validation, and then a rules engine(-ish) for validating that the config is correct.


this PR does NOT remove the remaining console.logs from various packages, as i wanted to keep this PR slightly more focused

@beeequeue beeequeue requested review from Andarist and bluwy May 15, 2026 12:55
Comment thread packages/config/scripts/generate-schema.ts Outdated
@socket-security
Copy link
Copy Markdown

socket-security Bot commented May 15, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedvalibot@​1.4.0981009987100
Added@​valibot/​to-json-schema@​1.7.010010010087100

View full report

Comment thread packages/config/src/config.ts
Comment thread packages/config/src/config.ts
Comment thread packages/config/src/rules.ts Outdated
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 16, 2026

🦋 Changeset detected

Latest commit: 26f5e45

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@changesets/config Major
@changesets/errors Major
@changesets/apply-release-plan Patch
@changesets/assemble-release-plan Patch
@changesets/cli Patch
@changesets/get-release-plan Patch
@changesets/git Patch
@changesets/pre Patch
@changesets/read Patch
@changesets/release-utils Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@beeequeue beeequeue mentioned this pull request May 16, 2026
26 tasks
@beeequeue beeequeue added this to the v3 milestone May 16, 2026
@beeequeue beeequeue force-pushed the valibot branch 2 times, most recently from 9f5718b to be4d2b4 Compare May 17, 2026 09:58
Copy link
Copy Markdown
Contributor Author

@beeequeue beeequeue May 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i need to test this against some complex configs from users

Comment thread packages/config/src/parse.ts Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

❌ Patch coverage is 88.33333% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.62%. Comparing base (fa6113f) to head (26f5e45).
⚠️ Report is 2 commits behind head on next.

Files with missing lines Patch % Lines
packages/config/src/rules.ts 90.24% 7 Missing and 1 partial ⚠️
packages/cli/src/utils/read-config.ts 64.28% 5 Missing ⚠️
packages/config/scripts/generate-json-schema.ts 71.42% 4 Missing ⚠️
packages/errors/src/index.ts 0.00% 2 Missing ⚠️
packages/config/src/config.ts 96.15% 1 Missing ⚠️
packages/config/src/utils.ts 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2015      +/-   ##
==========================================
- Coverage   81.27%   80.62%   -0.66%     
==========================================
  Files          55       61       +6     
  Lines        2377     2317      -60     
  Branches      718      638      -80     
==========================================
- Hits         1932     1868      -64     
- Misses        394      397       +3     
- Partials       51       52       +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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@beeequeue beeequeue marked this pull request as ready for review May 18, 2026 10:23
Comment thread packages/config/src/parse.ts Outdated
Comment thread packages/config/src/index.ts Outdated
Comment thread pnpm-workspace.yaml Outdated
Comment thread tsdown.config.ts
Comment thread .changeset/dumb-frogs-jump.md Outdated
Comment thread packages/get-release-plan/src/index.ts
Comment thread packages/types/src/index.ts
Comment thread packages/config/package.json
Comment thread packages/config/package.json Outdated
Comment thread packages/config/package.json Outdated
Comment thread packages/config/src/utils.ts Outdated
Comment thread packages/config/src/utils.ts
Comment thread packages/errors/src/index.ts
Comment thread packages/config/src/parse.test.ts Outdated
Comment thread packages/config/src/parse.test.ts Outdated
Comment thread packages/config/src/parse.test.ts
Comment thread packages/cli/src/utils/read-config.ts Outdated
}

if (errors.length !== 0) {
throw new ExitError(1, { cause: new Error(messages.join("\n")) });
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought this would print the errors twice but we'll ignore this cause here:

if (err instanceof ExitError) {
outro(c.red(`🦋 Exited with code ${err.code}`));
process.exit(err.code);
}

Attaching the .cause is nice - but perhaps this could actually throw that removed ValidationError? It would give it more context.

And I'm nitpicky here... but this message should just use:

Suggested change
throw new ExitError(1, { cause: new Error(messages.join("\n")) });
throw new ExitError(1, { cause: new Error(errors.join("\n")) });
  1. coloring shouldn't affect this
  2. warnings are not the cause of the error and they are part of the messages now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would say that ValidationError could be useful IF we expected anyone to run the CLI programmatically, which we don't.
since the CLI can only exit and print errors we should use ExitError.


the .cause shows up in vitest (iirc) so it's helpful for bubbling up the error without surfacing it in the CLI.


👍

Comment thread packages/cli/src/utils/read-config.ts Outdated
Comment on lines +23 to +26
const logFn = errors.length === 0 ? log.error : log.warn;
if (messages.length !== 0) {
logFn(`- ${messages.join("\n- ")}`);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like both diagnostic "levels" (warn/error) should just use different log levels and not be put into the same category here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a detail for how the output will look, we can polish it when we polish the rest of the CLI visuals

Comment thread packages/cli/src/commands/status/index.ts
Comment thread packages/config/src/parse.ts Outdated
@Andarist Andarist requested a review from bluwy May 23, 2026 22:33
Copy link
Copy Markdown
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for cleaning this up. I really appreciate it! This looks good to me now.

@beeequeue beeequeue added this pull request to the merge queue May 25, 2026
Merged via the queue into next with commit 6a05002 May 25, 2026
12 checks passed
@beeequeue beeequeue deleted the valibot branch May 25, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg.pr.new Publish PR via pkg.pr.new

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants