I have seen other text editors use extensions to allow syntax checkers such as JSLint, is this possible with Notepad++?
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+).
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)"
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.
You may try JSLint Plugin for Notepad++:
https://sourceforge.net/projects/jslintnpp/
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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With