From e136afe2eb2d27823851427767b5175716af24e1 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Mon, 19 Jul 2021 22:47:32 +0100 Subject: [PATCH 1/3] Conform to new typescript eslint rules --- package.json | 1 + src/vector/platform/ElectronPlatform.tsx | 90 +++++++++++------------ src/vector/platform/VectorBasePlatform.ts | 6 +- src/vector/platform/WebPlatform.ts | 6 +- 4 files changed, 52 insertions(+), 51 deletions(-) diff --git a/package.json b/package.json index 695cbe2eb5..1208b99df1 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "start:js": "webpack-dev-server --host=0.0.0.0 --output-filename=bundles/_dev_/[name].js --output-chunk-filename=bundles/_dev_/[name].js -w --progress --mode development --disable-host-check", "lint": "yarn lint:types && yarn lint:js && yarn lint:style", "lint:js": "eslint src", + "lint:js-fix": "eslint --fix src", "lint:types": "tsc --noEmit --jsx react", "lint:style": "stylelint 'res/css/**/*.scss'", "test": "jest" diff --git a/src/vector/platform/ElectronPlatform.tsx b/src/vector/platform/ElectronPlatform.tsx index 3367f5ef57..c97b7dc922 100644 --- a/src/vector/platform/ElectronPlatform.tsx +++ b/src/vector/platform/ElectronPlatform.tsx @@ -110,10 +110,10 @@ class SeshatIndexManager extends BaseEventIndexManager { constructor() { super(); - electron.on('seshatReply', this._onIpcReply); + electron.on('seshatReply', this.onIpcReply); } - async _ipcCall(name: string, ...args: any[]): Promise { + private async ipcCall(name: string, ...args: any[]): Promise { // TODO this should be moved into the preload.js file. const ipcCallId = ++this.nextIpcCallId; return new Promise((resolve, reject) => { @@ -122,7 +122,7 @@ class SeshatIndexManager extends BaseEventIndexManager { }); } - _onIpcReply = (ev: {}, payload: IPCPayload) => { + private onIpcReply = (ev: {}, payload: IPCPayload) => { if (payload.id === undefined) { console.warn("Ignoring IPC reply with no ID"); return; @@ -143,35 +143,35 @@ class SeshatIndexManager extends BaseEventIndexManager { }; async supportsEventIndexing(): Promise { - return this._ipcCall('supportsEventIndexing'); + return this.ipcCall('supportsEventIndexing'); } async initEventIndex(userId: string, deviceId: string): Promise { - return this._ipcCall('initEventIndex', userId, deviceId); + return this.ipcCall('initEventIndex', userId, deviceId); } async addEventToIndex(ev: IMatrixEvent, profile: IMatrixProfile): Promise { - return this._ipcCall('addEventToIndex', ev, profile); + return this.ipcCall('addEventToIndex', ev, profile); } async deleteEvent(eventId: string): Promise { - return this._ipcCall('deleteEvent', eventId); + return this.ipcCall('deleteEvent', eventId); } async isEventIndexEmpty(): Promise { - return this._ipcCall('isEventIndexEmpty'); + return this.ipcCall('isEventIndexEmpty'); } async isRoomIndexed(roomId: string): Promise { - return this._ipcCall('isRoomIndexed', roomId); + return this.ipcCall('isRoomIndexed', roomId); } async commitLiveEvents(): Promise { - return this._ipcCall('commitLiveEvents'); + return this.ipcCall('commitLiveEvents'); } async searchEventIndex(searchConfig: ISearchArgs): Promise { - return this._ipcCall('searchEventIndex', searchConfig); + return this.ipcCall('searchEventIndex', searchConfig); } async addHistoricEvents( @@ -179,43 +179,43 @@ class SeshatIndexManager extends BaseEventIndexManager { checkpoint: ICrawlerCheckpoint | null, oldCheckpoint: ICrawlerCheckpoint | null, ): Promise { - return this._ipcCall('addHistoricEvents', events, checkpoint, oldCheckpoint); + return this.ipcCall('addHistoricEvents', events, checkpoint, oldCheckpoint); } async addCrawlerCheckpoint(checkpoint: ICrawlerCheckpoint): Promise { - return this._ipcCall('addCrawlerCheckpoint', checkpoint); + return this.ipcCall('addCrawlerCheckpoint', checkpoint); } async removeCrawlerCheckpoint(checkpoint: ICrawlerCheckpoint): Promise { - return this._ipcCall('removeCrawlerCheckpoint', checkpoint); + return this.ipcCall('removeCrawlerCheckpoint', checkpoint); } async loadFileEvents(args): Promise { - return this._ipcCall('loadFileEvents', args); + return this.ipcCall('loadFileEvents', args); } async loadCheckpoints(): Promise { - return this._ipcCall('loadCheckpoints'); + return this.ipcCall('loadCheckpoints'); } async closeEventIndex(): Promise { - return this._ipcCall('closeEventIndex'); + return this.ipcCall('closeEventIndex'); } async getStats(): Promise { - return this._ipcCall('getStats'); + return this.ipcCall('getStats'); } async getUserVersion(): Promise { - return this._ipcCall('getUserVersion'); + return this.ipcCall('getUserVersion'); } async setUserVersion(version: number): Promise { - return this._ipcCall('setUserVersion', version); + return this.ipcCall('setUserVersion', version); } async deleteEventIndex(): Promise { - return this._ipcCall('deleteEventIndex'); + return this.ipcCall('deleteEventIndex'); } } @@ -249,7 +249,7 @@ export default class ElectronPlatform extends VectorBasePlatform { rageshake.flush(); }); - electron.on('ipcReply', this._onIpcReply); + electron.on('ipcReply', this.onIpcReply); electron.on('update-downloaded', this.onUpdateDownloaded); electron.on('preferences', () => { @@ -317,11 +317,11 @@ export default class ElectronPlatform extends VectorBasePlatform { }); } - this._ipcCall("startSSOFlow", this.ssoID); + this.ipcCall("startSSOFlow", this.ssoID); } async getConfig(): Promise<{}> { - return this._ipcCall('getConfig'); + return this.ipcCall('getConfig'); } onUpdateDownloaded = async (ev, { releaseNotes, releaseName }) => { @@ -388,7 +388,7 @@ export default class ElectronPlatform extends VectorBasePlatform { room_id: room.roomId, }); window.focus(); - this._ipcCall('focusWindow'); + this.ipcCall('focusWindow'); }; return notification; @@ -399,7 +399,7 @@ export default class ElectronPlatform extends VectorBasePlatform { } async getAppVersion(): Promise { - return this._ipcCall('getAppVersion'); + return this.ipcCall('getAppVersion'); } supportsAutoLaunch(): boolean { @@ -407,11 +407,11 @@ export default class ElectronPlatform extends VectorBasePlatform { } async getAutoLaunchEnabled(): Promise { - return this._ipcCall('getAutoLaunchEnabled'); + return this.ipcCall('getAutoLaunchEnabled'); } async setAutoLaunchEnabled(enabled: boolean): Promise { - return this._ipcCall('setAutoLaunchEnabled', enabled); + return this.ipcCall('setAutoLaunchEnabled', enabled); } supportsWarnBeforeExit(): boolean { @@ -419,11 +419,11 @@ export default class ElectronPlatform extends VectorBasePlatform { } async shouldWarnBeforeExit(): Promise { - return this._ipcCall('shouldWarnBeforeExit'); + return this.ipcCall('shouldWarnBeforeExit'); } async setWarnBeforeExit(enabled: boolean): Promise { - return this._ipcCall('setWarnBeforeExit', enabled); + return this.ipcCall('setWarnBeforeExit', enabled); } supportsAutoHideMenuBar(): boolean { @@ -432,11 +432,11 @@ export default class ElectronPlatform extends VectorBasePlatform { } async getAutoHideMenuBarEnabled(): Promise { - return this._ipcCall('getAutoHideMenuBarEnabled'); + return this.ipcCall('getAutoHideMenuBarEnabled'); } async setAutoHideMenuBarEnabled(enabled: boolean): Promise { - return this._ipcCall('setAutoHideMenuBarEnabled', enabled); + return this.ipcCall('setAutoHideMenuBarEnabled', enabled); } supportsMinimizeToTray(): boolean { @@ -445,15 +445,15 @@ export default class ElectronPlatform extends VectorBasePlatform { } async getMinimizeToTrayEnabled(): Promise { - return this._ipcCall('getMinimizeToTrayEnabled'); + return this.ipcCall('getMinimizeToTrayEnabled'); } async setMinimizeToTrayEnabled(enabled: boolean): Promise { - return this._ipcCall('setMinimizeToTrayEnabled', enabled); + return this.ipcCall('setMinimizeToTrayEnabled', enabled); } async canSelfUpdate(): Promise { - const feedUrl = await this._ipcCall('getUpdateFeedUrl'); + const feedUrl = await this.ipcCall('getUpdateFeedUrl'); return Boolean(feedUrl); } @@ -492,7 +492,7 @@ export default class ElectronPlatform extends VectorBasePlatform { window.location.reload(false); } - async _ipcCall(name: string, ...args: any[]): Promise { + private async ipcCall(name: string, ...args: any[]): Promise { const ipcCallId = ++this.nextIpcCallId; return new Promise((resolve, reject) => { this.pendingIpcCalls[ipcCallId] = { resolve, reject }; @@ -501,7 +501,7 @@ export default class ElectronPlatform extends VectorBasePlatform { }); } - _onIpcReply = (ev, payload) => { + private onIpcReply = (ev, payload) => { if (payload.id === undefined) { console.warn("Ignoring IPC reply with no ID"); return; @@ -526,22 +526,22 @@ export default class ElectronPlatform extends VectorBasePlatform { } async setLanguage(preferredLangs: string[]) { - return this._ipcCall('setLanguage', preferredLangs); + return this.ipcCall('setLanguage', preferredLangs); } setSpellCheckLanguages(preferredLangs: string[]) { - this._ipcCall('setSpellCheckLanguages', preferredLangs).catch(error => { + this.ipcCall('setSpellCheckLanguages', preferredLangs).catch(error => { console.log("Failed to send setSpellCheckLanguages IPC to Electron"); console.error(error); }); } async getSpellCheckLanguages(): Promise { - return this._ipcCall('getSpellCheckLanguages'); + return this.ipcCall('getSpellCheckLanguages'); } async getAvailableSpellCheckLanguages(): Promise { - return this._ipcCall('getAvailableSpellCheckLanguages'); + return this.ipcCall('getAvailableSpellCheckLanguages'); } getSSOCallbackUrl(fragmentAfterLogin: string): URL { @@ -561,7 +561,7 @@ export default class ElectronPlatform extends VectorBasePlatform { } private navigateForwardBack(back: boolean) { - this._ipcCall(back ? "navigateBack" : "navigateForward"); + this.ipcCall(back ? "navigateBack" : "navigateForward"); } private navigateToSpace(num: number) { dis.dispatch({ @@ -608,7 +608,7 @@ export default class ElectronPlatform extends VectorBasePlatform { async getPickleKey(userId: string, deviceId: string): Promise { try { - return await this._ipcCall('getPickleKey', userId, deviceId); + return await this.ipcCall('getPickleKey', userId, deviceId); } catch (e) { // if we can't connect to the password storage, assume there's no // pickle key @@ -618,7 +618,7 @@ export default class ElectronPlatform extends VectorBasePlatform { async createPickleKey(userId: string, deviceId: string): Promise { try { - return await this._ipcCall('createPickleKey', userId, deviceId); + return await this.ipcCall('createPickleKey', userId, deviceId); } catch (e) { // if we can't connect to the password storage, assume there's no // pickle key @@ -628,7 +628,7 @@ export default class ElectronPlatform extends VectorBasePlatform { async destroyPickleKey(userId: string, deviceId: string): Promise { try { - await this._ipcCall('destroyPickleKey', userId, deviceId); + await this.ipcCall('destroyPickleKey', userId, deviceId); } catch (e) {} } } diff --git a/src/vector/platform/VectorBasePlatform.ts b/src/vector/platform/VectorBasePlatform.ts index 22a93111c0..72c47793ac 100644 --- a/src/vector/platform/VectorBasePlatform.ts +++ b/src/vector/platform/VectorBasePlatform.ts @@ -49,7 +49,7 @@ export default abstract class VectorBasePlatform extends BasePlatform { return this._favicon = new Favicon(); } - _updateFavicon() { + private updateFavicon() { let bgColor = "#d00"; let notif: string | number = this.notificationCount; @@ -64,13 +64,13 @@ export default abstract class VectorBasePlatform extends BasePlatform { setNotificationCount(count: number) { if (this.notificationCount === count) return; super.setNotificationCount(count); - this._updateFavicon(); + this.updateFavicon(); } setErrorStatus(errorDidOccur: boolean) { if (this.errorDidOccur === errorDidOccur) return; super.setErrorStatus(errorDidOccur); - this._updateFavicon(); + this.updateFavicon(); } /** diff --git a/src/vector/platform/WebPlatform.ts b/src/vector/platform/WebPlatform.ts index 6ddb5f4740..33359f4292 100644 --- a/src/vector/platform/WebPlatform.ts +++ b/src/vector/platform/WebPlatform.ts @@ -100,7 +100,7 @@ export default class WebPlatform extends VectorBasePlatform { return notification; } - _getVersion(): Promise { + private getVersion(): Promise { // We add a cachebuster to the request to make sure that we know about // the most recent version on the origin server. That might not // actually be the version we'd get on a reload (particularly in the @@ -132,7 +132,7 @@ export default class WebPlatform extends VectorBasePlatform { if (this.runningVersion !== null) { return Promise.resolve(this.runningVersion); } - return this._getVersion(); + return this.getVersion(); } startUpdater() { @@ -145,7 +145,7 @@ export default class WebPlatform extends VectorBasePlatform { } pollForUpdate = () => { - return this._getVersion().then((ver) => { + return this.getVersion().then((ver) => { if (this.runningVersion === null) { this.runningVersion = ver; } else if (this.runningVersion !== ver) { From 7cde32ed2e7337ab13363abeddacf5119964561c Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jul 2021 09:15:26 +0100 Subject: [PATCH 2/3] Update eslint-plugin-matrix-org --- yarn.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/yarn.lock b/yarn.lock index 38c8ac296b..914fd705ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4273,7 +4273,7 @@ eslint-config-google@^0.14.0: "eslint-plugin-matrix-org@github:matrix-org/eslint-plugin-matrix-org#main": version "0.3.2" - resolved "https://codeload.github.com/matrix-org/eslint-plugin-matrix-org/tar.gz/28d392822533a7468be0dd806d0a4ba573a45d74" + resolved "https://codeload.github.com/matrix-org/eslint-plugin-matrix-org/tar.gz/8529f1d77863db6327cf1a1a4fa65d06cc26f91b" eslint-plugin-react-hooks@^4.2.0: version "4.2.0" From 4b5b0e92449660218ccad29b489d16ba88e9a6f4 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 20 Jul 2021 09:27:12 +0100 Subject: [PATCH 3/3] delint --- .../structures/CompatibilityView.tsx | 16 ++++++++-------- src/async-components/structures/ErrorView.tsx | 4 ++-- src/components/views/auth/VectorAuthFooter.tsx | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/async-components/structures/CompatibilityView.tsx b/src/async-components/structures/CompatibilityView.tsx index 7a781ab459..75cc8fea2e 100644 --- a/src/async-components/structures/CompatibilityView.tsx +++ b/src/async-components/structures/CompatibilityView.tsx @@ -71,7 +71,7 @@ const CompatibilityView: React.FC = ({ onAccept }) => { android = []; } - let mobileHeader =

{_t("Use %(brand)s on mobile", { brand })}

; + let mobileHeader =

{ _t("Use %(brand)s on mobile", { brand }) }

; if (!android.length && !ios) { mobileHeader = null; } @@ -102,11 +102,11 @@ const CompatibilityView: React.FC = ({ onAccept }) => { 'or Safari for the best experience.', {}, { - 'chromeLink': (sub) => {sub}, - 'firefoxLink': (sub) => {sub}, - 'safariLink': (sub) => {sub}, + 'chromeLink': (sub) => { sub }, + 'firefoxLink': (sub) => { sub }, + 'safariLink': (sub) => { sub }, }, - )} + ) }

{ _t( @@ -124,9 +124,9 @@ const CompatibilityView: React.FC = ({ onAccept }) => {

- {mobileHeader} - {ios} - {android} + { mobileHeader } + { ios } + { android }
diff --git a/src/async-components/structures/ErrorView.tsx b/src/async-components/structures/ErrorView.tsx index 195bb37f26..7bc97f708e 100644 --- a/src/async-components/structures/ErrorView.tsx +++ b/src/async-components/structures/ErrorView.tsx @@ -40,9 +40,9 @@ const ErrorView: React.FC = ({ title, messages }) => {

{ title }

- {messages && messages.map(msg =>

+ { messages && messages.map(msg =>

{ msg } -

)} +

) }
diff --git a/src/components/views/auth/VectorAuthFooter.tsx b/src/components/views/auth/VectorAuthFooter.tsx index 7d940cf049..7cb48e3745 100644 --- a/src/components/views/auth/VectorAuthFooter.tsx +++ b/src/components/views/auth/VectorAuthFooter.tsx @@ -35,14 +35,14 @@ const VectorAuthFooter = () => { for (const linkEntry of links) { authFooterLinks.push( - {linkEntry.text} + { linkEntry.text } , ); } return (
- {authFooterLinks} + { authFooterLinks } { _t('Powered by Matrix') }
);