// Requirements
//------------------------------------------------------------------------------
-const getPropertyName = require("./utils/ast-utils").getStaticPropertyName;
+const {
+ getStaticPropertyName: getPropertyName,
+ getVariableByName,
+ skipChainExpression
+} = require("./utils/ast-utils");
//------------------------------------------------------------------------------
// Helpers
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);
}
create(context) {
return {
CallExpression(node) {
- const callee = node.callee,
+ const callee = skipChainExpression(node.callee),
currentScope = context.getScope();
// without window.
});
}
}
-
}
};