[英]jshintConfig in package.json for angular project
I am trying to configure jshint in package.json. 我正在尝试在package.json中配置jshint。 I am using gulp and this is an angular project.
我正在用gulp,这是一个有角度的项目。 I have added the below code in package.json
我在package.json中添加了以下代码
"jshintConfig":{
"globals":{
"angular": false
}
}
But it seems jshint is not picking it up. 但是,jshint似乎没有选择。 I did this to avoid the below error I was getting on running jshint
我这样做是为了避免在运行jshint时出现以下错误
line 3 col 1 'angular' is not defined.
Not all editors support reading jshint configuration from package.json. 并非所有的编辑器都支持从package.json读取jshint配置。
For example, check out this discussion for Atom in which they ended up implementing it after all (it wasn't supported in the beginning). 例如,查看有关Atom的讨论 ,最终他们最终实现了Atom (一开始不支持它)。
I would invite you to move your settings outside package.json and use the .jshintrc approach instead. 我邀请您将设置移到package.json之外,而改用.jshintrc方法。 In fact, even jshint itself is using that approach as you can see in their repo .
实际上,甚至jshint本身也在使用这种方法,如您在他们的repo中所见。 The .jshintrc is more dynamic, as you can place different .jshintrc files per folder and fine-tune your settings (eg different settings for your unit tests folder and different settings for your client side scripts).
.jshintrc更具动态性,因为您可以为每个文件夹放置不同的.jshintrc文件并微调您的设置(例如,单元测试文件夹的不同设置和客户端脚本的不同设置)。
An example of it working is at https://stackoverflow.com/a/26288458/1587329 , which uses "angular": true
. https://stackoverflow.com/a/26288458/1587329就是使用它的一个例子,它使用了
"angular": true
。 Alternatively, you can try to use 或者,您可以尝试使用
"jshintConfig": {
"predef": ["angular"]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.