From bb13123114fdee5c1e2ffc03e2861cdcec4d7316 Mon Sep 17 00:00:00 2001 From: Prithvi Raju M Date: Mon, 23 Jan 2017 00:29:44 +0530 Subject: [PATCH 1/3] Capture the CssSyntaxError object and throw error. --- src/babel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/babel.js b/src/babel.js index 8303e1b..efe399d 100644 --- a/src/babel.js +++ b/src/babel.js @@ -101,7 +101,7 @@ export default function ({types: t}) { .catch(resolved) loopWhile(() => wait) - if (css instanceof Error) { + if (css instanceof Error || css.name === 'CssSyntaxError') { throw css } From e557777e8a052ecc31f01d5c6251a4f831e4b811 Mon Sep 17 00:00:00 2001 From: Prithvi Raju M Date: Wed, 1 Feb 2017 22:38:57 +0530 Subject: [PATCH 2/3] Add a basic syntax error test. --- test/fixtures/syntax-error.js | 13 +++++++++++++ test/index.js | 5 +++++ 2 files changed, 18 insertions(+) create mode 100644 test/fixtures/syntax-error.js diff --git a/test/fixtures/syntax-error.js b/test/fixtures/syntax-error.js new file mode 100644 index 0000000..acf95f4 --- /dev/null +++ b/test/fixtures/syntax-error.js @@ -0,0 +1,13 @@ +const color = 'red' + +export default () => ( +
+

test

+ +
+) \ No newline at end of file diff --git a/test/index.js b/test/index.js index 425ca18..3f39685 100644 --- a/test/index.js +++ b/test/index.js @@ -7,3 +7,8 @@ test('applies plugins', async t => { const out = await read('./fixtures/basic.out.js') t.is(code, out.trim()) }) + +test('check syntax', async t => { + const error = await t.throws(transform('./fixtures/syntax-error.js')) + t.is(error.name, 'CssSyntaxError') +}) From 87978dd0bd5a1fb1f4612c20577fdc3b3f86ab33 Mon Sep 17 00:00:00 2001 From: Prithvi Raju M Date: Sun, 21 May 2017 17:47:16 +0530 Subject: [PATCH 3/3] add newline at EOF. --- test/fixtures/syntax-error.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fixtures/syntax-error.js b/test/fixtures/syntax-error.js index acf95f4..09ad20e 100644 --- a/test/fixtures/syntax-error.js +++ b/test/fixtures/syntax-error.js @@ -10,4 +10,4 @@ export default () => ( } `} -) \ No newline at end of file +)