Repository navigation
fix: don't collect filtered reference warnings in sortByReference - #1763
Merged
jorenbroekema merged 1 commit intoOct 9, 2026
Merged
jorenbroekema merged 1 commit into
jorenbroekema merged 1 commit into
Conversation
sortByReference passed the unfiltered tokens to getReferences as `unfilteredTokens`, which records a "filtered out token references" warning for every reference that isn't in the filtered set. Because the sorter recurses into referenced tokens, this also recorded references of tokens that are never output, and outputReferencesFilter could not remove them, so the warning showed up even though no references were output. Resolve references against the unfiltered tokens directly instead; the formatters still report filtered references they actually output. Fixes #1379
🦋 Changeset detectedLatest commit: 23b268b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
✅ Deploy Preview for styledictionaryjs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
SahinurDEV
marked this pull request as draft
October 8, 2026 10:57
jorenbroekema
approved these changes
Oct 9, 2026
jorenbroekema
left a comment
Collaborator
There was a problem hiding this comment.
That's a pretty smart fix: sort on the filtered set, but grab the references from the unfiltered set, circumventing the warnings collection. After all, these warnings will be collected later anyways.
Thanks for the AI disclaimer, appreciate that.
jorenbroekema
marked this pull request as ready for review
October 9, 2026 10:36
Contributor
Author
|
Thanks a lot @jorenbroekema for the quick review and the kind words! Glad the fix fits well. Happy to help with more issues here. |
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.
Problem
When you combine a filter with
outputReferences: outputReferencesFilter, Style Dictionary can still print "filtered out token references were found", even though the output has no references and every value is resolved (#1379). This happens when the filtered-out tokens reference other tokens (multiple levels of references). With only one token, the warning goes away.Minimal repro:
The output is
--semantic-error: #ff0000; --semantic-notice: #0000ff;, but the build still logs the warning forbase.red/base.blue.Cause
When
outputReferencesis set, formats sort tokens withsortByReference(tokens, { unfilteredTokens }). The sorter calledgetReferences(value, tokens, { unfilteredTokens, warnImmediately: false }), and that call adds aFilteredOutputReferencesmessage for every reference missing from the filtered set. When two tokens reference other tokens but not each other, the sorter recurses into the referenced tokens (sorter(aRefs[0], bRefs[0])). Those tokens can be filtered out, so it also recorded their references (herebase.red,base.blue). Those tokens are never output, sooutputReferencesFilternever runs for them and can't remove the warnings.Fix
Sorting only needs to resolve references. It doesn't need to report them.
sortByReferencenow looks references up inunfilteredTokens ?? tokensdirectly, without theunfilteredTokensoption, so it no longer adds filter warnings. Filtered references that really end up in the output are still reported bycreatePropertyFormatter. WithoutunfilteredTokens, behavior is unchanged.One side effect: the verbose warning now lists references in output order. It used to list them in sort-comparison order (
neutral.0now comes beforeneutral.100), so I updated three snapshots for that. The set of references is the same.Tests
sortByReference.test.js: sorting withunfilteredTokensand multi-level references collects no filter warnings, and still sorts correctly through references that resolve to filtered-out tokens.__integration__/outputReferences.test.js: building the repro above withoutputReferencesFilterlogs no filtered-reference warning.npm run test:node: 998 passing, 4 pending.npm run lint(eslint, prettier, tsc) passes.AI disclosure: I used an AI coding assistant to investigate this issue and draft the fix and tests. I reproduced the bug and checked the change and test results locally.
Fixes #1379