ThisIsManta / stylus-supremacy

A Node.js script that helps formatting Stylus files.
https://thisismanta.github.io/stylus-supremacy
MIT License
88 stars 9 forks source link

Adds extra parenthesis. #41

Closed carterworks closed 5 years ago

carterworks commented 5 years ago

Formatting the code adds an extra set of parenthesis, without end.

Here's a test case

div {
  $width = 50;
  height: '%spx' % ($width / 2);
  width: '%spx' % $width;
  drop-shadow: '%spx %spx %spx green' % ((($width / 2) - 2) ($width - 4) ($width - 4));
}

Formatting it three times results in this:

div {
  $width = 50;
  height: '%spx' % ($width / 2);
  width: '%spx' % $width;
  drop-shadow: '%spx %spx %spx green' % ((($width / 2) - 2) (((($width - 4)))) (((($width - 4)))));
}

When the string interpolation argument are not wrapped in parenthesis, like the block below, this bug doesn't happen:

div {
  $width = 50;
  height: '%spx' % ($width / 2);
  width: '%spx' % $width;
  drop-shadow: '%spx %spx %spx green' % (($width / 2) - 2) ($width - 4) ($width - 4);
}
ThisIsManta commented 5 years ago

Thanks for reporting the bug. I'll take care of this tomorrow.

ThisIsManta commented 5 years ago

This is actually a bug from Stylus compiler (out of my scope), where the compiler generates an extra Expression node in a nested Expression. However, I can manage to find a workaround and patch this in Stylus Supremacy. Please upgrade to version 2.12.7.

carterworks commented 5 years ago

Thanks for getting a work around done so quickly. Do you think an issue on the Stylus repo would be appropriate?