Skip to content

[scss] if selector ends with operator two spaces are put between it and bracket #3731

Closed

Description

@zieka

Prettier 1.9.2
Playground link

--parser scss
--tab-width 4
--use-tabs

Input:

.this > .ends > .with > .an > .operator > {
  // note the double space between the operator and bracket
}

.this > .ends > .with > .an > .operator + {
  // note the double space between the operator and bracket
}

.this > .ends > .with > .an > .operator ~ {
  // note the double space between the operator and bracket
}

Output:

.this > .ends > .with > .an > .operator >  {
	// note the double space between the operator and bracket
}

.this > .ends > .with > .an > .operator +  {
	// note the double space between the operator and bracket
}

.this > .ends > .with > .an > .operator ~  {
	// note the double space between the operator and bracket
}

Expected behavior:
Expected there to only be one space between the last operator/combinator in the selector and the bracket (currently there are two spaces)

Activity

  1. vjeux commented on Jan 12, 2018

    @vjeux
    Contributor

    I'm curious, what does it even mean?

  2. zieka commented on Jan 12, 2018

    @zieka
    ContributorAuthor

    while not the greatest use of the syntax, scss will let you end a selector with an operator/combinator
    So this scss:

    .parent > {
      .child-one {
        color: red;
      }
      .child-two {
        color: blue;
      }
    }

    compiles to following css

    .parent > .child-one {
      color: red;
    }
    .parent > .child-two {
      color: blue;
    }

    in my opinion, the proper formatting for this should be the following scss:

    .parent {
      > .child-one {
        color: red;
      }
      > .child-two {
        color: blue;
      }
    }

    but for now the double space printing is ugly.

  3. lydell commented on Jan 12, 2018

    @lydell
    Member

    Wow, I had no idea that was a feature! TIL

  4. vjeux commented on Jan 12, 2018

    @vjeux
    Contributor

    @zieka thanks! I had no idea it existed. We should definitely not add two spaces. We already have a special-case for the second version which is more common.

  5. added
    lang:css/scss/less
    on Jan 12, 2018
  6. ikatyang commented on Jan 14, 2018

    @ikatyang
    Member

    For reference, fixed in #3738.

  7. added
    locked-due-to-inactivity
    on Jul 6, 2018
  8. locked as resolved and limited conversation to collaborators on Jul 6, 2018
  9. added theissue type on Mar 3, 2025
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

    lang:css/scss/lesslocked-due-to-inactivity

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions