Skip to content

Mixed SCSS feedback #1805

Closed
Closed

Description

@lydell

I ran Prettier on some real word SCSS code and went through the diff. I found a few things that didn't print super nice, and a few things that broke the code.

Missing space to the right of /

.Image {
  @media (max-width: $image-width-responsive) {
    padding-bottom:
      (
        100% *
        $image-height /
        ($image-width-responsive + $image-margin-responsive * 2)
      );
  }
}
.Image {
  @media (max-width: $image-width-responsive) {
    padding-bottom: (
      100% *
        $image-height /($image-width-responsive + $image-margin-responsive * 2)
    );
  }
}

Also, printing it more like we do for JS would be nicer:

if (1) {
  if (1) {
    padding_bottom = (
      100 *
        $image_height /($image_width_responsive + $image_margin_responsive * 2)
    );
  }
}
if (1) {
  if (1) {
    padding_bottom =
      100 *
      $image_height /
      ($image_width_responsive + $image_margin_responsive * 2);
  }
}

Another example:

a {
  padding-right: (100% * $info-width / (1 - $image-width));
}
a {
  padding-right: (100% * $info-width /(1 - $image-width));
}

Extraneous space before > at BOL

a {
  > * {
  }
}
a {
   > * {
  }
}

Also happens for + and ~.

Hmm, not only beginning of lines, but also beginning of sub selector:

a {
  &,
  > span[data-i18n] {
  }
}
a {
  &,  > span[data-i18n] {
  }
}

This would be nicer if printed more like JS

a {
  b {
    img {
      max-height:
        calc(
          100vh -
          #{var(--margin)} * 2 - #{var(--padding)} * 2 -
          #{$extra-space-for-scrollbar}
        );
    }
  }
}
a {
  b {
    img {
      max-height: calc(
        100vh -
          #{var(--margin)} *
          2 -
          #{var(--padding)} *
          2 -
          #{$extra-space-for-scrollbar}
      );
    }
  }
}
{
  {
      max_height = calc(
        100 -
          $(car(__margin)) *
          2 -
          $(car(__padding)) *
          2 -
          $($extra_space_for_scrollbar)
        );
  }
}
{
  {
    max_height = calc(
      100 -
        $(car(__margin)) * 2 -
        $(car(__padding)) * 2 -
        $($extra_space_for_scrollbar)
    );
  }
}

Should we try to break here?

Garbage in, garbage out, or do we want to break something like the input here?

a {
  ~ .Pagination-itemWrapper:not(.is-separator):not([data-priority^='#{$priority}'])
    ~ .Pagination-itemWrapper.is-separator[data-priority^='#{$priority}'] {
    display: flex;
  }
}
a {
  ~ .Pagination-itemWrapper:not(.is-separator):not([data-priority^='#{$priority}']) ~ .Pagination-itemWrapper.is-separator[data-priority^='#{$priority}'] {
    display: flex;
  }
}

Removed space before -

a {
  width: calc(100% - (#{var(--g-spacing)} - #{$iframe-x-padding}) * 2);
}
a {
  width: calc(100% -(#{var(--g-spacing)} - #{$iframe-x-padding}) * 2);
}

Activity

  1. vjeux commented on May 29, 2017

    @vjeux
    Contributor

    This would be nicer if printed more like JS

    Right now we only get a stream of tokens. We'd need to parse it to be able to reprint it properly. If you are interested in writing a small arithmetic parser, that would be great :)

  2. vjeux commented on May 29, 2017

    @vjeux
    Contributor

    #1806 and #1807 fix a bunch of your issues.

    I'm going to try and break expressions before combinators now.

  3. vjeux commented on May 29, 2017

    @vjeux
    Contributor

    Okay, #1809 adds the ability for ultra long selectors to break before combinators. So everything here is done.

    The only remaining thing is to handle arithmetic operators better. For this, we need to implement a small arithmetic parser and print it correctly. It shouldn't be too hard, but I'm going to focus on other things to get a release going.

  4. lydell commented on May 29, 2017

    @lydell
    MemberAuthor

    Awesome! You decide if we should keep this issue open or not :)

  5. vjeux commented on May 29, 2017

    @vjeux
    Contributor

    Could you open a separate issue for improving printing of arithmetic?

  6. lydell commented on May 29, 2017

    @lydell
    MemberAuthor

    Ok! #1811

  7. added
    locked-due-to-inactivity
    on Jul 7, 2018
  8. locked as resolved and limited conversation to collaborators on Jul 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    locked-due-to-inactivity

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions