Zeus + JSHint (JavaScript Linter)
Posted: Sun Jan 03, 2016 6:11 am
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:
That should result in the following output:
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:
Change the Errors Regex to be this:
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:
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: Click on the error shown above and you will be returned to the line at fault in the test.js file.
Cheers Jussi.
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
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)
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"
Code: Select all
line [0-9]+, col [0-9]+
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;
}
This should result in the following error output being displayed: Click on the error shown above and you will be returned to the line at fault in the test.js file.
Cheers Jussi.