Repository navigation
feat(core): report unresolved token references at build - #343
Merged
Merged
Conversation
A reference to a missing token in a recipe or a utility value built silently and emitted a var() that is never declared, and a misspelled theme override or a duplicate variable lost a value without a word. validate(instance) walks the finished instance and returns every problem in one pass: unresolved-reference, undefined-theme-override and duplicate-variable, each with the path that made it and the closest token name within two edits. transpile() runs it once and returns the diagnostics beside files, or throws one error listing them all under the new strict option. variable() and the utility namespace fallback keep a record on the root of what the finished tree no longer holds. Nested at-rules keep hyphenated names, so @starting-style and @font-feature-values emit as written. The theme gains z-index.tooltip, which the tooltip recipe already used, and the xs chip indicator stops referencing the undefined font-size.4xs. The transpiler and barrel peer on the core release that ships validate(). The theme typecheck builds again without the duplicate wcagContrast declaration.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
A plain @token string in a selector or theme still throws when it's defined, so the docs and changeset now say which references validate() reports. The default z-index output blocks list the tooltip level, and a namespace fallback whose variable was defined later says so instead of claiming no variable exists.
alexgrozav
marked this pull request as ready for review
October 21, 2026 06:48
Merged
This was referenced Oct 21, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A token reference that resolves to nothing used to build without a word.
recipe({ base: { background: "@color.brnad" } })emittedvar(--color--brnad), a variable that is never declared, and a misspelled theme override or a secondvariable("color.brand", …)lost a value silently. The docs said the first case throws at compile time. It didn't.This adds
validate(instance)to@styleframe/core. It walks the finished instance once and returns every problem as a diagnostic (code,severity,message,path, optionalsuggestion):unresolved-reference: an@tokenin a recipe (base,variants,compoundVariants, modifier blocks), a utility value (including a namespace fallback) or acsstemplate literal, or aref()anywhere, that resolves to no variable in scope. A plain@tokenstring in a selector or theme declaration still throws when it's defined, as before. The path names where it was made, likerecipe "button" › compoundVariants[0] › hover:enabled › background, and the suggestion is the closest token within two edits (@color.brnad→color.brand).undefined-theme-override: a themevariable()whose name isn't defined at root.duplicate-variable: twovariable()calls with the same name and withoutdefault: true, with both values.transpile()runs it once, after the licence step, and returns the diagnostics asdiagnosticsbesidefiles, so existing builds keep emitting as before. Withstyleframe({ strict: true }), it throws one error that lists them all. Printing them in the CLI and the plugin comes in a follow-up.Also in this PR:
"@starting-style"emitted@starting -style {, and"@font-feature-values Font One"broke the same way.@styleframe/themegainsz-index.tooltip(700), which the tooltip recipe already referenced. Thexschip indicator, a dot with no text, used the undefined@font-size.4xsand now uses@font-size.3xs.@styleframe/transpilerandstyleframepeer on@styleframe/coreasworkspace:^, so they publish against the core release that shipsvalidate().mainbuilds again:useSelectRecipeContrast.test.tsredeclaredwcagContrast, whichtheme/src/shims.d.tsalready declares.strict.Related issue
None.
Type of change
Checklist
feat(theme): …)pnpm build:nodocs && pnpm lint && pnpm typecheck && pnpm testand everything passespnpm changeset) for changes to publishable packages, or this change only touches docs/storybook/app/playground/testsdist/,.styleframe/)mainand stays focused in scopeNotes / screenshots
A test builds an instance with
useDesignTokensPreset,useModifiersPreset,useUtilitiesPresetand everyuse*Recipecomposable the theme exports, and assertsvalidate(s)returns[]. That test is what found the tooltip and chip references.A
ref()with a fallback isn't reported, since it resolves to its fallback. Only references inside the fallback are checked.