I have seen other text editors use extensions to allow syntax checkers such as JSLint, is this possible with Notepad++?
-
This isn't an answer but this code: (function() { if(!JSLINT(WScript.StdIn.ReadAll(),{passfail:false})) { var e; for(var i in JSLINT.errors) { e=JSLINT.errors[i]; WScript.StdOut.WriteLine('Lint at line '+(e.line+1)+' character '+(e.character+1)+': '+e.reason); WScript.StdOut.WriteLine(' '+(e.evidence||'').replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1")); } WScript.Quit(1); } }()); Is giving me this on Notepad++ console: > Lint at line 79 character 8: Stopping, > unable to continue. (39% scanned). > C:\Program Files\JSLint\jslint.js(4637, 17) > Microsoft JScript runtime error: > 'line' is null or not an – Juanra Dec 10 '09 at 14:44
3 Answers
I have managed to get two lint programs to run using the notepad++'s NppExec Plugin.
The NppExec plugin is usually installed by default and can be found under plugins -> NppExec. (Using NppExec 0.3 RC1 and Notepad++ 5.1+).
1) JSLint
first download the WSH version of jslint from http://www.jslint.com.
Modify the last part of the file as follows:
(function() {
if(!JSLINT(WScript.StdIn.ReadAll(),{passfail:false})) {
var e;
for(var i in JSLINT.errors) {
e=JSLINT.errors[i];
WScript.StdOut.WriteLine('Lint at line '+(e.line+1)+' character '+(e.character+1)+': '+e.reason);
WScript.StdOut.WriteLine(' '+(e.evidence||'').replace(/^\s*(\S*(\s+\S+)*)\s*$/,"$1"));
}
WScript.Quit(1);
}
}());
(Pre-modified version here)
This causes JSLint to output all of the errors, not just the first one.
Next, Notepad++'s NppExec doesn't allow the use of StdIn so I wrote a batch file to actually execute the command.
This also allowed me to add a config file that is inserted before all javascript files. The options can be seen here.
The batch file looks like this:
@copy /b "C:\Program Files\jslint\conf.txt"+%1 "C:\Program Files\jslint\lastoutput.txt" > temp.txt
@cscript /Nologo "C:\Program Files\jslint\jslint.js" < "C:\Program Files\jslint\lastoutput.txt"
You may need to modify the paths depending on where you put the jslint.js file. The conf.txt file looks like this:
/*jslint forin:true*/
Make sure there is no return carriage at the end of this line. If there is a return carriage all the lines counts will be off by one.
Finally, the command I entered into NppExec is:
"C:\Program Files\jslint\jslint.bat" "$(FULL_CURRENT_PATH)"
2) Javascript Lint
Javascript lint is a slightly less strict parser and was much easier to implement.
First grab a copy of the windows version from http://www.javascriptlint.com/download.htm and unzip it. Then the NppExec command is:
"C:\Program Files\JavascriptLint\jsl.exe" -conf "C:\Program Files\JavascriptLint\jsl.default.conf" -process "$(FULL_CURRENT_PATH)"
(note: Most instructions for Javascript Lint will say to add "pauseatend" to the end of the command, I found this caused problems in Notepad++ so I left it off)
Hope this helps someone,
Cheers,
Andy.

- 4,401
- 8
- 42
- 52
-
Thank you for the Javascript Lint reference. I like it much better than JSLint but most people tend to leave it out. – Gordon Tucker Jan 17 '10 at 04:09
-
Followed your instructions for JSLint and notepad++ and it worked. thanks. – N30 Jun 18 '10 at 20:33
-
Link for Javascript lint download is broken. it's: http://www.javascriptlint.com/download.htm – SimplGy Feb 15 '11 at 21:13
-
Thanks. For me NppExec plugin was not installed. I did Plugins->Plugin Manager-> Available and clicked on NppExec to install it. – B Seven Apr 26 '11 at 14:36
-
for javascript lint, dont forget to add the NppExec console output filter '%ABSFILE%(%LINE%): *' – peter Apr 17 '14 at 17:36
You may try JSLint Plugin for Notepad++:

- 1,179
- 2
- 12
- 15
-
11+1. You install this simply by downloading a DLL into the Notepad++ plugins directory. You immediately get JSLint, with a nice "options" dialog where you can customise the JSLint options, including changing the max number of errors that will be output. I really was up and running in less time than it took me just to **read** the [currently accepted answer](http://stackoverflow.com/questions/1046810/using-jslint-in-notepad/1046826#1046826). Let alone actually making all those edits to JS, config and batch files that it describes. – MarkJ Jun 03 '11 at 12:01
-
1
-
4FWIW, you don't have to manually install it any more - you can just select it from the list of available plugins. I love Notepad++'s plugin manager! see sshot @ http://i.imgur.com/Sap38.png – James Manning Jan 13 '13 at 17:00
-
Unfortunately, the plugin seems to be broken with the latest version of both JSLint (gives "Unknown exception" error dialog) and JSHint (gives "Invalid JSLint Script!" error dialog). Maybe I'm doing something wrong? – Wilson F Aug 17 '15 at 06:54
-
1
After you've installed the plugin you should go to:
Plugins -> JSLint -> JSLint options
and change "Choose JavaScript lint tool:" to JSHint.
JSHint gives alot less meaningless "errors".

- 320
- 3
- 14