簡體   English   中英

全球財產“未定義”的陰影

[英]Shadowing of global property 'undefined'

任何人都可以給我一些有關修復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

如果可能的話,我想擺脫這個警告。

您可能想從function(global, undefined) { function中刪除undefined參數,或者在該特定行上禁用警告(因為它可以防止其他腳本忽略此警告)。 或者,使用構建系統將這個UMD標頭自動添加到模塊中,並僅在源代碼上運行jslint。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM