有没有一种方法可以抑制给定行的JSHint警告? [英] Is there a way to suppress JSHint warning for one given line?

查看:65
本文介绍了有没有一种方法可以抑制给定行的JSHint警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用中有一个(单个)案例,使用的是eval,我只想针对这种情况取消JSHint警告.

I have a (single) case in my app were eval is used, and I would like to suppress JSHint warning only for this case.

有没有办法实现这一目标?配置,魔术注释,...?

Is there a way to achieve that? Configuration, magic comment, ...?

推荐答案

是的,有一种方法.实际上两个.在 2013年10月中,jshint添加了一种忽略代码块的方法像这样:

Yes, there is a way. Two in fact. In October 2013 jshint added a way to ignore blocks of code like this:

// Code here will be linted with JSHint.
/* jshint ignore:start */
// Code here will be ignored by JSHint.
/* jshint ignore:end */
// Code here will be linted with JSHint.

您还可以忽略带有尾随注释的单行,如下所示:

You can also ignore a single line with a trailing comment like this:

ignoreThis(); // jshint ignore:line

这篇关于有没有一种方法可以抑制给定行的JSHint警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆