7

How can I teach Stylelint Angular's selector ":host" ?

E.g. Angular2-Seed by MGechev shows in its build-process ":host" as error:

src/client/app/+home/home.component.css
1:1     ‼  Unexpected unknown pseudo-class selector 
        ":host" (selector-pseudo-class-no-unknown) [stylelint]

2 Answers2

12

Use the following selector-pseudo-class-no-unknown rule definition:

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

Edit: See https://stackoverflow.com/a/39196050/1911294 for the new recommended approch

Community
  • 1
  • 1
netweb
  • 622
  • 5
  • 12
  • the option name has changed to `ignorePseudoElements` https://stylelint.io/user-guide/rules/selector-pseudo-element-no-unknown#ignorepseudoelements-regex-string – André Kelling Jun 01 '21 at 06:41
3

Support for the CSS Scoping Module Level 1 pseudo-classes and pseudo-element of :host, :host-context and ::slotted was added in stylelint@7.2.0.

After updating to this version you should no longer need to use the ignorePseudoClasses optional secondary option.

jeddy3
  • 3,451
  • 1
  • 12
  • 21