Stylelint Rule: No Utility Selector Styling

4.0.0 · maintenance · verified Sun Apr 19

This Stylelint rule, `stylelint-selector-no-utility`, is designed to enforce a specific coding standard by disallowing the direct styling of utility classes within CSS. It serves to protect the immutability of single-purpose utility styles, preventing unintended side effects that can arise from altering their definitions. The rule is highly specialized and is intended for use with `@primer/css`, the CSS framework developed by GitHub. The current stable release is version 4.0.0, which was published in March 2019. Due to its close integration with the Primer CSS ecosystem, the package's release cadence is not frequent and is typically tied to updates or changes within Primer CSS itself. Its primary differentiator lies in its targeted application to enforce best practices within a utility-first CSS architecture, specifically for projects utilizing `@primer/css`. It acts as a guardrail against common anti-patterns that can compromise the predictability and maintainability of utility-based styling.

Common errors

Warnings

Install

Imports

Quickstart

This configuration snippet shows how to register the `stylelint-selector-no-utility` plugin and enable its `primer/selector-no-utility` rule in a `.stylelintrc.json` file.

{
  "plugins": [
    "stylelint-selector-no-utility"
  ],
  "rules": {
    "primer/selector-no-utility": true
  }
}

view raw JSON →