Linaria: stylelint complains about :global selector

Created on 2 Jul 2019  Â·  6Comments  Â·  Source: callstack/linaria

// https://github.com/callstack/linaria/blob/60962090410ea3878f3c190817c1667a124d7df9/docs/BASICS.md#adding-global-styles
export const globalCSS = css`
  :global() {
    @import-sanitize;
  }
`

Running stylelint on the above code will give:

src/App.tsx
 9:3  ✖  Unexpected unknown pseudo-class selector ":global"   selector-pseudo-class-no-unknown

My stylelint config is:

extends:
  - stylelint-config-recommended
  - linaria/stylelint-config
proposal 💬

Most helpful comment

For those who still have this problem, just add this rule to your .stylelintrc:

 "rules": {
    ...
    "selector-pseudo-class-no-unknown": [
      true,
      {
        "ignorePseudoClasses": ["global"]
      }
    ]
  }

Reference: https://stylelint.io/user-guide/configure#rules

All 6 comments

:global(html) works. See #450

Nvm it doesn't, my bad.

We can probably add ignorePseudoClasses: ["global()"] in the default config

This also happens for :export.

Going to close as it has been a while and I'm not sure if this is relevant anymore.

For those who still have this problem, just add this rule to your .stylelintrc:

 "rules": {
    ...
    "selector-pseudo-class-no-unknown": [
      true,
      {
        "ignorePseudoClasses": ["global"]
      }
    ]
  }

Reference: https://stylelint.io/user-guide/configure#rules

Was this page helpful?
0 / 5 - 0 ratings

Related issues

braco picture braco  Â·  3Comments

satya164 picture satya164  Â·  6Comments

amankkg picture amankkg  Â·  4Comments

jayu picture jayu  Â·  4Comments

MaximeHeckel picture MaximeHeckel  Â·  5Comments