Skip to content

Commit

Permalink
chore: replace 'global' with 'globalThis' (#701)
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald authored Jun 18, 2024
1 parent 77f11bb commit 5c1b87d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
6 changes: 3 additions & 3 deletions src/i18n/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/**
Expand Down Expand Up @@ -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');
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 5c1b87d

Please sign in to comment.