
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@ronilaukkarinen/stylelint-value-no-unknown-custom-properties
Advanced tools
A stylelint rule to disallow usage of unknown custom properties
Stylelint Value No Unknown Custom Properties is a stylelint rule to disallow usage of unknown custom properties.
Add stylelint and Stylelint Value No Unknown Custom Properties to your project.
npm install stylelint @ronilaukkarinen/stylelint-value-no-unknown-custom-properties --save-dev
Add Stylelint Value No Unknown Custom Properties to your stylelint configuration.
{
"plugins": [
"@ronilaukkarinen/stylelint-value-no-unknown-custom-properties"
],
"rules": {
"csstools/value-no-unknown-custom-properties": true || false || null
}
}
If the first option is true, then Stylelint Value No Unknown Custom Properties
requires all custom properties to be known, and the following patterns are
not considered violations:
:root {
--brand-blue: #33f;
}
.example {
color: var(--brand-blue);
}
.example {
color: var(--brand-blue);
}
.some-other-class {
--brand-blue: #33f;
}
:root {
--brand-blue: #33f;
--brand-color: var(--brand-blue);
}
While the following patterns are considered violations:
.example {
color: var(--brand-blue);
}
:root {
--brand-color: var(--brand-blue);
}
Custom Properties can be imported using the second option.
If the first option is false or null, then
Stylelint Value No Unknown Custom Properties does nothing.
When the first option is true, then the second option can specify sources
where Custom Properties should be imported from by using an importFrom key.
These imports might be CSS, JS, and JSON files, functions, and directly passed
objects.
// .stylelintrc
{
"plugins": [
"stylelint-value-no-unknown-custom-properties"
],
"rules": {
"csstools/value-no-unknown-custom-properties": [true, {
"importFrom": [
"path/to/file.css", // => :root { --brand-blue: #33f; }
"path/to/file.json" // => { "custom-properties": { "--brand-blue": "#33f" } }
]
}]
}
}
Use this option to configure how the rule solve paths of @import rules.
// .stylelintrc
{
"plugins": [
"stylelint-value-no-unknown-custom-properties"
],
"rules": {
"csstools/value-no-unknown-custom-properties": [true, {
"resolver": {
"extensions": [".css"], // => default to [".css"]
"paths": ["./assets/css", "./static/css"] // => paths to look for files, default to []
"moduleDirectories": ["node_modules"] // => modules folder to look for files, default to ["node_modules"]
}
}]
}
}
FAQs
A stylelint rule to disallow usage of unknown custom properties
We found that @ronilaukkarinen/stylelint-value-no-unknown-custom-properties 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
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.