例如,考虑以下Node.js代码:
(function () {
"use strict";
/*jslint node: true */
var toBeExecutedInBrowser = function () {
"use strict";
/*jslint devel: true */
alert( Hello world! );
};
exports.controller = function (req, res) {
res.send(toBeExecutedInBrowser.toString());
};
}());
最新的 JSLint 版本< a href = https:// github. com/douglascrockford/ JSLint/blob/master/jslint.js#L2386" rel= “ nofollow” > 无条件不能够检查此代码。 显然, JSLint 作者不想回答我们在本案中应该做什么, 由他来判断他删除了我的问题; 但也许有人可以回答我在这种情况下应该做什么?
- I do not want to significantly change the application logic;
- I do not want to write unsafe code by letting the client-side mode to be executed in a non-strict context (something Douglas Crockford supposedly also wants);
- I do not want to write unsafe code by disabling JSLint for this file entirely (something Douglas Crockford supposedly also wants);
- I do not want the JSLint report to be "spammed" by the
unnecessary use strict
messages, so that it will be possible to overlook something really important.