我的意思是像这样运行它:
node.exe lint.js my_js_file.js
然后输出到控制台.
我需要下载什么?我是否只需要保存http://www.jslint.com/
到磁盘然后获取一些附加的js文件,或者我需要为node.js寻找特殊版本?
jshint
全局安装然后您可以从命令行使用它.
npm install -g jshint jshint testfile.js
所有这一切都假设您已经拥有node
并npm
运行在Windows机器上.
编辑
我只是注意到我回答了一个答案jshint
而不是jslint
,正如另一个答案所指出的那样,它们相似但不一样.我的答案适用于两者.
用于jslint
:
npm install -g jslint jslint testfile.js
March的回答是针对jsHint的.jsLint的微小变化,带有"L",如果这正是你想要的.
这是Ubuntu的一个不错的指南.大多数翻译:http: //blog.simplytestable.com/installing-jslint-for-command-line-use-on-ubuntu/
因此,一旦安装了节点,就可以执行以下操作:
C:\Users\YourName>mkdir C:\usr\share\node-jslint C:\Users\YourName>cd C:\usr\share\node-jslint C:\usr\share\node-jslint>npm install jslint npm http GET https://registry.npmjs.org/jslint npm http 200 https://registry.npmjs.org/jslint npm http GET https://registry.npmjs.org/jslint/-/jslint-0.2.10.tgz npm http 200 https://registry.npmjs.org/jslint/-/jslint-0.2.10.tgz npm http GET https://registry.npmjs.org/nopt npm http 200 https://registry.npmjs.org/nopt npm http GET https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz npm http 200 https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz npm http GET https://registry.npmjs.org/abbrev npm http 200 https://registry.npmjs.org/abbrev npm http GET https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz npm http 200 https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz jslint@0.2.10 node_modules\jslint +-- nopt@1.0.10 (abbrev@1.0.4)
请注意,我从Ubuntu方向借用了我的C:\
驱动器的路径.您可以将jslint模块放在任何您想要的位置.只需确保在下面的jslint调用中更改路径.
现在我可以使用我安装的jslint模块对任何我想要的文件运行jslint.我为了好玩而下载了jQuery development 1.11,并将其保存到了c:\temp\jquery-1.11.0.js
.让我们来jslint吧.
C:\usr\share\node-jslint>node C:/usr/share/node-jslint/node_modules/jslint/bin/jslint.js c:\temp\jquery-1.11.0.js c:\temp\jquery-1.11.0.js #1 Expected exactly one space between 'function' and '('. (function( global, factory ) { // Line 15, Pos 10 #2 Unexpected space between '(' and 'global'. (function( global, factory ) { // Line 15, Pos 12 #3 Unexpected space between 'factory' and ')'. (function( global, factory ) { // Line 15, Pos 28 #4 Use spaces, not tabs. if ( typeof module === "object" && typeof module.exports === "object" ) { // Line 17, Pos 1 ...
等等我在C:\usr\share\node-jslint
上面,但是我已经使用了完整的路径jslint.js
,所以我可以在任何地方使用相同的呼叫.
而且你是在发痒.