Over a million developers have joined DZone.

Easy Lint Check for JavaScript

DZone 's Guide to

Easy Lint Check for JavaScript

· Web Dev Zone ·
Free Resource

I'm introducing lint checking on one of my projects, because it didn't have a build process yet and I love this as a great place to start. Oh, and because we managed to commit broken syntax! So I set up a php lint job (I will share my travis config in another post) and tried to work out doing the same thing for JavaScript.

So it turns out that JSLint is really chatty and opinionated, and JSHint is almost as bad; I really only want to know if this JS is syntactically correct and I am not sure that I could care any less than this about whether the bracket or space characters are pleasing to the parser. I moaned on twitter (I know, shocking!) and got a few pointers - one really useful tip in particular:

On closer inspection this is a pretty nice set of tools for exactly what I wanted to do (and many other things besides). Even better, I found that there is a super-simple grunt task available to wrap Esprima and validate Javascript: grunt-jsvalidate. I don't write much client-side JS but this does seem to be doing the trick on my project and it wasn't as easy to find as I expected so I thought I'd mention it here in the hope that the next person searching for a simple way to check that their JavaScript is syntax-valid will find this rather than having to moan on twitter :)

If you're using this or other tools, I'm interested to hear about it so please share in the comments!


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}