如何将全局配置传递给jshint?

11

我如何将全局配置传递给jshint?我在文档中没有找到答案。

我的配置文件:

>type tests\jshint_options.js
/*jshint globalstrict:true */

这是我迄今为止尝试过的:

>jshint myfile.js --config=tests\jshint_options.js
myfile.js: line 1, col 1, Use the function form of "use strict".
myfile.js: line 4, col 24, Unescaped '['.
myfile.js: line 4, col 49, Unescaped '['.

3 errors

>jshint myfile.js --config tests\jshint_options.js

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
SyntaxError: Unexpected end of input
    at Object.parse (native)
    at _loadAndParseConfig (C:\Users\RONG\AppData\Roaming\npm\node_modules\jshint\lib\cli.js:28:18)
    at Object.interpret (C:\Users\RONG\AppData\Roaming\npm\node_modules\jshint\lib\cli.js:114:22)
    at Object.<anonymous> (C:\Users\RONG\AppData\Roaming\npm\node_modules\jshint\bin\hint:2:25)
    at Module._compile (module.js:441:26)
    at Object..js (module.js:459:10)
    at Module.load (module.js:348:31)
    at Function._load (module.js:308:12)
    at Array.0 (module.js:479:10)
    at EventEmitter._tickCallback (node.js:192:40)

>

FYI,已经开了一个问题来记录这个:https://github.com/jshint/jshint/issues/483 - ripper234
1个回答

10

经过多次查找,我发现这篇有用的博客文章揭示了...

配置文件采用JSON格式,而不是javascript注释!

{
    "supernew": true
}

P.S.

实际上这在 nodejs-jshint 文档中有记录!不确定为什么我之前没有找到。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接