JSHINT:如何禁用警告匿名'功能'

JSHINT: how to disable the warning Missing space after anonymous 'function'

本文关键字:功能 何禁用 警告 JSHINT      更新时间:2023-09-26

我在jshint中收到警告

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

I遵循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
}

通常在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" ]
    }
}

用于强制开启white选项的indent选项。在最新版本中不再是这种情况。

尝试在.jshintrc中添加以下内容:

"white": false