Now that we have a fledgling extension, we may want to remove any extraneous code or potential errors. A common way to do this is to use a lint program (that is, a program designed to find suspicious language usage). This recipe will examine how we can use JSHint
to find errors in our extension.
Install JSHint (http://www.jshint.com/install/). If you already have NodeJS and npm
set up, you can just install it by running the following command:
npm install jshint
Note
It may be necessary to install JSHint globally (rather than locally, which is the default method). To install JSHint globally, run the following command:
npm install jshint -g
It is also possible to avoid installing JSHint entirely by using the JSHint website at http://www.jshint.com.
Run JSHint using the following command:
jshint myExtension.js
Correct the errors/warnings listed.