lukasoppermann / design-tokens

🎨 Figma plugin to export design tokens to json in an amazon style dictionary compatible format.
https://www.figma.com/community/plugin/888356646278934516/Design-Tokens
MIT License
971 stars 134 forks source link

update toCamelCase #290

Open cailborg opened 1 year ago

cailborg commented 1 year ago

Checks for existing camelCase before applying a conversion

Screenshot 2023-10-31 at 10 48 38 am

OUTPUT

 "interactiveSubtle": {
          "type": "color",
          "value": "{palette.eggplant.300}"
        },
coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 6739879734

Warning: This coverage report may be inaccurate.

We've detected an issue with your CI configuration that might affect the accuracy of this pull request's coverage report. To ensure accuracy in future PRs, please see these guidelines. A quick fix for this PR: rebase it; your next report should be accurate.


Changes Missing Coverage Covered Lines Changed/Added Lines %
src/utilities/transformName.ts 2 3 66.67%
<!-- Total: 2 3 66.67% -->
Totals Coverage Status
Change from base Build 6474855251: -0.09%
Covered Lines: 497
Relevant Lines: 732

💛 - Coveralls
lukasoppermann commented 1 year ago

Hey, thank you for the PR.

I think we should make sure that it does also work if there are numbers in the name, what do you think?

cailborg commented 1 year ago

No worries, should work with numbers now. Input:

Screenshot 2023-11-03 at 11 40 11 am

Output:

Screenshot 2023-11-03 at 11 40 22 am
lukasoppermann commented 1 year ago

Hey, sadly with the change to the function we run into issues so that the test does not pass anymore:

Use npx jest transformName to run the test locally.

FAIL tests/unit/transformName.test.ts transformName ✓ default case (1 ms) ✕ camelCase (3 ms) ✓ kebab-case

● transformName › camelCase

expect(received).toStrictEqual(expected) // deep equality

- Expected  - 6
+ Received  + 6

  Array [
-   "fooBar",
-   "fooBar",
-   "fooBar",
-   "foo123bar",
+   " FooBar",
+   "-fooBar",
+   "_FOOBAR",
+   "foo123Bar",
    "fooBar",
    "fooBarFooBarFooBarFooBar",
-   "equipmentclassName",
-   "equipmentClassname",
+   "equipmentClassName",
    "equipmentClassName",
    "equipmentClassName",
+   " EquipmentClassName",
  ]

  35 |   test('camelCase', () => {
  36 |     const transformed = strings.map(string => transformName(string, 'camelCase'))
> 37 |     expect(transformed).toStrictEqual([
     |                         ^
  38 |       'fooBar',
  39 |       'fooBar',
  40 |       'fooBar',
lukasoppermann commented 12 months ago

Hey @cailborg would you be able to update this so we can merge it?