简体   繁体   English

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

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

I got warning in jshint 我在jshint收到警告

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

I follows Nicholas Zakkas Maintainable javascript styles where there is no space after anonymous function. 我遵循Nicholas Zakkas可 维护的javascript样式,匿名函数后没有空格。 How to remove this warning in jshint? 如何在jshint中删除此警告?

.jshintrc .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
}

Normally you have error notices in the following form in your CLI: 通常,您在CLI中有以下表单中的错误通知:

[L426:C63] W030: Expected an assignment or function call and instead saw an expression. [L426:C63] W030:预期赋值或函数调用,而是看到一个表达式。

Now you can take that WXXX ID and add it to your options subobject. 现在,您可以将该WXXX ID添加到options子对象中。 Simply add 只需添加

"-WXXX" : true

for whatever notice you want to turn off. 无论你想要什么通知关闭。 Keep in mind that you only can turn off all notices of a type and no specific notices on specific lines or lines in only single files. 请记住,您只能关闭某个类型的所有通知,而不能仅关注单个文件中特定行或行的特定通知。 Still, you can add different tasks for different files and ignore different hints/notices that way. 不过,您可以为不同的文件添加不同的任务,并忽略不同的提示/通知。

Here's an example for grunt-contrib-jshint . 这是grunt-contrib-jshint的一个例子。 Note: site.scripts comes from a YAML file that holds the config. 注意: site.scripts来自保存配置的YAML文件。

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

The indent option used to force the white option on . 用于强制启用white选项indent选项 This is no longer the case in the most recent version. 在最新版本中不再是这种情况。

Try adding the following to your .jshintrc: 尝试将以下内容添加到.jshintrc:

"white": false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 未使用JSHint和RequireJS定义如何禁用警告“定义” - How to disable the warning 'define' is not defined using JSHint and RequireJS 如何在 Sublime 3 中禁用 jshint 缺少的“使用严格”语句? - How to disable the Missing "use strict" statement by jshint in Sublime 3? 如何让JSHint抱怨缺少函数参数? - How do I make JSHint complain about missing function parameters? 如何在JSHint中禁用“use strict” - How to disable “use strict” in JSHint 导致JSHint警告的未知函数语法 - Unknown function syntax causing JSHint warning 将参数传递给命名函数jshint警告 - Passing arguments to named function jshint warning 如何清除以下错误的逃逸警告: <br\\> 在jshint中 - How to remove Bad Escaping warning for <br\> in jshint 警告带有主干的JSHint:预期分配或函数调用,而是看到一个表达式 - Warning JSHint with backbone : Expected an assignment or function call and instead saw an expression JSHint 警告“在循环内声明的函数引用外部 scope 变量可能会导致语义混淆”。 我怎样才能改进代码? - JSHint warning "Function declared within loop referencing an outer scope variable may lead to confusing semantics" . How can I improve the code? jshint根据函数是否无效给出“缺少分号”? - jshint gives “missing semicolon” or not based on whether the function is void?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM