From 2e3b0bb242f888919896951b85536b4565b044da Mon Sep 17 00:00:00 2001 From: Abhinav Date: Fri, 10 Feb 2023 10:24:11 +0530 Subject: [PATCH] update code to prevent of eslint escapes --- .../Search/SearchBar/searchInput/index.tsx | 1 - src/services/machineLearning/mlWorkManager.ts | 19 +++++++++---------- src/utils/storage/mlIDbStorage.ts | 8 +++----- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/components/Search/SearchBar/searchInput/index.tsx b/src/components/Search/SearchBar/searchInput/index.tsx index ec5d3182e..b084821df 100644 --- a/src/components/Search/SearchBar/searchInput/index.tsx +++ b/src/components/Search/SearchBar/searchInput/index.tsx @@ -120,7 +120,6 @@ export default function SearchInput(props: Iprops) { // unwanted side effect: placeholder is not shown on focus/click // https://github.com/JedWatson/react-select/issues/1879 // for correct fix AsyncSelect can be extended to support default options reloading on focus/click - // eslint-disable-next-line @typescript-eslint/no-unused-vars const handleOnFocus = () => { refreshDefaultOptions(); }; diff --git a/src/services/machineLearning/mlWorkManager.ts b/src/services/machineLearning/mlWorkManager.ts index 3c64fa366..24ac11599 100644 --- a/src/services/machineLearning/mlWorkManager.ts +++ b/src/services/machineLearning/mlWorkManager.ts @@ -38,8 +38,7 @@ class MLWorkManager { }); this.mlSearchEnabled = false; - // eslint-disable-next-line @typescript-eslint/unbound-method - eventBus.on(Events.LOGOUT, this.logoutHandler, this); + eventBus.on(Events.LOGOUT, this.logoutHandler.bind(this), this); this.debouncedLiveSyncIdle = debounce( () => this.onLiveSyncIdle(), LIVE_SYNC_IDLE_DEBOUNCE_SEC * 1000 @@ -58,8 +57,11 @@ class MLWorkManager { logQueueStats(this.liveSyncQueue, 'livesync'); this.liveSyncQueue.on('idle', this.debouncedLiveSyncIdle, this); - // eslint-disable-next-line @typescript-eslint/unbound-method - eventBus.on(Events.FILE_UPLOADED, this.fileUploadedHandler, this); + eventBus.on( + Events.FILE_UPLOADED, + this.fileUploadedHandler.bind(this), + this + ); eventBus.on( Events.LOCAL_FILES_UPDATED, this.debouncedFilesUpdated, @@ -75,8 +77,7 @@ class MLWorkManager { eventBus.removeListener( Events.FILE_UPLOADED, - // eslint-disable-next-line @typescript-eslint/unbound-method - this.fileUploadedHandler, + this.fileUploadedHandler.bind(this), this ); eventBus.removeListener( @@ -85,8 +86,7 @@ class MLWorkManager { this ); - // eslint-disable-next-line @typescript-eslint/await-thenable - await this.stopSyncJob(); + this.stopSyncJob(); } } @@ -103,8 +103,7 @@ class MLWorkManager { private async logoutHandler() { addLogLine('logoutHandler'); try { - // eslint-disable-next-line @typescript-eslint/await-thenable - await this.stopSyncJob(); + this.stopSyncJob(); this.mlSyncJob = undefined; await this.terminateLiveSyncWorker(); await mlIDbStorage.clearMLDB(); diff --git a/src/utils/storage/mlIDbStorage.ts b/src/utils/storage/mlIDbStorage.ts index d017f4c47..d615ebfea 100644 --- a/src/utils/storage/mlIDbStorage.ts +++ b/src/utils/storage/mlIDbStorage.ts @@ -72,15 +72,13 @@ class MLIDbStorage { } private openDB(): Promise> { - // eslint-disable-next-line @typescript-eslint/no-this-alias - const mlIDbStorage = this; return openDB(MLDATA_DB_NAME, 3, { - async terminated() { + terminated: async () => { console.error('ML Indexed DB terminated'); logError(new Error(), 'ML Indexed DB terminated'); - mlIDbStorage._db = undefined; + this._db = undefined; // TODO: remove if there is chance of this going into recursion in some case - await mlIDbStorage.db; + await this.db; }, blocked() { // TODO: make sure we dont allow multiple tabs of app