Fix `custom-property-no-missing-var-function` false positives for properties that can contain author-defined identifiers
See original GitHub issueWhat is the problem you’re trying to solve?
Thanks to the CSS Houdini API, the property name of a custom property could appear in the value of some declarations, such as transition
(or more precisely, transition-property
). However, the current custom-property-no-missing-var-function
rule will report errors for these custom property names that are not wrapped in var()
.
What solution would you like to see?
One possibility is to not report transition
, etc. by default, but this could also produce breaking changes.
It is also possible to add options to the rule to ignore certain property names, as we did in property-no-vendor-prefix
.
module.exports = {
rules: {
'custom-property-no-missing-var-function': [true, { ignoreProperties: ['transition', 'transition-property'] }],
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Fix declaration-block-no-redundant-longhand-properties false ...
There's no error for this case because there are longhand properties with inherit value. Per MDN. Only the individual properties values can ......
Read more >False positives and semantic versioning
It performs a recursive comparison of two object graphs. To determine which properties have to be included in the comparison, by default it's ......
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 FreeTop 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
Top GitHub Comments
Sorry, I missed this.
Yes, that was the original reason for limiting this rule to defined custom properties. However, we didn’t consider the scenario where a custom property is defined but intentionally not used in a
var()
.Thanks for drawing up the list in https://github.com/stylelint/stylelint/issues/5742#issuecomment-981352174. Ideally, we’d ignore just the
<custom-ident>
slot of these properties, but that’s tricky to do with our current parser. I suggest we ignore the properties outright to avoid these false positives and then document this limitation, e.g. “This rule does not check properties which can contain author-defined identifiers”.As a side note, I found that almost all user-defined at-rules in the CSS standard support the
<custom-ident>
identifier, such as@keyframes
and@counter-style
, which leads to a number of properties in addition totransition-property
that can actually pass custom property names that are not wrapped invar()
.As a possibly incomplete list, the properties I’ve gathered so far are as follows:
animation
, exactlyanimation-name
counter-reset
andcounter-increment
grid-row-start
,grid-row-end
,grid-column-start
andgrid-column-end
. This also means thatgrid-row
andgrid-column
list-style
, exactlylist-style-type
transition
, exactlytransition-property
will-change
, as a closely related one totransition-property
For these properties, I think the more common use case is probably still custom properties wrapped in
var()
. So I suspect that ignoring them by default may not be appropriate, and perhaps an option approach would be a better choice.As a rough design, perhaps we could provide
{ "ignoreCustomIdent": true }
as an option, but it would be more difficult to implement. ProvidingignoreProperties
is probably the most cost effective option.