How to make regex work in stylelint rule?

60 Views Asked by At

i want to specify allowed values properties for 'background' and i made this

rules: {
        'declaration-property-value-allowed-list': {
            'background': ['/^linear-gradient\(.*\)$/', '/var/']
        },
    },

I want to make rule that allows only variables and linear-gradient function as property value and forbid hex / rgb / rgba etc. But linter doesnt take the value

background: linear-gradient(
            263deg,
            rgba(84, 145, 255, 0.24) 0%,
            rgba(169, 143, 207, 0.06) 30.85%,
            rgba(169, 143, 207, 0.06) 74.1%,
            rgba(172, 159, 126, 0.12) 100%
        );

error:

Unexpected value "linear-gradient( 263deg, rgba(84, 145, 255, 0.24) 0%, rgba(169, 143, 207, 0.06)  declaration-property-value-allowed-list
           30.85%, rgba(169, 143, 207, 0.06) 74.1%, rgba(172, 159, 126, 0.12) 100% )" for property                                                   
           "background" 

Are some mistakes in my regex ? /^linear-gradient\(.*\)$/

0

There are 0 best solutions below