开发者

Running JSLint from command prompt

开发者 https://www.devze.com 2023-04-12 10:56 出处:网络
I would like to run jsLint from the command prompt. At a later stage, as a task in an ANT build. I downloaded rhino 1.7 R3 and the latest jslint.js and wrote this custom test.js which contents is:

I would like to run jsLint from the command prompt. At a later stage, as a task in an ANT build.

I downloaded rhino 1.7 R3 and the latest jslint.js and wrote this custom test.js which contents is:

for (var i = 0; i < 10; i++)  { }

Notice that this single line of code should already cause js开发者_开发问答lint to warn:

Move 'var' declarations to the top of the function.

I used this command:

java -jar .\rhino1_7R3\js.jar .\douglascrockford-JSLint-e31fa4c\jslint.js .\test.js

Which ran for a couple of seconds and then finished without any output.

My question is -> Am I doing it right? What kind of output should I expect in case of an error?


You might find jslint4java useful as it has a command line interface, wrapping JSLint.


I don't know about Rhino etc, but when using JSLint in pure JS, it creates a JSLINT object, and you need to iterate through JSLINT.errors (which has methods JSLINT.errors[i].line, JSLINT.errors[i].reason, etc). Also, you have to pass your code as a string into the JSLINT function, not just run them both together.

0

精彩评论

暂无评论...
验证码 换一张
取 消