Search code examples
stylelint

How to lint typos in color names in stylelint?


Is it possible to have stylelint detect when I have a typo in a named color? Like detecting that color: pruple is wrong, the real color name being purple.

So far I can only find rules for forcing all colors to be hex/alpha/named, but no check to validate the actual named values.


Solution

  • Is it possible to have stylelint detect when I have a typo in a named color?

    Yes, by using the csstree-validator plugin. It will validate the property-value pairs of declarations, including those where the value can contain <color> types.

    {
      "plugins": [
        "stylelint-csstree-validator"
      ],
      "rules": {
        "csstree/validator": true
      }
    }