Skip to content

Fix extended theme token-set matching with slash-space normalization#3840

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/figma-plugin-issue-review-02ea
Draft

Fix extended theme token-set matching with slash-space normalization#3840
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/figma-plugin-issue-review-02ea

Conversation

@cursor
Copy link
Copy Markdown

@cursor cursor Bot commented Apr 13, 2026

Why does this PR exist?

Closes #3826

Extended collection/theme token-set names were being compared as raw strings. If users entered names with spaces around / (for example Collection / Child), export/import comparison logic treated them as different sets from Collection/Child, which broke matching and caused incorrect rename behavior.

What does this pull request do?

  • Adds normalizeTokenSetName() to canonicalize token-set names by trimming whitespace around / path separators.
  • Adds normalizeTokenSetStatusMap() to dedupe normalized token-set keys while preserving strongest status (enabled > source > disabled).
  • Applies normalization in:
  • getTokenSetsOrder() token-set matching and active-set handling.
  • getOverallConfig() and getEnabledTokenSets() in token helper logic.
  • generateTokensToCreate() when filtering enabled token sets.
  • pullVariables() rename detection so whitespace-only differences are not treated as renames.
  • Adds regression tests for:
  • Slash-space normalization utility behavior.
  • Ordering/matching with normalized token-set keys.
  • Token generation with core / colors vs core/colors.
  • Pull-variable rename flow not flagging whitespace-only token-set changes.

Testing this change

Run targeted tests:

yarn test src/plugin/generateTokensToCreate.test.ts src/utils/getTokenSetsOrder.test.ts src/plugin/pullVariables.test.ts src/utils/normalizeTokenSetName.test.ts

Result: all targeted tests pass (4 suites, 21 tests).

Also ran ESLint autofix on touched files:

npx eslint src/plugin/generateTokensToCreate.ts src/plugin/generateTokensToCreate.test.ts src/plugin/pullVariables.ts src/plugin/pullVariables.test.ts src/utils/getTokenSetsOrder.ts src/utils/getTokenSetsOrder.test.ts src/utils/tokenHelpers.ts src/utils/normalizeTokenSetName.ts src/utils/normalizeTokenSetName.test.ts --fix

Additional Notes (if any)

This fix intentionally normalizes only slash-boundary whitespace to avoid changing legitimate internal token-set naming.

Open in Web View Automation 

Co-authored-by: Jan Six <six.jan@gmail.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 13, 2026

⚠️ No Changeset found

Latest commit: 439d1d2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 10 complexity · -10 duplication

Metric Results
Complexity 10
Duplication -10

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@github-actions
Copy link
Copy Markdown
Contributor

⤵️ 📦 ✨ The artifact was successfully created! Want to test it? Download it here 👀 🎁

@github-actions
Copy link
Copy Markdown
Contributor

Commit SHA:7730a3c86295776548a40e7ed41329c5c8d1de8c

Test coverage results 🧪

Code coverage diff between base branch:main and head branch: cursor/figma-plugin-issue-review-02ea 
Status File % Stmts % Branch % Funcs % Lines
🟢 total 61.52 (0.05) 52.95 (0.05) 59.33 (0.04) 61.91 (0.04)
🔴 packages/tokens-studio-for-figma/src/plugin/generateTokensToCreate.ts 100 (0) 81.81 (-7.07) 100 (0) 100 (0)
🟢 packages/tokens-studio-for-figma/src/plugin/pullVariables.ts 78.6 (0.23) 62.56 (2.79) 80.76 (-3.24) 79.09 (0.24)
🔴 packages/tokens-studio-for-figma/src/utils/getTokenSetsOrder.ts 100 (0) 83.33 (-16.67) 100 (0) 100 (0)
✨ 🆕 packages/tokens-studio-for-figma/src/utils/normalizeTokenSetName.ts 100 80 100 100
🟢 packages/tokens-studio-for-figma/src/utils/tokenHelpers.ts 80.64 (0.64) 65.38 (0) 75 (0) 81.48 (0.72)

@github-actions
Copy link
Copy Markdown
Contributor

Commit SHA:7730a3c86295776548a40e7ed41329c5c8d1de8c
Current PR reduces the test coverage percentage by 1 for some tests

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.

Bug: Extended Collections break when spaces are added before or after the / in the child theme

1 participant