如何使用JSHint禁用有关'this'和严格模式的警告? [英] How to disable warnings about 'this' and strict mode using JSHint?

查看:304
本文介绍了如何使用JSHint禁用有关'this'和严格模式的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用AngularJS(v1.5)编写一个Web应用程序,所以我有一些控制器,在那些控制器中,我经常声明如下:

I am writing a web app using AngularJS (v1.5) so I have some controllers, and in those controllers I am often declaring something like :

function myController($someDirectives, ...){
    var ctrl = this;
    // My code
}

事情是我JSHint我的代码,我收到控制器中声明的所有'this'的警告信息:

The thing is when I JSHint my code, I get this warning message for all of my 'this' declared in controllers :


如果使用函数调用执行严格模式函数,它的'this'值将是未定义的。

If a strict mode function is executed using function invocation, its 'this' value will be undefined.

我必须确切地说,在我的.jshintrc文件中,我设置了 严格:假
有没有人知道如何禁用此消息?

I must precise that in my .jshintrc file, I set "strict":false. Does anyone know how to disable this message in particular?

提前致谢。

推荐答案

.jshintrc 文件中设置配置

{
  "validthis": true // Tolerate using this in a non-constructor 
}

这篇关于如何使用JSHint禁用有关'this'和严格模式的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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