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:
- Install Rhino (
sudo apt-get install rhino) - Download the Rhino version of JSLint (details here)
- Enable the External Tools plugin for gedit (Edit->Preferences->Plugins)
-
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
- Command:
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.
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.
Glad it helped! Let me know if you need any more details to get JSLint working.
Hi, unfortunately it seems as if the whole /rhino directory is missing from jslint.com – could you post the rhino jslint version somewhere?
Hey Oliver. Not sure what’s happened to that rhino directory, but the JSLint code appears to now be hosted on github: https://github.com/douglascrockford/JSLint
One of those versions may work with Rhino. Failing that, there’s always the Wayback Machine: http://web.archive.org/web/20070627170950/http://www.jslint.com/rhino/jslint.js
Thanks gareth, it has been very useful!
Nice, thanks!
great solution!
you may want to have a look at
this additional tipps
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