Skip to content

Extra space in styled component grid-area named area #8250

@ccwoolfolk

Description

@ccwoolfolk

This may be similar enough to #5465 to warrant a duplicate flag. I'm filing a non-var() example since the title of #5465 indicates that issue is specific to within var().

Prettier 2.0.5
Playground link

--parser babel

Input:

// `styled` inserts space between "area-" and prop name
export const StyledComponent = styled.div`
	grid-area: area-${props => props.propName};
`

// Other names behave as expected (no extra space)
export const StyledComponent = someOtherName.div`
	grid-area: area-${props => props.propName};
`

Output:

// `styled` inserts space between "area-" and prop name
export const StyledComponent = styled.div`
  grid-area: area- ${(props) => props.propName};
`;

// Other names behave as expected (no extra space)
export const StyledComponent = someOtherName.div`
	grid-area: area-${(props) => props.propName};
`;

Expected behavior:
grid-area: area-[prop name] without a space after the -

In this specific case, it is trivial to move area- into the function, but nonetheless, the formatter does change the behavior of the code.

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