From b2a03534cc3e5ce4de3b2fe83c8cb668d5ec8b95 Mon Sep 17 00:00:00 2001 From: Hugo Peek Date: Sat, 17 Jun 2023 07:37:00 +0000 Subject: [PATCH 1/2] Ignore CSS variables --- src/CssLint/Linter.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/CssLint/Linter.php b/src/CssLint/Linter.php index 53b9828..88c7b81 100644 --- a/src/CssLint/Linter.php +++ b/src/CssLint/Linter.php @@ -386,9 +386,15 @@ protected function lintPropertyNameChar(string $sChar): ?bool } if ($sChar === ':') { - // Check if property name exists $sPropertyName = trim($this->getContextContent()); + // Ignore CSS variables (names starting with --) + if (substr($sPropertyName, 0, 2) === '--') { + $this->setContext(self::CONTEXT_PROPERTY_CONTENT); + return true; + } + + // Check if property name exists if (!$this->getCssLintProperties()->propertyExists($sPropertyName)) { $this->addError('Unknown CSS property "' . $sPropertyName . '"'); } From 0ad42300d4e724931d5501e341bb0c9f6995792e Mon Sep 17 00:00:00 2001 From: Hugo Peek Date: Sat, 17 Jun 2023 07:42:42 +0000 Subject: [PATCH 2/2] Add CSS variable to valid.css test file --- tests/_files/valid.css | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/_files/valid.css b/tests/_files/valid.css index b8e58d8..fb399c3 100644 --- a/tests/_files/valid.css +++ b/tests/_files/valid.css @@ -1,4 +1,8 @@ -.button.drodown::after { +:root { + --border-radius: 3px; +} + +.button.dropdown::after { display: block; width: 0; height: 0; @@ -7,6 +11,7 @@ border-bottom-width: 0; border-top-style: solid; border-color: #fefefe transparent transparent; + border-radius: var(--border-radius); position: relative; top: 0.4em; display: inline-block;