package.json中的jshintConfig用于angular度项目

我正在尝试在package.json中configurationjshint。 我正在使用gulp,这是一个有angular度的项目。 我在package.json中添加了下面的代码

"jshintConfig":{ "globals":{ "angular": false } } 

但是,似乎jshint并没有拿起它。 我这样做是为了避免下面的错误,我正在运行jshint

 line 3 col 1 'angular' is not defined. 

并不是所有的编辑器都支持从package.json读取jshintconfiguration。

例如,请查看Atom的讨论 ,他们终于实现了它(开始时不支持它)。

我会邀请你将你的设置移动到package.json之外,并使用.jshintrc方法。 事实上,即使jshint本身正在使用这种方法,你可以在他们的回购看到。 .jshintrc更具dynamic性,因为您可以为每个文件夹放置不同的.jshintrc文件并微调您的设置(例如,unit testing文件夹的不同设置和客户端脚本的不同设置)。

它的一个例子是https://stackoverflow.com/a/26288458/1587329 ,它使用"angular": true 。 或者,您可以尝试使用

 "jshintConfig": { "predef": ["angular"] }