Zeus + JSHint (JavaScript Linter)

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Zeus + JSHint (JavaScript Linter)

Post by jussij »

The JSHint utility is a static code analysis tool for JavaScript, designed to detect errors and potential problems in JavaScript code and to enforce coding conventions.

The default Zeus installation already comes configured for JSLint but it is also possible to configure Zeus to use JSHint as well.

Below are the steps needed to do this configuration.

1. Since JSHint requires Node.js, if you don't have Node.js installed, you will need to do that first of all.

You can download the Node.js installer from here: https://nodejs.org/en/download/

2. Run the installer and make sure you select the option to add it to the PATH.

3. Start a new Zeus instance and use the Tools, Dos Command Line to open up a command prompt.

Run this command:

Code: Select all

npm install jshint -g
That should result in the following output:

Code: Select all

D:\Temp>npm install jshint -g
C:\Users\<Current User>\AppData\Roaming\npm\jshint -> C:\Users\<Current User>\AppData\Roaming\npm\node_modules\jshint\bin\jshint
jshint@2.9.1-rc2 C:\Users\<Current User>\AppData\Roaming\npm\node_modules\jshint
+-- strip-json-comments@1.0.4
+-- exit@0.1.2
+-- shelljs@0.3.0
+-- lodash@3.7.0
+-- console-browserify@1.1.0 (date-now@0.1.4)
+-- cli@0.6.6 (glob@3.2.11)
+-- minimatch@2.0.10 (brace-expansion@1.1.2)
+-- htmlparser2@3.8.3 (domelementtype@1.3.0, entities@1.0.0, domhandler@2.3.0, readable-stream@1.1.13, domutils@1.5.1)
If you fail to see that output it means your Node.js installation is incorrect or is not in the PATH.

4. Use the Zeus Options, Document Types menu to edit the JScript document type.

5. Move to the Compiler section of the document type and make the following changes.

Change the Command Line to this:

Code: Select all

jshint "$fn"
Change the Errors Regex to be this:

Code: Select all

line [0-9]+, col [0-9]+
Note: More JSHint command line options can be found here: http://jshint.com/docs/

That is all that is required as per the configuration. To check that everything is working run the following test.

1. Create a test.js file containing the following code:

Code: Select all

function main(a, b) {
  return a == null;
}
2. With the test.js file as the active document use the Zeus Compiler, Compile menu to syntax check the file.

This should result in the following error output being displayed:
js_error.png
js_error.png (13.99 KiB) Viewed 27289 times
Click on the error shown above and you will be returned to the line at fault in the test.js file.

Cheers Jussi.
Post Reply