Skip to content

Instantly share code, notes, and snippets.

@tiloyi
Last active June 13, 2025 12:46
Show Gist options
  • Select an option

  • Save tiloyi/79fe0cc3b6110a502e96711da631e2a6 to your computer and use it in GitHub Desktop.

Select an option

Save tiloyi/79fe0cc3b6110a502e96711da631e2a6 to your computer and use it in GitHub Desktop.
[Stylelint] – scss/at-mixin-pattern (Sass / SCSS private members)

About Sass Private Members

The Sass specification allows us to create private mixins. These private mixins are usable and available only within a Sass module and cannot therefore be consumed outside this module.

To make a mixin private, simply prefix the mixin with the - or _ character.

For more information, see Sass documentation here: https://sass-lang.com/documentation/at-rules/use/#private-members

Issue with Stylelint & stylelint-config-standard-scss

When using Stylelint with stylelint-config-standard-scss on a Sass project containing private mixins, it may happen that the latter returns the following error:

✖  Expected mixin name to be kebab-case  scss/at-mixin-pattern

This is because the scss/at-mixin-pattern rule does not allow the use of the _ prefix.

Find out more here:

Customizing the Stylelint rule

To overcome this, we can customise the Stylelint rule so that it uses the characters - or _ as a prefix and is ISO compliant with the Sass specification.

{
  "rules": {
    "scss/at-mixin-pattern": "^[-_]?([a-z][a-z0-9]*)(-[a-z0-9]+)*$",
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment