Egi*_*sen 14 javascript jslint
运行以下简单代码会导致"严格违规".错误信息.我一直在努力寻找有关原因以及如何解决问题的文档.任何输入将非常感激.
错误:
Error:
Problem at line 6 character 4: Strict violation.
} (this));
Run Code Online (Sandbox Code Playgroud)
示例代码:
/*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));
Run Code Online (Sandbox Code Playgroud)
此致,埃吉尔.
我看了一下jslint的源代码,它说:
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;
});
}
Run Code Online (Sandbox Code Playgroud)
我猜jslint真的抱怨你this在全球范围内使用.