Skip to content

Commit f5479b8

Browse files
committed
Skip comments between imports
1 parent 8f8f11d commit f5479b8

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/parse-statements.js

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ function parseMedia(result, atRule) {
7070

7171
function parseImport(result, atRule) {
7272
var prev = atRule.prev()
73+
while (prev && prev.type === 'comment') {
74+
prev = prev.prev();
75+
}
7376
if (prev) {
7477
if (
7578
prev.type !== "atrule" ||

test/lint.js

+16
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ test("should warn when not @charset and not @import statement before", t => {
2121
})
2222
})
2323

24+
test("should not warn if comments before @import", t => {
25+
return processor.process(`/* skipped comment */ @import "";`)
26+
.then(function(result) {
27+
const warnings = result.warnings();
28+
t.is(warnings.length, 1);
29+
t.is(warnings[0].text, `Unable to find uri in '@import ""'`);
30+
})
31+
});
32+
33+
test("should warn if something before comments", t => {
34+
return processor.process(`a{} /* skipped comment */ @import "";`)
35+
.then(function(result) {
36+
t.is(result.warnings().length, 1);
37+
})
38+
});
39+
2440
test("should not warn when @charset or @import statement before", t => {
2541
return Promise.all([
2642
processor.process(`@import "bar.css"; @import "bar.css";`, {

0 commit comments

Comments
 (0)