Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Handle caught 'SyntaxError' errors #163

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ module.exports = options => ({
)
return extractedCSS
} catch (e) {
const name = e.name
// incorrect interpolations will throw CssSyntaxError and they'll be handled by stylelint
if (e.name === 'CssSyntaxError') {
throw e
}
if (name === 'SyntaxError') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a comment above here would be awesome too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will add a comment and update PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericberens By the way, how about checking e.name directly, without a new local variable declared?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, especially because we use e.name in the conditional above, that's odd and inconsistent

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it's necessary to even do the name === 'SyntaxError' check, will it be sufficient to just return input on all errors and let the stylelint engine process it?

return input
}
return ''
}
},
Expand Down