Skip to content

Prettier breaks with interpolation and complex CSS selector #2883

@brikou

Description

@brikou

Prettier 1.7.0
Playground link

--parser typescript
--tab-width 4

Input:

export const foo = css`
&.foo .${bar}::before,&.foo[value="hello"] .${bar}::before {
	position: absolute;
}
`;

Output:

Error: Error: Couldn't insert all the expressions

Expected behavior:

export const foo = css`
    &.foo .${bar}::before,
    &.foo[value="hello"] .${bar}::before {
        position: absolute;
    }
`;

If I replace before,& by before, & (space before &), it works but is not pretty...

Thank you to look at this :D you are wonderful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:multiparserIssues with printing one language inside another, like CSS-in-JSlang:css/scss/lessIssues affecting CSS, Less or SCSSlocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions