任何人都可以给我一些关于修复我用JSLint获得的警告的指示。
我有以下代码:
/* global window, define, module */
(function(global, factory) {
var Gauge = factory(global);
if(typeof define === "function" && define.amd) {
// AMD support
define(function() {return Gauge;});
}else if(typeof module === "object" && module.exports) {
// CommonJS support
module.exports = Gauge;
}else {
// We are probably running in the browser
global.Gauge = Gauge;
}
})(typeof window === "undefined" ? this : window, function(global, undefined) {
在最后一行(typeof window === "undefined" ...
我收到这个警告:
Line 14: Shadowing of global property 'undefined' no-shadow-restricted-names
如果可能的话,我想摆脱这个警告。
您要么从undefined
中删除the function(global, undefined) {
function参数,要么禁用该特定行上的警告(因为它可以防止其他脚本无法注意此警告)。或者,使用构建系统自动将此UMD标头添加到模块中,并仅在源上运行jslint。