Update .bashrc
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / eslint / lib / rules / no-alert.js
index 287cd2c35701f0a2498e90160ad3ace62343960c..702b4d2ba7cccf1ddea02bc10b4168534f0bc7e0 100644 (file)
@@ -8,7 +8,11 @@
 // Requirements
 //------------------------------------------------------------------------------
 
-const getPropertyName = require("./utils/ast-utils").getStaticPropertyName;
+const {
+    getStaticPropertyName: getPropertyName,
+    getVariableByName,
+    skipChainExpression
+} = require("./utils/ast-utils");
 
 //------------------------------------------------------------------------------
 // Helpers
@@ -61,7 +65,13 @@ function isGlobalThisReferenceOrGlobalWindow(scope, node) {
     if (scope.type === "global" && node.type === "ThisExpression") {
         return true;
     }
-    if (node.name === "window") {
+    if (
+        node.type === "Identifier" &&
+        (
+            node.name === "window" ||
+            (node.name === "globalThis" && getVariableByName(scope, "globalThis"))
+        )
+    ) {
         return !isShadowed(scope, node);
     }
 
@@ -93,7 +103,7 @@ module.exports = {
     create(context) {
         return {
             CallExpression(node) {
-                const callee = node.callee,
+                const callee = skipChainExpression(node.callee),
                     currentScope = context.getScope();
 
                 // without window.
@@ -119,7 +129,6 @@ module.exports = {
                         });
                     }
                 }
-
             }
         };