Question

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?

Was it helpful?

Solution

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 InvokeProcess workflow 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.

OTHER TIPS

If you want to check your Javascript while running a TFS build I would recommend having a look at sharplinter:

https://github.com/jamietre/SharpLinter

This contains a executable which allows you to check your Javascript files with JSLint/JSHint. To run this during your TFS build you could create a Code Activity which can be included into your workflow.

This video by Marcel de Vries from the Techdays 2012 goes through the automated build process step by step, and gives a demonstration on how to include your custom activity.

http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2361

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top