Using JSLint from gedit in Ubuntu 10.10

I tend to use gedit as my editor for most of my development work as it has a great number of plugins that enhance it’s ability as an IDE. Some of the plugins I find most useful include Code Comment, External Tools, Save without trailing space, Session Saver, Symbol Browser, TabSwitch and Word Completion.

One thing I thought would be really useful would be to validate my JavaScript using JSLint from within the editor, rather than manually or via a build process. It seems a few other people have had the same idea but the plugin I found didn’t seem to work and other instructions (e.g. here) generally seemed to require SpiderMonkey which didn’t seem to be in the Ubuntu repositories (not that I looked very hard).

I worked out how to do it myself by using the instructions other people had used and came up with the following:

  1. Install Rhino (sudo apt-get install rhino)
  2. Download the Rhino version of JSLint (details here)
  3. Enable the External Tools plugin for gedit (Edit->Preferences->Plugins)
  4. Setup a new External Tool in gedit (Tools->Manage External Tools) with the following (or similar) settings:

    • Command: js /home/garethj/.gnome2/gedit/plugins/jslint.js $GEDIT_CURRENT_DOCUMENT_PATH
    • Shortcut Key: <Control>j
    • Save: Current document
    • Input: Nothing
    • Ouput: Display in bottom pane

Then all you need to do is open a JavaScript file and hit Ctrl+j. Here it is in action:

Worth noting that it should be possible to do this without having to save the document and actually pipe the current document content into JSLint/Rhino but this was sufficient for my needs.

Advertisements

8 thoughts on “Using JSLint from gedit in Ubuntu 10.10

  1. This is awesome. I still couldn’t get to run JSLint, but this one – $GEDIT_CURRENT_DOCUMENT_PATH – helped me to run php -l when i had no clue at all. Now again gonna try running JSLint. Keep up the good work Ubuntu buddy. šŸ˜€

  2. i have troubles to get jslint (or jshint) to work with gedit. i had it working and now it just reports “done”, but no information about problems (of which some are present in the code).
    i tried the installation method described here and the one in
    https://github.com/Kilian/gedit-jslint
    neither works. i use ubuntu 11.04 and gedit 2.30.4.
    thank you for help!
    andrew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s