Add `no-unknown-custom-properties`
See original GitHub issueWhat is the problem you’re trying to solve?
I’d like to disallow unknown custom properties. For example:
:root {
--foo: 1px;
}
a {
top: var(--bar);
}
What solution would you like to see?
A new rule to catch this. It’s currently available as a plugin but it meets our criteria to be a built-in rule.
Prior art for user-defined unknowns is no-unknown-animations.
Also, see this Twitter thread.
We’d need to address https://github.com/stylelint/stylelint/issues/4088 first, and work out how best to add imports & resolvers to configuration files. Is standardised importForm
and resolver
secondary options on each of these types of rules the way to go?
- Name:
no-unknown-custom-properties
- Primary option:
true
- Secondary options:
importForm
&resolver
? - Autofixable: No
- Message: -
Unexpected unknown custom property
- Description: “Disallow unknown custom properties.”
- Extended description: “This rule considers custom properties defined within the same source to be known. Use the
importForm
secondary option to specify more sources.” - Section: “Avoid errors” -> “General”
Like no-unknown-animations, we won’t turn the rule on in the recommended config and we’ll want to update the recommended config to reflect this.
Any thoughts?
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (5 by maintainers)
Top Results From Across the Web
csstools/stylelint-value-no-unknown-custom-properties - GitHub
Stylelint Value No Unknown Custom Properties is a stylelint rule to disallow usage of unknown custom properties. Usage. Add stylelint and Stylelint Value...
Read more >stylelint-value-no-unknown-custom-properties - npm
A stylelint rule to disallow usage of unknown custom properties. Latest version: 4.0.0, last published: 8 months ago.
Read more >property-no-unknown | Stylelint
Disallow unknown properties. This rule considers properties defined in the CSS Specifications and browser specific properties to be known. This rule ignores:
Read more >stylelint-value-no-unknown-custom-properties - npm package
A stylelint rule to disallow usage of unknown custom properties. Visit Snyk Advisor to see a full health score report for stylelint-value-no-unknown-custom- ...
Read more >stylelint-value-no-unknown-custom-properties examples
Learn how to use stylelint-value-no-unknown-custom-properties by viewing and forking example apps that make use of stylelint-value-no-unknown-custom-properties ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I agree.
I’ll label this as ready to implement.
no-unknown-custom-properties
true
importFrom: []
- array of glob paths to.css
filesUnexpected unknown custom property
importFrom
secondary option to specify more sources.”If anyone fancies contributing this rule, there are steps on how to add a new rule in the Developer guide.
I agree with the idea.
Indeed, there may be a helpful case if
defaultImportFrom
is supported. But I’m not sure whether it is necessary for the first step. If it is easy to implementdefaultImportFrom
andimportFrom
simultaneously, I agree with adding both.