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

Comments with newlines are not formatted nicely in createPropertyFormatter #952

Closed jorenbroekema closed 11 months ago

jorenbroekema commented 1 year ago

This was raised in our repo https://github.com/tokens-studio/sd-transforms/issues/62 but I believe it to be best fixed in style-dictionary createPropertyFormatter.

Current

:root {
  --foo-bar: #FFFFFF; // Some comment with a 
<-- new line here that creates invalid CSS
}

^ this part I would call a bug, because it actually results in broken CSS, so in that sense this issue is not just a feature request but moreso a bug report.

or if you set it to commentStyle "long":

:root {
  --foo-bar: #FFFFFF; /* Some comment with a 
<-- new line here that creates invalid CSS */
}

Expected

Newlines to be filtered out in short:

:root {
  --foo-bar: #FFFFFF; // Some comment with a <-- new line here that creates invalid CSS
}

or with commentStyle "long":

:root {
  /** 
   * Some comment with a 
   * <-- new line here that creates invalid CSS
   */
  --foo-bar: #FFFFFF;
}

I'm happy to create a PR for this, but only if you guys have the time to review & release it at some point :)

chazzmoney commented 1 year ago

@jorenbroekema We will have time to review and release - we are checking once a week or so right now. If you have a PR submitted, we will take a look.