File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change 1- const postcss = require ( 'postcss' )
1+ const { parse } = require ( 'postcss' )
22const atRules = require ( './atrules' )
33const rules = require ( './rules' )
44const selectors = require ( './selectors' )
@@ -15,16 +15,18 @@ function processNodes(tree) {
1515
1616module . exports = async css => {
1717 try {
18- const result = await postcss . parse ( css )
18+ const result = await parse ( css )
1919 const rootNode = result . toResult ( ) . root
2020
2121 return Promise . resolve ( processNodes ( rootNode ) )
2222 } catch ( error ) {
23- const { source , line, column, reason} = error
23+ const { line, column, reason} = error
2424
2525 return Promise . reject (
2626 new SyntaxError (
27- `${ reason } at line ${ line } , column ${ column } . Source: ${ source } `
27+ `${ reason } at line ${ line } , column ${ column } :\n\n${ error . showSourceCode (
28+ false
29+ ) } `
2830 )
2931 )
3032 }
Original file line number Diff line number Diff line change @@ -31,6 +31,6 @@ test('parser throws a useful error on invalid CSS', async t => {
3131
3232 t . is (
3333 error . message ,
34- 'Unknown word at line 1, column 5. Source: a { color red }'
34+ 'Unknown word at line 1, column 5:\n\n> 1 | a { color red }\n | ^ '
3535 )
3636} )
You can’t perform that action at this time.
0 commit comments