Skip to content

Commit

Permalink
Merge pull request #164 from postcss/skip-comments
Browse files Browse the repository at this point in the history
Skip comments between imports
  • Loading branch information
MoOx committed Jan 27, 2016
2 parents 8f8f11d + 488dc27 commit b109e73
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit b109e73

Please sign in to comment.