Skip to content

Styled-components css injection issue in 1.12.0 #4301

@thebuilder

Description

@thebuilder

Updated Prettier, and noticed my global CSS stopped working. Something changed in Prettier, that causes it to remove the html tag from my styled-components css.

Note: If i use injectGlobal instead of css it works as expected.

Prettier 1.12.0
https://prettier.io/playground/#N4Igxg9gdgLgprEAuEBLAtgBwgJxgAmHzAGcT8BffAMxwnXwHISYBPAGzgBMBaSLaAhglGAHSgZseQvhIBDCTFQAvOJRp0GjAHQB6eYpVwxEgdKLVow9bXpM9l2CPHi4ADykEucanICu7ASkJAAG4vj4ACTABqhKqhThUcCOwolQEQAWMOjshEkR6HI4AOaoUEj4AAwA3EnpYVAgADQgEJhK0CTIoMV0AO4ACsUI3ShyAG4QqFwtIHIsyL7sJHCtAEY4cmAA1nAwAMqY2+UlyDA4fmsgXBBgS3Ir1+WreINbJUUPT60AViRuABCW12+wOcnQcAAMuU4N9Vq0IH4YJhkQAmeHXY44V7IEDrOTrDjQOaYHDlGAAdRmMEyyAAHFVWmSIKtKVtMHiyXBXhM4a0cHAAI5+VCC95yT5yTGtVboVAykAkU6cACKfgg8HOl2uMEJ1K4tOQaNaFzkqHYpwAwvQvigoII5n5VgAVQljZarCgUIA

# Options (if any):
--single-quote

Input:

import { css } from 'styled-components'
import { sanitize } from './sanitize'
import { fonts } from './fonts'

export default css`
  ${sanitize}
  ${fonts}
  html {
    margin: 0;
  }
`

Output:

import { css } from 'styled-components'
import { sanitize } from './sanitize'
import { fonts } from './fonts'

export default css`
  ${sanitize} ${fonts} {
    margin: 0;
  }
`

Expected behavior:
It shouldn't remove the html element from the css. Earlier versions preserved the html tag correctly:

export default css`
  ${sanitize} ${fonts}
  html {
    margin: 0;
  }
`

Metadata

Metadata

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.priority:highCode is printed in a way that alters the AST, breaks syntax, or is a significant regression. Urgent!

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions