Report unknown custom properties/media as warning, not error#151
Merged
Conversation
no-unknown-custom-properties and no-unknown-custom-media assert that a referenced custom property/media query is defined nowhere. Static analysis of the CSS captured from a single crawled page can't see definitions set at runtime via JS, in inline style attributes, on a page that wasn't crawled, or produced at build time by PostCSS, so error severity yields frequent false positives. A missing custom property also degrades gracefully to the initial/inherited value rather than producing invalid CSS. Downgrade both to warning so they stay visible without counting as standards errors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Downgrade
no-unknown-custom-propertiesandno-unknown-custom-mediafromerrortowarning.Why
Both rules assert a negative — that a referenced custom property / custom media query is defined nowhere. Unlike rules that detect genuinely malformed CSS (
property-no-unknown,color-no-invalid-hex, …), this can't be verified by static analysis of the CSS captured from a single crawled page. Custom properties are legitimately defined in places the linter never sees:element.style.setProperty('--x', …)) — common for theming / dark mode,style="--x: …"attributes,:root/section block on a page that wasn't the one crawled,A missing custom property also degrades gracefully —
var(--undefined)with no fallback becomes invalid-at-computed-value-time and falls back to the initial/inherited value, rather than producing invalid CSS. That is warning-shaped, not error-shaped.Real example that prompted this: https://tillvaxtverket.se references four
--lp-filterable-list__control--*theming hooks it never defines. The page renders fine (the inputs just use default styling), but the finding was reported aserror(fel) and pulled down the standards grade.Notes
configurations/standard.jsonis generated, so the change is intools/update_stylelint.py; the regeneratedstandard.jsonis included and is byte-identical to a fresh run against the pinned stylelint 17.12.0.no-unknown-*rules stay aterror.