Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
stylelint-value-no-numeric-constants
Advanced tools
Stylelint plugin that disallows constant numeric values for specified properties
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.
Array of unprefixed property names (strings).
.stylelintrc.js:
module.exports.plugins = ['stylelint-value-no-numeric-constants'];
module.exports.rules = {
'tradingview/value-no-numeric-constants': [['order', 'z-index'], {
severity: 'warning'
}],
}
Given z-index
and width
are specified in config:
z-index: 42; /* Error! Numeric constant. */
z-index: 40 + 2; /* Error! Expression that consists only of numeric constants. */
z-index: (40 + 2); /* Error! Expression that consists only of numeric constants. And braces won't fool us. */
z-index: calc(40 + 2); /* Error! Calc expression that consists only of numeric constants. */
width: calc(42% + 100px); /* Error! Constants with units are still constants. */
-moz-z-index: -webkit-calc(40 + 2); /* Error! No matter how property or calc are prefixed. */
z-index: -40 + -2.71; /* Error! */
Given z-index
is specified in config:
z-index: $my_z_index; /* Okay. A SASS-like variable. That's the way we code! */
z-index: @my_z_index; /* Okay. A LESS-like variable. Yess! Variables everywhere! */
z-index: #my_z_index; /* Okay. We don't know what is it, but it's clearly not a numeric constant. */
z-index: $my_z_index + 1; /* Okay. */
z-index: var(--omg, 100px); /* Okay. */
z-index: url(100px); /* Okay. */
FAQs
Stylelint plugin that disallows constant numeric values for specified properties
The npm package stylelint-value-no-numeric-constants receives a total of 931 weekly downloads. As such, stylelint-value-no-numeric-constants popularity was classified as not popular.
We found that stylelint-value-no-numeric-constants demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.