I Googled for npm packages that check JS syntax and came across a package called syntax-checker [1] which checks several languages. I looked at the source and found the lines where it checks the syntax of each language [2]. For languages other than JS, it just uses the interpreter/compiler with a flag passed to it. However, for JS, it passes the file to UglifyJS [3] and redirects its output to /dev/null. Presumably, UglifyJS complains when it sees invalid JS.
Probably not the best way to do it, but certainly a solution.
[1] https://github.com/xianhuazhou/syntax-checker/ [2] https://github.com/xianhuazhou/syntax-checker/blob/c68c562d8/lib/syntax-chec... [3] https://github.com/mishoo/UglifyJS2
-- Vivek Ghaisas polybuildr