Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/parse-statements.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ function parseMedia(result, atRule) {

function parseImport(result, atRule) {
var prev = atRule.prev()
while (prev && prev.type === "comment") {
prev = prev.prev()
}
if (prev) {
if (
prev.type !== "atrule" ||
Expand Down
16 changes: 16 additions & 0 deletions test/lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ test("should warn when not @charset and not @import statement before", t => {
})
})

test("should not warn if comments before @import", t => {
return processor.process(`/* skipped comment */ @import "";`)
.then(function(result) {
const warnings = result.warnings()
t.is(warnings.length, 1)
t.is(warnings[0].text, `Unable to find uri in '@import ""'`)
})
})

test("should warn if something before comments", t => {
return processor.process(`a{} /* skipped comment */ @import "";`)
.then(function(result) {
t.is(result.warnings().length, 1)
})
})

test("should not warn when @charset or @import statement before", t => {
return Promise.all([
processor.process(`@import "bar.css"; @import "bar.css";`, {
Expand Down