Skip to content

breaks CSS in JS ${Cls}:not() -> ${Cls}:not () #6259

@brandonkal

Description

@brandonkal

Prettier 1.18.2
Playground link

--parser typescript

I am using Typescript but this does not matter here.

Input:

export const Group = styled.div`
  margin: 0;

  .input {
    margin: 0;
  }

  ${StyledInput}:not(:first-child) {
    margin: 0;
  }

  & > :not(.${inputWrap}):not(${Button}) {
    display: flex;
  }
`

Output:

export const Group = styled.div`
  margin: 0;

  .input {
    margin: 0;
  }

  ${StyledInput}:not (:first-child) {
    margin: 0;
  }

  & > :not(.${inputWrap}):not(${Button}) {
    display: flex;
  }
`;

Expected behavior:
No space should be inserted after not as this breaks the CSS.

Updated with minimal reproduction. It appears that having a child selector is required. Oddly, the space is not always inserted as you can see in the last declaration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:css/scss/lessIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions