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:
moduleexportsplugins = 'stylelint-value-no-numeric-constants'; moduleexportsrules = 'tradingview/value-no-numeric-constants': 'order' 'z-index' severity: 'warning'
Values that triggers errors:
Given z-index
and width
are specified in config:
/* Error! Numeric constant. *//* Error! Expression that consists only of numeric constants. */); /* Error! Expression that consists only of numeric constants. And braces won't fool us. */); /* Error! Calc expression that consists only of numeric constants. */); /* Error! Constants with units are still constants. */-); /* Error! No matter how property or calc are prefixed. *//* Error! */
OK values, that DOESN'T trigger errors:
Given z-index
is specified in config:
/* Okay. A SASS-like variable. That's the way we code! */@/* Okay. A LESS-like variable. Yess! Variables everywhere! *//* Okay. We don't know what is it, but it's clearly not a numeric constant. *//* Okay. */); /* Okay. */); /* Okay. */