阴影全球财产'未定义'

问题描述 投票:0回答:1

任何人都可以给我一些关于修复我用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

如果可能的话,我想摆脱这个警告。

javascript jslint
1个回答
2
投票

您要么从undefined中删除the function(global, undefined) { function参数,要么禁用该特定行上的警告(因为它可以防止其他脚本无法注意此警告)。或者,使用构建系统自动将此UMD标头添加到模块中,并仅在源上运行jslint。

© www.soinside.com 2019 - 2024. All rights reserved.