From 5c1b87d74f31d3fe36df38cd6130f8778f499655 Mon Sep 17 00:00:00 2001 From: Braden MacDonald Date: Tue, 18 Jun 2024 10:08:58 -0700 Subject: [PATCH] chore: replace 'global' with 'globalThis' (#701) --- .eslintrc.js | 1 + src/i18n/lib.js | 6 +++--- src/initialize.js | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 237b4781c..3452e8fa4 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,6 +3,7 @@ const { getBaseConfig } = require('@openedx/frontend-build'); const config = getBaseConfig('eslint'); +config.globals = { globalThis: 'readonly' }; config.rules = { 'import/no-extraneous-dependencies': ['error', { devDependencies: [ diff --git a/src/i18n/lib.js b/src/i18n/lib.js index 6f389526a..867d0509f 100644 --- a/src/i18n/lib.js +++ b/src/i18n/lib.js @@ -167,7 +167,7 @@ export function getLocale(locale) { // Note that some browers prefer upper case for the region part of the locale, while others don't. // Thus the toLowerCase, for consistency. // https://developer.mozilla.org/en-US/docs/Web/API/NavigatorLanguage/language - return findSupportedLocale(global.navigator.language.toLowerCase()); + return findSupportedLocale(globalThis.navigator.language.toLowerCase()); } /** @@ -199,9 +199,9 @@ export function isRtl(locale) { */ export function handleRtl() { if (isRtl(getLocale())) { - global.document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl'); + globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'rtl'); } else { - global.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr'); + globalThis.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr'); } } diff --git a/src/initialize.js b/src/initialize.js index 2c7223595..d84f656d6 100644 --- a/src/initialize.js +++ b/src/initialize.js @@ -140,7 +140,7 @@ export async function initError(error) { */ export async function auth(requireUser, hydrateUser) { if (requireUser) { - await ensureAuthenticatedUser(global.location.href); + await ensureAuthenticatedUser(globalThis.location.href); } else { await fetchAuthenticatedUser(); }