From c10d16f678dba9c5e51b670fd6b011a7e2d72908 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20=C3=96sterberg?= Date: Fri, 12 Jun 2026 16:42:35 +0200 Subject: [PATCH] Report unknown custom properties/media as warning, not error 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. --- configurations/standard.json | 4 ++-- tools/update_stylelint.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/configurations/standard.json b/configurations/standard.json index 782d028..f2fc27f 100644 --- a/configurations/standard.json +++ b/configurations/standard.json @@ -156,14 +156,14 @@ "no-unknown-custom-media": [ true, { - "severity": "error", + "severity": "warning", "message": "Unknown custom media query \u201c%s\u201d" } ], "no-unknown-custom-properties": [ true, { - "severity": "error", + "severity": "warning", "message": "Unknown custom property \u201c%s\u201d" } ], diff --git a/tools/update_stylelint.py b/tools/update_stylelint.py index b30b1f4..11c8a9f 100644 --- a/tools/update_stylelint.py +++ b/tools/update_stylelint.py @@ -43,6 +43,14 @@ def update_stylelint_rules(): break if 'no-unknown' in rule_name: + # Unknown custom properties/media reference values that are + # frequently defined where static analysis can't see them (set at + # runtime via JS, in inline style attributes, on a page that wasn't + # crawled, or built at compile time by PostCSS). A missing one + # degrades gracefully to the initial/inherited value rather than + # producing invalid CSS, so report it as a warning, not an error. + if rule_name in ('no-unknown-custom-properties', 'no-unknown-custom-media'): + rule_config["severity"] = "warning" rules[rule_name] = [rule_enable, rule_config] elif 'no-deprecated' in rule_name: rule_config["severity"] = "warning"