Search code examples
cssangularhostpseudo-classstylelint

Angualar2 & Stylelint: Unexpected unknown pseudo-class selector ":host"


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]

Solution

  • 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