JSHINT:匿名'函数'后如何禁用警告缺少空格

时间:2013-04-27 14:28:47

标签: javascript jshint

我在jshint中收到警告

  '[L76:C24] Missing space after 'function''

我遵循 Nicholas Zakkas 可维护的javascript 样式,匿名函数后没有空格。如何在jshint中删除此警告?

.jshintrc

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

2 个答案:

答案 0 :(得分:8)

通常,您在CLI中有以下表单中的错误通知:

  

[L426:C63] W030:预期分配或函数调用,而是看到一个表达式。

现在,您可以获取该WXXX ID并将其添加到options子对象中。只需添加

"-WXXX" : true

无论你想要关闭什么通知。请记住,您只能关闭某个类型的所有通知,而不能仅关注单个文件中特定行或行的特定通知。不过,您可以为不同的文件添加不同的任务,并忽略不同的提示/通知。

以下是grunt-contrib-jshint的示例。注意:site.scripts来自保存配置的YAML文件。

jshint : {
    dev : {
        options : {
            // Ignore: "Bad" line break
            "-W014" : true
        },
        src: [ "<%= site.scripts %>/**/*.js" ]
    }
}

答案 1 :(得分:3)

indent option used to force the white option on。在最新版本中不再是这种情况。

尝试将以下内容添加到.jshintrc:

"white": false
相关问题