Javascript 在jshint中使用下划线

Javascript 在jshint中使用下划线,javascript,angularjs,jshint,Javascript,Angularjs,Jshint,我正在使用下划线库 我在运行jshint时得到以下信息: [L38:C38] W117: '_' is not defined. var approvedAndRequstedCount = _.countBy(products, function(obj) { 警告:任务“jshint:all”失败。使用--force继续 这是我的配置文件: { "node": true, "browser": true, "esnext": true, "bitwise": t

我正在使用下划线库

我在运行jshint时得到以下信息:

[L38:C38] W117: '_' is not defined.
      var approvedAndRequstedCount = _.countBy(products, function(obj) {
警告:任务“jshint:all”失败。使用--force继续

这是我的配置文件:

{
  "node": true,
  "browser": true,
  "esnext": true,
  "bitwise": true,
  "camelcase": false,
  "curly": true,
  "eqeqeq": true,
  "immed": true,
  "indent": 2,
  "latedef": true,
  "newcap": true,
  "noarg": true,
  "quotmark": "single",
  "regexp": true,
  "undef": true,
  "unused": true,
  "strict": true,
  "trailing": true,
  "smarttabs": true,
  "globals": {
    "angular": false
  }
}

我想这是有全球选项的吧?我试着加上“u”:假,但没有运气。有什么想法吗?

我也有这个问题

我安装了下划线:
bower安装-保存下划线
,它在代码中运行良好。不幸的是,jshint没有找到该引用。您必须在配置文件中告诉jshint您的全局变量:


如果仍然存在此问题,则需要确保在执行jshint时包含下划线。我不建议将-W117设置为true。压制这些错误可能会导致更多的错误。

“”:false
对我(在全局中)有效。哦!是的,我在主配置对象上还有一个
“-W117”:true
。W117:true解决了问题!谢谢。如果你发布一个带有简短解释的答案,我会同意。我不确定关闭W117是件好事。但这是一个解决办法。可能还不足以给出答案。这在使用lodash时也适用。这对我有用。
{
  …
  "globals": {
    "angular": false,
    "_": false
  }
}