From a8ef6617c9fd5cc8fcdd6c4e646acc19d1dabfe2 Mon Sep 17 00:00:00 2001 From: Thomas Belin Date: Mon, 12 Feb 2024 10:03:48 +0100 Subject: [PATCH] chore: remove deprecated globals (#16417) --- .eslintrc.json | 10 +++------- src/script/auth/configureEnvironment.ts | 8 -------- .../Message/ContentMessage/ContentMessage.tsx | 1 + .../ContentMessage/MessageActions/MessageActions.tsx | 1 + src/script/properties/PropertiesRepository.ts | 3 ++- src/script/tracking/countly-skd-web.d.ts | 2 +- src/script/util/DebugUtil.ts | 4 ++-- src/types/window.d.ts | 11 +---------- webpack.config.common.js | 4 ---- 9 files changed, 11 insertions(+), 33 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 62fb30af8fd..b3ecaba41de 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -4,12 +4,9 @@ "jasmine": true }, "globals": { - "amplify": true, - "ko": true, - "sinon": true, - "wire": true, - "z": true, - "RTCAudioSource": true + "React": "readonly", + "JSX": "readonly", + "amplify": "readonly" }, "ignorePatterns": [ ".git/", @@ -42,7 +39,6 @@ "@typescript-eslint/no-floating-promises": "warn", "@typescript-eslint/typedef": "off", "no-dupe-class-members": "off", - "no-undef": "off", "no-unsanitized/property": "off", "prefer-promise-reject-errors": "off", "valid-jsdoc": "off", diff --git a/src/script/auth/configureEnvironment.ts b/src/script/auth/configureEnvironment.ts index e8c5d4c32e8..8f1bf10c0de 100644 --- a/src/script/auth/configureEnvironment.ts +++ b/src/script/auth/configureEnvironment.ts @@ -17,16 +17,8 @@ * */ -import {amplify} from 'amplify'; -import jQuery from 'jquery'; - import '../event/Client'; import '../message/MessageCategorization'; import '../message/MessageCategory'; import '../service/BackendEnvironment'; import '../storage/StorageSchemata'; - -window.amplify = amplify; -window.jQuery = jQuery; -// eslint-disable-next-line id-length -window.$ = jQuery; diff --git a/src/script/components/MessagesList/Message/ContentMessage/ContentMessage.tsx b/src/script/components/MessagesList/Message/ContentMessage/ContentMessage.tsx index 4f52884efa7..4cb47379b76 100644 --- a/src/script/components/MessagesList/Message/ContentMessage/ContentMessage.tsx +++ b/src/script/components/MessagesList/Message/ContentMessage/ContentMessage.tsx @@ -20,6 +20,7 @@ import {useMemo, useState, useEffect} from 'react'; import {QualifiedId} from '@wireapp/api-client/lib/user'; +import ko from 'knockout'; import {Conversation} from 'src/script/entity/Conversation'; import {CompositeMessage} from 'src/script/entity/message/CompositeMessage'; diff --git a/src/script/components/MessagesList/Message/ContentMessage/MessageActions/MessageActions.tsx b/src/script/components/MessagesList/Message/ContentMessage/MessageActions/MessageActions.tsx index 272cfaa4ee6..f35c1b456b5 100644 --- a/src/script/components/MessagesList/Message/ContentMessage/MessageActions/MessageActions.tsx +++ b/src/script/components/MessagesList/Message/ContentMessage/MessageActions/MessageActions.tsx @@ -20,6 +20,7 @@ import {FC, useCallback, useRef, useState} from 'react'; import {amplify} from 'amplify'; +import ko from 'knockout'; import {WebAppEvents} from '@wireapp/webapp-events'; diff --git a/src/script/properties/PropertiesRepository.ts b/src/script/properties/PropertiesRepository.ts index 79092b64530..c407cc6241c 100644 --- a/src/script/properties/PropertiesRepository.ts +++ b/src/script/properties/PropertiesRepository.ts @@ -21,6 +21,7 @@ import {RECEIPT_MODE} from '@wireapp/api-client/lib/conversation/data'; import {ConsentType} from '@wireapp/api-client/lib/self/'; import {AudioPreference, NotificationPreference, WebappProperties} from '@wireapp/api-client/lib/user/data/'; import {amplify} from 'amplify'; +import jquery from 'jquery'; import ko from 'knockout'; import {WebAppEvents} from '@wireapp/webapp-events'; @@ -185,7 +186,7 @@ export class PropertiesRepository { return this.propertiesService .getPropertiesByKey(PropertiesRepository.CONFIG.WEBAPP_ACCOUNT_SETTINGS) .then(properties => { - $.extend(true, this.properties, properties); + jquery.extend(true, this.properties, properties); }) .catch(() => { this.logger.warn( diff --git a/src/script/tracking/countly-skd-web.d.ts b/src/script/tracking/countly-skd-web.d.ts index 2e8da9270fe..a83f39fd1e1 100644 --- a/src/script/tracking/countly-skd-web.d.ts +++ b/src/script/tracking/countly-skd-web.d.ts @@ -35,7 +35,7 @@ declare module 'countly-sdk-web' { begin_session(): void; change_id(newId: string, merge: boolean): void; userData: UserData; - add_event: (eventData: EventData) => void; + add_event: (eventData: any) => void; } const Countly: Countly; diff --git a/src/script/util/DebugUtil.ts b/src/script/util/DebugUtil.ts index 1b932f35173..0e6ae2544cd 100644 --- a/src/script/util/DebugUtil.ts +++ b/src/script/util/DebugUtil.ts @@ -32,6 +32,7 @@ import {FeatureStatus} from '@wireapp/api-client/lib/team/feature/'; import type {QualifiedId} from '@wireapp/api-client/lib/user'; import {DatabaseKeys} from '@wireapp/core/lib/notification/NotificationDatabaseRepository'; import Dexie from 'dexie'; +import jquery from 'jquery'; import keyboardjs from 'keyboardjs'; import {$createTextNode, $getRoot, LexicalEditor} from 'lexical'; import {container} from 'tsyringe'; @@ -73,7 +74,7 @@ export class DebugUtil { private readonly eventRepository: EventRepository; private readonly storageRepository: StorageRepository; private readonly messageRepository: MessageRepository; - public readonly $: JQueryStatic; + public readonly $ = jquery; /** Used by QA test automation. */ public readonly userRepository: UserRepository; /** Used by QA test automation. */ @@ -89,7 +90,6 @@ export class DebugUtil { private readonly core = container.resolve(Core), private readonly apiClient = container.resolve(APIClient), ) { - this.$ = $; this.Dexie = Dexie; const {calling, client, connection, conversation, event, user, storage, message} = repositories; diff --git a/src/types/window.d.ts b/src/types/window.d.ts index 51bdd75f2fc..5aee04301df 100644 --- a/src/types/window.d.ts +++ b/src/types/window.d.ts @@ -18,22 +18,13 @@ */ import {amplify} from 'amplify'; -import jQuery from 'jquery'; -import ko from 'knockout'; - -import {t} from 'Util/LocalizerUtil'; import {WireModule} from './Wire.types'; declare global { interface Window { - $: typeof jQuery; - amplify: amplify.Static; - jQuery: typeof jQuery; - ko: typeof ko; - t: typeof t; wire: WireModule; - wSSOCapable: boolean; + amplify: amplify.Static; z: any; } } diff --git a/webpack.config.common.js b/webpack.config.common.js index 7560ec16ba2..29e15bb1f1f 100644 --- a/webpack.config.common.js +++ b/webpack.config.common.js @@ -131,11 +131,7 @@ module.exports = { }, plugins: [ new webpack.ProvidePlugin({ - $: 'jquery', Buffer: ['buffer', 'Buffer'], - _: 'underscore', - jQuery: 'jquery', - ko: 'knockout', }), new WorkboxPlugin.InjectManifest({ maximumFileSizeToCacheInBytes: process.env.NODE_ENV !== 'production' ? 10 * 1024 * 1024 : undefined,