amzn / style-dictionary

A build system for creating cross-platform styles.
https://styledictionary.com
Apache License 2.0
3.87k stars 543 forks source link

fix(transforms): consistent usage of 'token' instead of 'prop' #934

Closed julien-deramond closed 1 year ago

julien-deramond commented 1 year ago

Description of changes:

While working on custom transforms based on the code of existing ones, I noticed a minor discrepancy between the parameter names in transformers and matchers in lib/common/transforms.js.

It seems that there was a big work done in https://github.com/amzn/style-dictionary/pull/617/files#diff-a910c29ae52c0bba61129dd0dc3a9a3fee3293e35c3ecb177ec257e65119832c to force this behavior.

This PR suggests to modify lib/common/transforms.js to use token everywhere and also to modify README.md and docs/extending.md to reflect this change in the doc as well.


Not directly linked to this PR:

I needed to execute locally npm test -- -u to be able to have passed tests locally and to commit my modifications. __integration__/__snapshots__/compose.test.js.snap and __tests__/formats/__snapshots__/all.test.js.snap were modified this way:

diff --git a/__integration__/__snapshots__/compose.test.js.snap b/__integration__/__snapshots__/compose.test.js.snap
index eb7f42d..08bd161 100644
--- a/__integration__/__snapshots__/compose.test.js.snap
+++ b/__integration__/__snapshots__/compose.test.js.snap
@@ -10,7 +10,6 @@ exports[`integration compose compose/object should match snapshot 1`] = `

 package com.example.tokens;

-
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.unit.*

@@ -191,7 +190,6 @@ exports[`integration compose compose/object with references should match snapsho

 package com.example.tokens;

-
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.unit.*

diff --git a/__tests__/formats/__snapshots__/all.test.js.snap b/__tests__/formats/__snapshots__/all.test.js.snap
index 15230d2..68a3634 100644
--- a/__tests__/formats/__snapshots__/all.test.js.snap
+++ b/__tests__/formats/__snapshots__/all.test.js.snap
@@ -90,7 +90,6 @@ exports[`formats all should match compose/object snapshot 1`] = `

 package ;

-
 import androidx.compose.ui.graphics.Color
 import androidx.compose.ui.unit.*

I haven't commited these files here because not linked to this PR. But maybe there's something to do in the main branch. IDK enough the project to know if it is needed :)


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.