将`jshint` worker添加到package.json的`scripts`中

时间:2016-08-26 14:21:56

标签: npm jsxhint

亲爱的stackoverflowers。

我决定将jshint包含到我的项目中,以帮助我检测JavaScript代码中的错误和潜在问题。我已经在项目的根目录下安装了它,我可以从控制台运行下一个代码:

Router.route('/patients/:_id', {
  layoutTemplate: 'ApplicationLayout',
  yieldRegions: {
    'single_patient': {to: 'content'}
  },
  waitOn: function () {
    return Meteor.subscribe('patients.single', this.params._id);
  }
  data: function () {
    return Patients.findOne({_id: this.params._id});
  },
});

它给我发了几个通知。

然后我jshint --config .jshintrc ./app/ 脚本`部分。它看起来像是:

v decided to create a special section inside my package.json

当我尝试运行时

  "scripts": {
    "jshint": "jshint --config .jshintrc ./app/"
  }

它给我一个例外......

enter image description here

1 个答案:

答案 0 :(得分:1)

请查看https://github.com/npm/npm/issues/6124,如果您使用以下||设置脚本,则可以防止此错误如下面的代码片段中那样真实

{
 "scripts": {
   "test": "jshint || true"
 }
}

在这种情况下,您的脚本将以退出代码= 0结束,而npm将不会抛出错误

相关问题