Add `declaration-property-value-no-unknown`
See original GitHub issueWhat steps are needed to reproduce the bug?
body {
padding: auto;
}
What Stylelint configuration is needed to reproduce the bug?
{
"extends": [
"stylelint-config-standard",
"stylelint-config-prettier"
],
"rules": {
"block-closing-brace-newline-after": [
"always", {
"ignoreAtRules": [ "if", "else" ]
}
],
"at-rule-no-unknown": [
true,
{
"ignoreAtRules": [
"mixin",
"if",
"else",
"error",
"include",
"at-root",
"extend"
]
}
]
},
"property-no-unknown": true,
"defaultSeverity": "warning"
}
How did you run Stylelint?
From VSCode
Which version of Stylelint are you using?
14.13.0
What did you expect to happen?
The editor should tell me that ‘auto’ is not a permitted value for property ‘padding’.
What actually happened?
Nothing, the error is not reported.
Does the bug relate to non-standard syntax?
Nope, tryed in a plain CSS
Proposal to fix the bug
No response
Issue Analytics
- State:
- Created a year ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
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 'Unknown rule declaration-property-value-blacklist ...
Stylelint shows the "Unknown rule ..." problem when it encounters a rule in the configuration object that it doesn't recognise.
Read more >property - CSS: Cascading Style Sheets - MDN Web Docs
Unknown descriptors are invalid and ignored, but do not invalidate the @property rule. Examples. Add type checking to --my-color custom property ...
Read more >stylelint-value-no-unknown-custom-properties - Yarn
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 >Property Declarations - Sass
Sometimes you only want a property declaration to show up some of the time. If a declaration's value is null or an empty...
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
This question pops up often, and it feels like an appropriate time to revisit it.
As mentioned in our doc that @ybiquitous linked to, there are three types of tools:
Stylelint has historically overlapped with both validators and formatters. We intend to remove our formatting rules so that we don’t overlap with formatters. We need a clear vision for how we approach validation too.
We split our rules into two groups that:
The latter group is made up of 5 subgroups that:
no-*
,*-allowed-list
and*-disallowed-list
rules , e.g.unit-disallowed-list
max-*
andmin-*
rules, e.g.selector-max-id
*-pattern
rules, e.g.custom-property-pattern
*-notation
rules, e.g.color-function-notation
*-quotes
rules, e.g.function-url-quotes
no-redundant-*
rules, e.g.shorthand-property-no-redundant-values
These all apply to valid CSS. They are powerful rules, mostly unique to Stylelint and aligned with our goal of being a linter.
The group that avoids errors is made up of two subgroups that check for:
*-no-invalid
rules , e.g.named-grid-areas-no-invalid
*-no-unknown
rules, e.g.unit-no-unknown
no-duplicates-*
rules, e.g.keyframe-block-no-duplicate-selectors
no-*-overrides
rules, e.g.declaration-block-no-shorthand-property-overrides
no-missing-*
rules, e.g.custom-property-no-missing-var-function
no-*
rules, e.g.keyframe-declaration-no-important
(as an aside, we should have calledno-invalid-double-slash-comments
no-double-slashes
as they’re neither invalid nor comments 🤷)The former group overlaps with validators whereas the latter does not. Like the rules that enforce (non-stylistic) conventions, the ones in the latter subgroup are mostly unique to Stylelint.
Additionally, we catch and surfaces broad syntax errors, e.g. unclosed blocks.
The complete list of our validating rules is:
annotation-no-unknown
at-rule-no-unknown
function-no-unknown
selector-pseudo-class-no-unknown
selector-pseudo-element-no-unknown
selector-type-no-unknown
media-feature-name-no-unknown
unit-no-unknown
color-no-invalid-hex
named-grid-areas-no-invalid
no-invalid-position-at-import-rule
string-no-newline
Of which, the following overlap with CSSTree:
at-rule-no-unknown
function-no-unknown
unit-no-unknown
color-no-invalid-hex
string-no-newline
Now that we have the lay of the land, let’s decide on a clear vision for validation.
I think we have three options:
*-no-unknown
and*-no-invalid
onesFor the first two, we’d need to improve our documentation to better explain linters and validators, and how Stylelint can be used with a validator like CSSTree.
There are pros and cons to all three approaches, for example:
Based on how often people open property/value pair validation issues in our tracker, I feel users are expecting this feature. Especially as some CSS-in-JS libraries like vanilla-extract now support this (via the CSSType library).
What do people think?
It’s a big topic and one that may refine the direction of Stylelint. So let’s leave this issue open as a discussion for a while so that we can stew on it.
SGTM.
I agree. It feels like the pros outweigh the cons, though. Unless anyone knows of an alternative, we can use the CSSTree within the rule for now. We can refactor the implementation if a more appropriate library comes along (or if we end up rolling our own).
I believe the CSSTree parser returns everything we need, including what we need for accurate positions (i.e.
mismatchOffset
andmismatchLength
):We’ll want to limit the scope of the rule compared to the plugin, e.g. the rule should only check standard CSS for unknown values within properties. We should silently catch all other errors the parser throws, including the error for unknown properties so that the rule doesn’t overlap with our existing
property-no-unknown
one.We may also want to limit our
unit-no-unknown
andfunction-no-unknown
rules to at-rules params so that they won’t overlap with this new rule.declaration-property-value-no-unknown
true
ignoreProperties: []
ignoreValues: []
propertiesSyntax: {}
typesSyntax: {}
Unexpected unknown value "${value}" for property "${property}"
propertiesSyntax
andtypesSyntax
secondary options to alter the syntax.”I’ve labelled the issue as ready to implement. Please consider contributing if anyone fancies giving this ago.
There are steps on how to add a new rule in the Developer guide.