Skip to content

custom-property-pattern

Reports a custom property whose name, without the --, does not match the pattern option (a regex), where it is declared, used in var() or named by @property. An empty pattern allows everything.

A naming convention for custom properties makes the variables of a design system predictable, so a name can be guessed and searched for. The rule is a policy: with no pattern it reports nothing.

Reported
.good-name, .badName, #bad_id, #good-id { --good-name: 1; --badName: 2 }
...
@keyframes good-frames { from { top: 0 } }
...
css:
lint:
rules:
custom-property-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
less:
lint:
rules:
custom-property-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
scss:
lint:
rules:
custom-property-pattern:
level: warn # off (default), warn, error
options:
pattern: ""
Option Type Default Description
pattern string "" The regex a custom property name, without its --, must match.

Enabled by the presets: css/stylelint-standard.

Suppress one line with sudsy-disable-next-line custom-property-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 custom-property-pattern full