Skip to main content

custom-property-no-missing-var-function

Disallow missing var function for custom properties.

:root { --foo: red; }
a { color: --foo; }
/** ↑
* This custom property */

Use this rule to avoid declarations that browsers ignore. A custom property without var(), e.g. --foo alone, is a plain identifier that most properties reject.

This rule ignores properties that accept a <custom-ident> or <dashed-ident> as their whole value, e.g. transition-property.

You can filter the CSSTree Syntax Reference to find out what properties accept them, and use the languageOptions configuration property to extend it.

This rule supports 1 message argument: the custom property.

Options​

true​

{
"custom-property-no-missing-var-function": true
}

The following patterns are considered problems:

:root { --foo: red; }
a { color: --foo; }
@property --foo {}
a { color: --foo; }

The following patterns are not considered problems:

:root { --foo: red; }
a { color: var(--foo); }
@property --foo {}
a { color: var(--foo); }
@property --foo {}
a { transition-property: --foo; }