简体   繁体   中英

jshintConfig in package.json for angular project

I am trying to configure jshint in package.json. I am using gulp and this is an angular project. I have added the below code in package.json

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

But it seems jshint is not picking it up. I did this to avoid the below error I was getting on running jshint

line 3  col 1  'angular' is not defined.

Not all editors support reading jshint configuration from package.json.

For example, check out this discussion for Atom in which they ended up implementing it after all (it wasn't supported in the beginning).

I would invite you to move your settings outside package.json and use the .jshintrc approach instead. In fact, even jshint itself is using that approach as you can see in their 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).

An example of it working is at https://stackoverflow.com/a/26288458/1587329 , which uses "angular": true . Alternatively, you can try to use

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM