简体   繁体   English

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

[英]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.

相关问题 angular 2 package.json文件的解释 - Explanation for angular 2 package.json file package.json中Angular 2到4迁移的更改 - Changes in package.json for Angular 2 to 4 migration 在VSCode中,如何为没有package.json的项目启用Angular / Backbone / jQuery intellisense? - In VSCode, How can I enable Angular/Backbone/jQuery intellisense for a project without a package.json? Angular 项目构建具有更高版本的清晰度,即 4 ,它可以包含在使用较低版本清晰度的平台 package.json 中,即 1.3 - Angular project build with higher version of clarity ie 4 , can it be included in a platform package.json which uses lower version of clarity ie 1.3 将 package.json 中的版本更新为与 POM 中的 project.version 相同 - update version in package.json to be the same as project.version in POM 创建package.json时出现角度EACCESS错误 - yo angular EACCESS error when creating package.json angular2 中的 package.json 是否需要以任何方式启动应用程序? - Is package.json in angular2 needed in any way to start the application? 完全相同的 package.json 文件在空的全新项目中有效,但在旧项目中无效 - Same exact package.json file works in empty brand new project but doesn't in old project 从依赖项从package.json移到bower.json后,Angular无法识别jQuery - Angular not recognizing jQuery after dependency move from package.json to bower.json bower.json和package.json插值 - bower.json and package.json interpolation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM