Skip to content

dollar-variable-pattern

Reports a $name declaration whose name, without the $, does not match the pattern option (a regex). An empty pattern allows everything.

A naming convention for Sass variables keeps the variables of a project predictable. The rule is a policy: with no pattern it reports nothing.

With this configuration:

no-global-function-names: warn
at-mixin-argumentless-call-parentheses: warn
at-rule-conditional-no-parentheses: warn
at-extend-no-missing-placeholder: warn
at-if-no-null: warn
load-no-partial-leading-underscore: warn
dollar-variable-pattern: { level: warn, options: { pattern: "^[a-z-]+$" } }
at-mixin-pattern: { level: warn, options: { pattern: "^[a-z-]+$" } }
at-function-pattern: { level: warn, options: { pattern: "^[a-z-]+$" } }
Reported
...
@use "c.css";
$fooBar: map-get($m, a) + list.length($x);
...
a {
...
css:
lint:
rules:
dollar-variable-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
less:
lint:
rules:
dollar-variable-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
scss:
lint:
rules:
dollar-variable-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
Option Type Default Description
pattern string "" The regex a variable name, without its $, must match.

Enabled by the presets: css/stylelint-standard.

Suppress one line with sudsy-disable-next-line dollar-variable-pattern in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
stylelint-scss scss/dollar-variable-pattern full