I want to automatically run JSHINT on all my javascript files as part of our continuous integration environment (actually, probably as part of TFS Gated Checkin, but I’m not sure yet as it will depend on speed).
I tried using rhino-jshint like this:
java -jar js.jar jshint-rhino.js myFile.js
but how can I set the required JSHint options? I know I could list them in a comment at the top of myfile.js, but I’ve got lots of javascript files, and I don’t want the options duplicated in all my source files. (Or does JavaScript have an ‘include’ feature that I’m not aware of?)
I had hoped to pass an options.js file in as a parameter on the command line, and then keep options.js under version control. But I don’t think this is possible with jshint-rhino.js.
Additionally, we are using a Visual studio extension to ‘JSHint’ all JavaScript files as we save them. But this tool cannot be ran on the command-line. We want the best of both worlds – running JSHint inside Visual Studio and Automated for the CI build, and then without duplicating the options (and indeed keeping the options under version control).
So the question is, how do other people automate JSHint in their development process?
Since you are essentially wanting to use a command-line activity inside of the TFS 2010 build process, then it is actually pretty simple. You’ll want to add an
InvokeProcessworkflow activity (see MSDN documentation) at the point you want to run the tool.There is actually a walkthrough available for how to do this with a different command-line utility but you’ll just replace it with your own. The workflow activity even allows you to specify a set of command-line parameters that you can pass in.