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
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-patternThis is because the scss/at-mixin-pattern rule does not allow the use of the _ prefix.
Find out more here:
- Wrong kebab-case pattern for private members
- Default variable, mixin, and function patterns should not error on _ prefix used for private sass contructs
- Allow private mixins, placeholders and functions
- https://github.com/stylelint-scss/stylelint-config-standard-scss/blob/f6dfec8ef432a363984e1b3fed4db417328083e3/index.js#L37
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]+)*$",
}
}