-
Notifications
You must be signed in to change notification settings - Fork 49
[Project Solar / Phase 1 / Engineering Follow-ups] Improve validation for $modes
#3397
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: project-solar/phase-1-main-feature-branch
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances validation for design token $modes entries in the build script to catch configuration errors early. It adds two levels of validation: a warning for mismatched default mode values and an error that halts execution when expected mode keys are missing.
Key changes:
- Added chalk dependency for improved console output formatting
- Implemented soft validation warning when
$modes.defaultdiffers from$value - Converted TODO comment into hard validation that throws an error for missing mode keys
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/tokens/scripts/build.ts | Added validation logic for $modes with chalk-formatted console messages |
| packages/tokens/package.json | Added chalk dependency for colored console output |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
KristinLBradley
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good other than the duplicated warning messages I was seeing when I tested.
@KristinLBradley I have now pushed another commit, to improve the log messages. Now you can see that there are two warnings, because it's invoked twice, for two build paths (the CSS files generation and the JSON doc file generation)
|
6e3d58b to
2e4a003
Compare
50b57fa to
af84387
Compare
|
Can approve after failing check passes |
$modes$modes
cb62d03 to
59aacb2
Compare
af84387 to
2ecdfb2
Compare
2ecdfb2 to
a8010a3
Compare

📌 Summary
Small PR that adds some basic validation to the design tokens
buildscript, to make sure the$modesentry have the expected format and values.🛠️ Detailed description
In this PR I have:
chalkas devDependency (used to highlight some text in the console messages)replace-value-for-mode-${mode}preprocessing function:$modes.defaultvalue is different from the standard$value$modeskeys is missingNote: later we may decide to make also the first validation a blocker, for now we want to test how this "soft" check works for the developers adding tokens for the migration of the HDS components to Carbon
🔗 External links
Jira ticket: https://hashicorp.atlassian.net/browse/HDS-5668
👀 Component checklist
💬 Please consider using conventional comments when reviewing this PR.
📋 PCI review checklist
Examples of changes to controls include access controls, encryption, logging, etc.
Examples include changes to operating systems, ports, protocols, services, cryptography-related components, PII processing code, etc.