[英]JSHint ignore `!function(){ /* … */ }()` pattern
How can I configure JS Hint to ignore JSHint ignore !function(){ /* ... */ }()
pattern. 如何配置JS Hint忽略JSHint ignore
!function(){ /* ... */ }()
模式。 Currently, it is throwing warnings for me to tell me it expects a statement or assignment. 目前,它向我发出警告,告诉我它需要一份声明或作业。 I expect this is due to
!function
converting the function into a function expression, which goes nowhere. 我希望这是由于
!function
将函数转换为函数表达式,这无处可去。 I know I could do... var garbage = !function ...
but I don't want to change the source code to please JS Hint, I want to tell JS Hint that it is ok to use an operator to coerce a function into an expression. 我知道我可以做...
var garbage = !function ...
但我不想更改源代码以取悦JS Hint,我想告诉JS Hint可以使用运算符来强制执行函数表达。
You can disable it. 你可以禁用它。 Put this at the beginning of the file or add the
expr
option to your .jshintrc
configuration. 将它放在文件的开头,或者将
expr
选项添加到.jshintrc
配置中。
/*jshint expr:true */
This option allows any raw expression such as: 此选项允许任何原始表达式,例如:
!function(){}();
a || b();
a ? b() : c();
You'd write it like this to avoid the warning: 你这样写是为了避免警告:
(function(){}());
if (!a) b();
if (a) {
b();
} else {
c();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.