Skip to content

Commit 86ccbdb

Browse files
committed
BREAKING: CssSyntaxError in imported file now throws instead of warns
Closes #264
1 parent a993d1a commit 86ccbdb

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

index.js

-4
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,6 @@ function resolveImportId(result, stmt, options, state) {
210210
return statements ? result.concat(statements) : result
211211
}, [])
212212
})
213-
.catch(err => {
214-
if (err.message.indexOf("Failed to find") !== -1) throw err
215-
result.warn(err.message, { node: atRule })
216-
})
217213
}
218214

219215
function loadImportContent(result, stmt, filename, options, state) {
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
body {
2+
bar: bar;
3+
qux: qux;
4+
5+
a {
6+
foo: foo;
7+
}

test/fixtures/syntax-error.css

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@import "syntax-error.css";
2+
3+
syntax.error {
4+
/* Error isn't here, it's in the imported file */
5+
color: green;
6+
}

test/syntax-error.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// builtin tooling
2+
import fs from "fs"
3+
4+
// external tooling
5+
import test from "ava"
6+
import postcss from "postcss"
7+
8+
// plugin
9+
import atImport from ".."
10+
11+
test("SyntaxError in imported file throws", t => {
12+
return postcss(atImport({ path: "test/fixtures/imports" }))
13+
.process(fs.readFileSync("test/fixtures/syntax-error.css", "utf8"))
14+
.then(() => t.fail("should error out"))
15+
.catch(err => t.truthy(err))
16+
})

0 commit comments

Comments
 (0)