question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kebab case transform seems inconsistent with other name transforms

See original GitHub issue

Hi, hope you’re doing well @dbanksdesign!

I noticed that because the cti/name/kebab-case transform uses lodash’s kebabCase under the hood, it is prone to inserting dashes between numbers and letters as if they were different words. This is inherent in their implementation of kebab and does not appear to be up for changing any time soon.

Issues raised in lodash’s repo here asking similar questions: https://github.com/lodash/lodash/issues/2425 https://github.com/lodash/lodash/issues/4462 https://github.com/lodash/lodash/issues/4205 https://github.com/lodash/lodash/issues/4141

Here’s an example of what is happening in our dictionary:

Where the json is:

"size": {
  "spacing": {
    "2xl": { "value": "2.5" }
  }
}

Our expectation for a css variable is --size-spacing-2xl The actual output is --size-spacing-2-xl

I understand this is probably by design, but unfortunately it creates inconsistencies between css/scss variable outputs and js/json outputs, where the resulting objects still have the original non-kebab attribute.

We have already solved this with a custom transform on our dictionary but I thought it was worth bringing up to see if you’d be open to a PR to change the default kebab transforms. Let me know if there’s a reason that this should not be changed as we are ok with the custom transform, but perhaps it’s worth bringing up in the docs somewhere. (Perhaps it’s already in the docs and I missed it)

All the best!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
chazzmoneycommented, Feb 23, 2021

@juanfabrega

We are changing our case-changing support in 3.0 to use change-case and want to create some unit tests around it. If you have any challenging ones, please submit them on #500

1reaction
dbanksdesigncommented, May 25, 2021

3.0 is launched! This should be fixed now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

kebabcase incorrect results · Issue #4462 · lodash ... - GitHub
Kebab case transform seems inconsistent with other name transforms amzn/style-dictionary#449. Closed. This was referenced on Aug 9, 2020.
Read more >
Convert Pascal Case to Kebab Case in VSCode User Snippet
I'm currently trying to write a user snippet that will take a variable of ${1} (For example JobsSummary) and convert it into Kebab...
Read more >
Encoding/Decoding JSON with camelCase keys - Eneko Alonso
This convention uses lower camel case ( camelCase ) for object/struct property names. In this scenario, we can encode/decode JSON objects ...
Read more >
Convert Strings into any Case • snakecase
It converts strings (by default) into snake case: ... However, one can choose between many other cases like "lower_camel" , "upper_camel" , "all_caps" ......
Read more >
Ukraine: Here's what comes next for the conflict | CNN
Here's what comes next for the conflict. Analysis by Tim Lister and Vasco Cotovio, CNN. Updated 8:21 AM EDT, Mon September 19, 2022....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found