jslint:为什么此代码会导致“严格违规"?错误信息? [英] jslint: why does this code result in a "Strict violation" error message?

查看:46
本文介绍了jslint:为什么此代码会导致“严格违规"?错误信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行以下简单代码将导致严格违规".错误信息.我一直在尝试查找有关为什么以及如何修复它的文档.任何输入将不胜感激.

Running the following simple code results in a "Strict violation." error message. I have been trying to find documentation on why, and how to fix it. Any input will be much appreciated.

错误:

Error:

Problem at line 6 character 4: Strict violation.

} (this));

示例代码:

/*jslint browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, strict: true, newcap: true, immed: true */

"use strict";

(function (window) {
} (this));

关于,埃吉尔.

推荐答案

我看了一下jslint的源代码,它说:

I had a look at the source code of jslint, which says:

function reservevar(s, v) {
    return reserve(s, function () {
        if (this.id === 'this' || this.id === 'arguments' ||
                this.id === 'eval') {
            if (strict_mode && funct['(global)']) {
                warning("Strict violation.", this);
            } else if (option.safe) {
                warning("ADsafe violation.", this);
            }
        }
        return this;
    });
}

我猜想jslint确实抱怨您在全局上下文中使用this.

I guess that jslint really complains that you are using this in a global context.

这篇关于jslint:为什么此代码会导致“严格违规"?错误信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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