Merge pull request #14780 from backstage/freben/globals

avoid globals
This commit is contained in:
Fredrik Adelöw
2022-11-22 20:18:27 +01:00
committed by GitHub
19 changed files with 212 additions and 21 deletions
+1 -1
View File
@@ -179,7 +179,7 @@ export class Git {
});
} catch (ex) {
this.config.logger?.error(
`Failed to fetch repo {dir=${dir},origin=${origin}}`,
`Failed to fetch repo {dir=${dir},remote=${remote}}`,
);
if (ex.data) {
throw new Error(`${ex.message} {data=${JSON.stringify(ex.data)}}`);
@@ -89,6 +89,6 @@ describe('AppIdentityProxy', () => {
});
await proxy.signOut();
expect(location.href).toBe('/foo');
expect(window.location.href).toBe('/foo');
});
});
@@ -124,6 +124,6 @@ export class AppIdentityProxy implements IdentityApi {
async signOut(): Promise<void> {
await this.waitForTarget.then(target => target.signOut());
location.href = this.signOutTargetUrl;
window.location.href = this.signOutTargetUrl;
}
}
@@ -154,7 +154,7 @@ export class DefaultAuthConnector<AuthSession>
const scope = this.joinScopesFunc(scopes);
const popupUrl = await this.buildUrl('/start', {
scope,
origin: location.origin,
origin: window.location.origin,
});
const payload = await showLoginPopup({
@@ -155,7 +155,7 @@ function useScrollDistance(
return [scrollLeft, scrollRight];
}
// Used to animate scrolling. Returns a single setScrollTarger function, when called with e.g. 200,
// Used to animate scrolling. Returns a single setScrollTarget function, when called with e.g. 200,
// the element pointer to by the ref will be scrolled 200px forwards over time.
function useSmoothScroll(
ref: React.MutableRefObject<HTMLElement | undefined>,
@@ -169,7 +169,7 @@ function useSmoothScroll(
return;
}
const startTime = performance.now();
const startTime = window.performance.now();
const id = requestAnimationFrame(frameTime => {
if (!ref.current) {
return;
@@ -19,7 +19,9 @@ function getGlobalObject() {
if (typeof window !== 'undefined' && window.Math === Math) {
return window;
}
// eslint-disable-next-line no-restricted-globals
if (typeof self !== 'undefined' && self.Math === Math) {
// eslint-disable-next-line no-restricted-globals
return self;
}
// eslint-disable-next-line no-new-func