Search code examples
htmlstylelint

How to configure stylelint to ban all HTML tags


Is there a way to configure stylelint to disallow all selectors which include tag names?

I found the (stylelint-selector-tag-no-without-class)[https://www.npmjs.com/package/stylelint-selector-tag-no-without-class] plugin, using which I want to ban ALL tag names, present and future, without listing each and every tag.


Solution

  • You can use the built-in selector-max-type rule to disallow all selectors which include tag names (aka type selectors):

    {
      "rules": {
        "selector-max-type": 0
      }
    }
    

    This will disallow all tag names, present and future, as the rule disallows selectors that are parsed as type selectors, rather than relying on some list of known type selectors.