Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Using JSHint with Geany

b_b edited this page Apr 27, 2014 · 4 revisions

A tutorial how to install and use JSHint with JavaScript file within Geany:

Installation

Ubuntu

We are going to run JSHint via Node.js. Everything is available to install through Ubuntu apt-get.

  1. Install Node.js & npm (Node Package Manager):
    $ sudo apt-get install nodejs npm
    
  2. Install jshint (via npm):
    $ sudo npm install jshint -g
    

Windows

On Windows, JSHint can run with built-in Windows Script Host so there are less things to prepare:

  1. Download JSHint source from Github
  2. Extract the files to a folder with short and easy access path. For example "C:\jshint". There should be "jshint.js" file and "env" folder inside.
  3. Download my WSH runner patch for Geany: wsh-geany.js and copy to the "env" folder in "C:\jshint".
    FYI, I have patched the wsh.js file in JSHint so that it generates output compatible with Geany's Error Regular Expression. You'll have the convenience of Geany jumping to the error line when click on the compile error output.

Set Up

Setup up custom build command in Geany for JavaScript file:

  • Make sure no project is opened (so that the settings will be applied globally)
  • Open any JavaScript file (*.js)
  • Go to menu Build > Set Build Commands
  • At JavaScript Commands, click on the first "Set menu item label" button, type in "JSHint"
  • For the command, type in:
    • Ubuntu/Linux: jshint %f
    • Windows: cscript C:\jshint\env\wsh-geany.js %f (assuming you place JSHint in suggested path above)
  • For the working directory, type in %d
    Build menu
  • To enable error highlight in source file, copy this pattern into "Error Regular Expression": (Same for Ubuntu & Windows)
    (.+):\ line\ ([0-9]+)
    
  • OK to apply and close the setting window

Usage

From now you can run JSHint on opening JavaScript file by clicking the Compile button on menu bar OR go to Build > JSHint OR press F8. The output will displayed at Compiler panel at the bottom.

JSHint Executed within Geany

NOTE: On some Ubuntu based systems JSHint will fail to execute, the output would be something like /usr/bin/env: node: No such file or directory. This is because the package manager installs the binary as /usr/bin/nodejs instead of /usr/bin/node, to fix this just run the following command in the terminal: $ ln -s /usr/bin/nodejs /usr/bin/node

Clone this wiki locally