[英]JSHint Inline Configuration issue
I am using jshint with grunt and using some inline configuration. 我使用带有grunt的jshint并使用了一些内联配置。 I am confused at the following.
我对以下感到困惑。 If I run jshint on just the below code.
如果我仅在以下代码上运行jshint。
/* jshint undef: false */
var app = foo;
/* jshint undef: true */
I would expect this to NOT return the error code W117 stating foo
is undefined, but it does for some reason. 我希望这不会返回错误代码W117,说明
foo
是未定义的,但是由于某些原因,它确实会发生。 It works if I leave out the last statement like so: 如果我省略最后一条语句,它会起作用:
/* jshint undef: false */
var app = foo;
Though this is not the behavior I want. 虽然这不是我想要的行为。 I only want jshint to ignore the undef warning for that one line.
我只希望jshint忽略该行的undef警告。
My options are below: 我的选择如下:
options:{
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
undef: true,
unused: 'vars',
globals: {
jQuery: false,
$: false
}
},
What am I doing wrong? 我究竟做错了什么?
Per ruffin's comment, I was calling foo elsewhere and causing the issue. Per ruffin的评论是,我在其他地方调用foo并导致了问题。 I decided to set foo to a global.
我决定将foo设置为全局变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.