Skip to content

Commit 3c1abcb

Browse files
committed
fix(lint): support semicolon in import url
Signed-off-by: Emilien Escalle <[email protected]>
1 parent 54e25e9 commit 3c1abcb

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/CssLint/Linter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ protected function lintImportChar(string $charValue): ?bool
505505
if ($this->assertContext(self::CONTEXT_SELECTOR) && str_starts_with($this->getContextContent(), '@import')) {
506506
$this->addContextContent($charValue);
507507

508-
if ($charValue === ';') {
508+
if ($charValue === ';' && $this->assertPreviousChar(')')) {
509509
$this->resetContext();
510510
return true;
511511
}

tests/TestSuite/LinterTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,20 @@ public function testLintValidImportRule()
201201
$this->linter->lintString("@import url('https://fonts.googleapis.com/css2?family=Poppins&display=swap');"),
202202
print_r($this->linter->getErrors(), true)
203203
);
204+
205+
$this->assertTrue(
206+
$this->linter->lintString("@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:ital,wght@0,300;0,400;0,700;1,300;1,400;1,700&display=swap');"),
207+
print_r($this->linter->getErrors(), true)
208+
);
209+
}
210+
211+
public function testLintNotValidImportRule()
212+
{
213+
$this->assertFalse(
214+
$this->linter->lintString("@import url('"),
215+
);
216+
$this->assertSame([
217+
'Unterminated "selector" (line: 1, char: 13)',
218+
], $this->linter->getErrors());
204219
}
205220
}

0 commit comments

Comments
 (0)