tradingview/value-no-numeric-constants
Disallows constant numeric values for specified properties. Designed to disallow "magic constants" for z-index
properties, but can be used for any property.
Expressions in braces or within calc()
that consists only of constant values are treated like constants as well.
Options:
Array of unprefixed property names (strings).
Sample configuration:
.stylelintrc.js:
module.exports.plugins = ['stylelint-value-no-numeric-constants'];
module.exports.rules = {
'tradingview/value-no-numeric-constants': [['order', 'z-index'], {
severity: 'warning'
}],
}
Values that triggers errors:
Given z-index
and width
are specified in config:
z-index: 42;
z-index: 40 + 2;
z-index: (40 + 2);
z-index: calc(40 + 2);
width: calc(42% + 100px);
-moz-z-index: -webkit-calc(40 + 2);
z-index: -40 + -2.71;
OK values, that DOESN'T trigger errors:
Given z-index
is specified in config:
z-index: $my_z_index;
z-index: @my_z_index;
z-index: #my_z_index;
z-index: $my_z_index + 1;
z-index: var(--omg, 100px);
z-index: url(100px);