In this recipe, we'll make use of the contrib-jshint (0.11.1)
plugin to detect errors and potential problems in our JavaScript code. It is also commonly used to enforce code conventions within a team or project. As can be derived from its name, it's basically a Grunt adaptation for the JSHint tool.
In this example, we'll work with the basic project structure we created in the Installing Grunt on a project recipe in Chapter 1, Getting Started with Grunt. Be sure to refer to it if you are not yet familiar with its contents.
The following steps take us through creating a sample JavaScript file and configuring a task that will scan and analyze it using the JSHint tool.
We'll start by installing the package that contains the
contrib-jshint
plugin as per the instructions provided in the Installing a plugin recipe in Chapter 1, Getting Started with Grunt.Next, we'll create a sample JavaScript file called
main.js
in thesrc
directory, and add the...