tokens-studio / figma-plugin

Official repository of the plugin 'Tokens Studio for Figma' (Figma Tokens)
https://www.figma.com/community/plugin/843461159747178978
MIT License
1.35k stars 194 forks source link

Importing variables leaves internal token properties exposed #2917

Closed six7 closed 4 weeks ago

six7 commented 3 months ago

When we import variables from Figma we take variables and then store that as tokens. Sometimes we override existing values, if a token already existed. To do that, we use some token keys internally that let us understand what was the old value, and the new. However, it seems we expose these to the user and save back to the JSON.

If I create a Figma variable of type number with a value of 16 and then go to Import variables, the result in JSON looks like this:

{
  "mynumber": {
    "value": "16",
    "type": "number",
    "parent": "Collection 1/Mode 1",
    "description": ""
  }
}

If I then change the variable's value in Figma to 32 and do an Import again, it will look like this:

{
  "mynumber": {
    "value": "32",
    "type": "number",
    "parent": "Collection 1/Mode 1",
    "description": "",
    "oldValue": 16
  }
}

This is a problem, because we expose 2 keys that should be only internal: parent and oldValue. We need to make sure that we strip away those tokens when we import.

Note that this also happens on production.

six7 commented 4 weeks ago

Cannot reproduce anymore in latest