(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);
}
}());
(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);
}
}());
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:
(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)
发布评论
评论(3)
我已经设法使用 notepad++ 的 NppExec 插件。
NppExec 插件通常是默认安装的,可以在插件 -> 下找到。 NppExec。 (使用 NppExec 0.3 RC1 和 Notepad++ 5.1+)。
1) JSLint
首先从 WSH 版本的 jslint href="http://www.jslint.com" rel="noreferrer">http://www.jslint.com。
修改文件的最后部分如下:
(此处为修改前的版本)< br>
这会导致 JSLint 输出所有错误,而不仅仅是第一个错误。
接下来,Notepad++ 的 NppExec 不允许使用 StdIn,所以我编写了一个 批处理文件实际执行命令。
这还允许我添加一个配置文件,该文件插入在所有 javascript 文件之前。 这些选项可以在此处查看。
批处理文件如下所示:
您可能需要根据放置 jslint.js 文件的位置修改路径。
conf.txt 文件如下所示:
确保在此行的末尾。 如果有回车,则所有行数都会减一。
最后,我在 NppExec 中输入的命令是:
2) Javascript Lint
Javascript lint 稍微不那么严格解析器并且更容易实现。
首先从 http://www.javascriptlint.com/download.htm 并解压它。
那么 NppExec 命令是:(
注意:大多数 Javascript Lint 指令都会说在命令末尾添加“pauseatend”,我发现这会在 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+).
1) JSLint
first download the WSH version of jslint from http://www.jslint.com.
Modify the last part of the file as follows:
(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:
You may need to modify the paths depending on where you put the jslint.js file.
The conf.txt file looks like this:
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:
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:
(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.
您可以尝试 Notepad++ 的 JSLint 插件:
https://sourceforge.net/projects/jslintnpp/
You may try JSLint Plugin for Notepad++:
https://sourceforge.net/projects/jslintnpp/
安装插件后,您应该转到:
插件 -> JSLint -> JSLint 选项
并将“选择 JavaScript lint 工具:”更改为 JSHint。
JSHint 给出了很多无意义的“错误”。
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".