Skip to content

Commit 3d5821d

Browse files
authored
#5822 Fix: deprecated errors (#5842)
* fix: deprecated errors * fix: ui tests * fix: ui tests * fix: pr reviews
1 parent cff2332 commit 3d5821d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+200
-103
lines changed

eslint.config.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ const commonConfig = {
7272
format: ['camelCase', 'PascalCase'],
7373
},
7474
],
75-
// should be enabled in https://github.com/FlowCrypt/flowcrypt-browser/issues/5822
76-
'@typescript-eslint/no-deprecated': 'off',
75+
'@typescript-eslint/no-deprecated': 'warn',
7776
'@typescript-eslint/no-empty-interface': 'off',
7877
'@typescript-eslint/no-explicit-any': ['warn'],
7978
'@typescript-eslint/no-extraneous-class': 'off',

extension/chrome/elements/add_pubkey.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ View.run(
7676
}
7777
},
7878
});
79-
$('select.copy_from_email').change(this.setHandler(el => this.copyFromEmailHandler(el)));
79+
$('select.copy_from_email').on(
80+
'change',
81+
this.setHandler(el => this.copyFromEmailHandler(el))
82+
);
8083
$('.action_ok').on(
8184
'click',
8285
this.setHandler(() => this.submitHandler())

extension/chrome/elements/attachment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ export class AttachmentDownloadView extends View {
376376
const result = await this.gmail.msgGet(this.attachment.msgId, 'full');
377377
if (result?.payload?.parts) {
378378
for (const attMeta of result.payload.parts) {
379-
if (attMeta.filename === name && attMeta.body && attMeta.body.size === this.size && attMeta.body.attachmentId) {
379+
if (attMeta.filename === this.name && attMeta.body && attMeta.body.size === this.size && attMeta.body.attachmentId) {
380380
this.attachment.id = attMeta.body.attachmentId;
381381
return;
382382
}

extension/chrome/elements/attachment_preview.ts

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { AttachmentWarnings } from './shared/attachment_warnings.js';
1717
import * as pdfjsLib from 'pdfjs';
1818
import { AttachmentPreviewPdf } from '../../js/common/ui/attachment_preview_pdf.js';
1919

20+
// https://github.com/FlowCrypt/flowcrypt-browser/issues/5822#issuecomment-2362529197
21+
// eslint-disable-next-line @typescript-eslint/no-deprecated
2022
pdfjsLib.GlobalWorkerOptions.workerSrc = chrome.runtime.getURL(`lib/pdf.worker.min.mjs`);
2123
type AttachmentType = 'img' | 'txt' | 'pdf';
2224

extension/chrome/elements/backup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ View.run(
7070
'click',
7171
this.setHandler(async () => this.testPassphraseHandler())
7272
);
73-
$('#pass_phrase').keydown(this.setEnterHandlerThatClicks('.action_test_pass'));
73+
$('#pass_phrase').on('keydown', this.setEnterHandlerThatClicks('.action_test_pass'));
7474
};
7575

7676
private sendResizeMsg = () => {

extension/chrome/elements/compose-modules/compose-attachments-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class ComposeAttachmentsModule extends ViewModule<ComposeView> {
1717
}
1818

1919
public setHandlers = () => {
20-
this.view.S.cached('body').bind({ drop: Ui.event.stop(), dragover: Ui.event.stop() }); // prevents files dropped out of the intended drop area to interfere
20+
this.view.S.cached('body').on({ drop: Ui.event.stop(), dragover: Ui.event.stop() }); // prevents files dropped out of the intended drop area to interfere
2121
this.attachment.initAttachmentDialog('fineuploader', 'fineuploader_button', {
2222
uiChanged: () => {
2323
this.view.sizeModule.setInputTextHeightManuallyIfNeeded();

extension/chrome/elements/compose-modules/compose-recipients-module.ts

+15-6
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,18 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
108108
this.view.S.cached('input_to').trigger('focus');
109109
})
110110
);
111-
this.view.S.cached('input_to').focus(this.view.setHandler(() => this.focusRecipients()));
112-
this.view.S.cached('cc').focus(this.view.setHandler(() => this.focusRecipients()));
113-
this.view.S.cached('bcc').focus(this.view.setHandler(() => this.focusRecipients()));
111+
this.view.S.cached('input_to').on(
112+
'focus',
113+
this.view.setHandler(() => this.focusRecipients())
114+
);
115+
this.view.S.cached('cc').on(
116+
'focus',
117+
this.view.setHandler(() => this.focusRecipients())
118+
);
119+
this.view.S.cached('bcc').on(
120+
'focus',
121+
this.view.setHandler(() => this.focusRecipients())
122+
);
114123
this.view.S.cached('compose_table').on(
115124
'click',
116125
this.view.setHandler(() => this.hideContacts(), this.view.errModule.handle(`hide contact box`))
@@ -568,7 +577,7 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
568577
}
569578
}
570579
return false;
571-
} else if (e.keyCode === 32) {
580+
} else if (e.key === 'Space') {
572581
// Handle 'Space' key
573582
const target = $(e.target);
574583
const emails = String(target.val())
@@ -808,7 +817,7 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
808817
displayEmail = contact.email;
809818
} else {
810819
const parts = contact.email.split('@');
811-
displayEmail = parts[0].replace(/<\/?b>/g, '').substr(0, 10) + '...@' + parts[1];
820+
displayEmail = parts[0].replace(/<\/?b>/g, '').substring(0, 10) + '...@' + parts[1];
812821
}
813822
displayEmail = '<div class="select_contact_email" data-test="action-select-contact-email">' + Xss.escape(displayEmail) + '</div>';
814823
if (contact.name) {
@@ -835,7 +844,7 @@ export class ComposeRecipientsModule extends ViewModule<ComposeView> {
835844
this.view.errModule.handle(`select contact`)
836845
)
837846
);
838-
contactItems.hover(function () {
847+
contactItems.on('hover', function () {
839848
contactItems.removeClass('active');
840849
$(this).addClass('active');
841850
});

extension/chrome/elements/compose-modules/compose-render-module.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,13 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
371371
};
372372

373373
private addComposeTableHandlers = async () => {
374-
this.view.S.cached('body').keydown(
374+
this.view.S.cached('body').on(
375+
'keydown',
375376
this.view.setHandler((el, ev) => {
376377
this.onBodyKeydownHandler(el, ev);
377378
})
378379
);
379-
this.view.S.cached('input_to').bind(
380+
this.view.S.cached('input_to').on(
380381
'paste',
381382
this.view.setHandler((el, ev) => this.onRecipientPasteHandler(el, ev))
382383
);
@@ -391,7 +392,7 @@ export class ComposeRenderModule extends ViewModule<ComposeView> {
391392
.children()
392393
.on('click', () => false);
393394
this.view.S.cached('input_subject')
394-
.bind(
395+
.on(
395396
'input',
396397
this.view.setHandler((el: HTMLInputElement) => {
397398
this.subjectRTLHandler(el);

extension/chrome/elements/compose-modules/compose-reply-btn-popover-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class ComposeReplyBtnPopoverModule extends ViewModule<ComposeView> {
6969
if (replyContainer.hasClass('popover-opened')) {
7070
$('body').on('click', popoverClickHandler);
7171
const replyOptions = this.view.S.cached('reply_options_container').find('.reply-option');
72-
replyOptions.hover(function () {
72+
replyOptions.on('hover', function () {
7373
replyOptions.removeClass('active');
7474
$(this).addClass('active');
7575
});

extension/chrome/elements/compose-modules/compose-send-btn-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class ComposeSendBtnModule extends ViewModule<ComposeView> {
3737

3838
public setHandlers = (): void => {
3939
const ctrlEnterHandler = Ui.ctrlEnter(() => !this.view.sizeModule.composeWindowIsMinimized && this.extractProcessSendMsg());
40-
this.view.S.cached('subject').add(this.view.S.cached('compose')).keydown(ctrlEnterHandler);
40+
this.view.S.cached('subject').add(this.view.S.cached('compose')).on('keydown', ctrlEnterHandler);
4141
this.view.S.cached('send_btn').on(
4242
'click',
4343
this.view.setHandlerPrevent('double', () => this.extractProcessSendMsg())

extension/chrome/elements/compose-modules/compose-send-btn-popover-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class ComposeSendBtnPopoverModule extends ViewModule<ComposeView> {
115115
this.view.setHandler(async (target, e) => this.keydownHandler(e))
116116
);
117117
const sendingOptions = this.view.S.cached('sending_options_container').find('.sending-option');
118-
sendingOptions.hover(function () {
118+
sendingOptions.on('hover', function () {
119119
sendingOptions.removeClass('active');
120120
$(this).addClass('active');
121121
});

extension/chrome/elements/compose-modules/compose-sender-module.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,13 @@ export class ComposeSenderModule extends ViewModule<ComposeView> {
5151
const fmtOpt = (addr: string) => `<option value="${Xss.escape(addr)}" ${this.getSender() === addr ? 'selected' : ''}>${Xss.escape(addr)}</option>`;
5252
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
5353
emailAliases.sort((a, b) => (sendAs![a].isDefault === sendAs![b].isDefault ? 0 : sendAs![a].isDefault ? -1 : 1));
54-
Xss.sanitizeRender(fromContainer.find('#input_from'), emailAliases.map(fmtOpt).join('')).change(() =>
54+
Xss.sanitizeRender(fromContainer.find('#input_from'), emailAliases.map(fmtOpt).join('')).on('change', () =>
5555
this.view.myPubkeyModule.reevaluateShouldAttachOrNot()
5656
);
57-
this.view.S.now('input_from').change(this.view.setHandler(() => this.actionInputFromChangeHandler()));
57+
this.view.S.now('input_from').on(
58+
'change',
59+
this.view.setHandler(() => this.actionInputFromChangeHandler())
60+
);
5861
if (this.view.isReplyBox) {
5962
this.view.sizeModule.resizeComposeBox();
6063
}

extension/chrome/elements/passphrase.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ View.run(
119119
};
120120

121121
public setHandlers = () => {
122-
$('#passphrase').keyup(this.setHandler(() => this.renderNormalPpPrompt()));
122+
$('#passphrase').on(
123+
'keyup',
124+
this.setHandler(() => this.renderNormalPpPrompt())
125+
);
123126
$('.action_close').on(
124127
'click',
125128
this.setHandler(() => this.closeDialog())
@@ -165,7 +168,8 @@ View.run(
165168
);
166169
})
167170
);
168-
$('#passphrase').keydown(
171+
$('#passphrase').on(
172+
'keydown',
169173
this.setHandler((el, ev) => {
170174
if (ev.key === 'Enter') {
171175
$('.action_ok').trigger('click');

extension/chrome/elements/pgp_pubkey.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ View.run(
127127
'click',
128128
this.setHandler(btn => this.addContactHandler(btn))
129129
);
130-
$('.input_email').keyup(this.setHandler(() => this.setBtnText()));
130+
$('.input_email').on(
131+
'keyup',
132+
this.setHandler(() => this.setBtnText())
133+
);
131134
$('.action_show_full').on(
132135
'click',
133136
this.setHandler(btn => this.showFullKeyHandler(btn))

extension/chrome/settings/index.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ View.run(
7070
}
7171

7272
public render = async () => {
73+
// eslint-disable-next-line @typescript-eslint/no-deprecated
7374
const isDevMode = !('update_url' in chrome.runtime.getManifest());
7475
$('#status-row #status_version').text(`v:${VERSION}${isDevMode ? '-dev' : ''}`);
7576
for (const webmailLName of await Env.webmails()) {
@@ -222,7 +223,8 @@ View.run(
222223
}, 500);
223224
})
224225
);
225-
this.altAccounts.keydown(
226+
this.altAccounts.on(
227+
'keydown',
226228
this.setHandler((el, ev) => {
227229
this.accountsMenuKeydownHandler(ev);
228230
})

extension/chrome/settings/modules/add_key.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class AddKeyView extends View {
7272

7373
public setHandlers = () => {
7474
$('.action_add_private_key').on('click', this.setHandlerPrevent('double', this.addPrivateKeyHandler));
75-
$('#input_passphrase').keydown(this.setEnterHandlerThatClicks('.action_add_private_key'));
75+
$('#input_passphrase').on('keydown', this.setEnterHandlerThatClicks('.action_add_private_key'));
7676
this.addKeyGenerateModule.setHandlers();
7777
};
7878

extension/chrome/settings/modules/compatibility.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ View.run(
3434
public setHandlers = () => {
3535
$('.action_load_public_key').on('click', this.setHandlerPrevent('double', this.actionLoadPublicKey));
3636
$('.action_test_key').on('click', this.setHandlerPrevent('double', this.actionTestKeyHandler));
37-
$('#input_passphrase').keydown(this.setEnterHandlerThatClicks('.action_test_key'));
37+
$('#input_passphrase').on('keydown', this.setEnterHandlerThatClicks('.action_test_key'));
3838
};
3939

4040
private performKeyCompatibilityTests = async (keyString: string) => {

extension/chrome/settings/modules/contacts.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ View.run(
6060
$('#bulk_import .action_process').off().on('click', this.setHandlerPrevent('double', this.actionProcessBulkImportTextInput));
6161
$('.action_export_all').off().on('click', this.setHandlerPrevent('double', this.actionExportAllKeysHandler));
6262
$('.action_view_bulk_import').off().on('click', this.setHandlerPrevent('double', this.actionRenderBulkImportPageHandler));
63-
$('.input-search-contacts').off().keyup(this.setHandlerPrevent('double', this.loadAndRenderContactList));
63+
$('.input-search-contacts').off().on('keyup', this.setHandlerPrevent('double', this.loadAndRenderContactList));
6464
};
6565

6666
// --- PRIVATE

extension/chrome/settings/modules/my_key_update.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ View.run(
8282
'click',
8383
this.setHandlerPrevent('double', () => this.updatePrivateKeyHandler())
8484
);
85-
$('.input_passphrase').keydown(this.setEnterHandlerThatClicks('.action_update_private_key'));
85+
$('.input_passphrase').on('keydown', this.setEnterHandlerThatClicks('.action_update_private_key'));
8686
};
8787

8888
private storeUpdatedKeyAndPassphrase = async (updatedPrv: Key, updatedPrvPassphrase: string) => {

extension/chrome/settings/modules/security.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ View.run(
5858
Settings.redirectSubPage(this.acctEmail, this.parentTabId, '/chrome/settings/modules/test_passphrase.htm');
5959
})
6060
);
61-
$('#hide_message_password').change(this.setHandler(el => this.hideMsgPasswordHandler(el)));
62-
$('.password_message_language').change(this.setHandler(() => this.onMsgLanguageUserChange()));
61+
$('#hide_message_password').on(
62+
'change',
63+
this.setHandler(el => this.hideMsgPasswordHandler(el))
64+
);
65+
$('.password_message_language').on(
66+
'change',
67+
this.setHandler(() => this.onMsgLanguageUserChange())
68+
);
6369
};
6470

6571
private renderPassPhraseOptionsIfStoredPermanently = async () => {
@@ -91,7 +97,7 @@ View.run(
9197
$('.cancel_passphrase_requirement_change').on('click', () => {
9298
window.location.reload();
9399
});
94-
$('#passphrase_entry').keydown(this.setEnterHandlerThatClicks('.confirm_passphrase_requirement_change'));
100+
$('#passphrase_entry').on('keydown', this.setEnterHandlerThatClicks('.confirm_passphrase_requirement_change'));
95101
}
96102
};
97103

extension/js/common/api/authentication/configured-idp-oauth.ts

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export class ConfiguredIdpOAuth extends OAuth {
100100
grant_type: 'refresh_token',
101101
refreshToken,
102102
client_id: authConf.oauth.clientId,
103+
// eslint-disable-next-line @typescript-eslint/no-deprecated
103104
redirect_uri: chrome.identity.getRedirectURL('oauth'),
104105
},
105106
dataType: 'JSON',
@@ -119,6 +120,7 @@ export class ConfiguredIdpOAuth extends OAuth {
119120
access_type: 'offline',
120121
prompt: 'login',
121122
state,
123+
// eslint-disable-next-line @typescript-eslint/no-deprecated
122124
redirect_uri: chrome.identity.getRedirectURL('oauth'),
123125
scope: this.OAUTH_REQUEST_SCOPES.join(' '),
124126
login_hint: acctEmail,
@@ -129,7 +131,9 @@ export class ConfiguredIdpOAuth extends OAuth {
129131
private static async getAuthRes({ acctEmail, expectedState, authUrl }: { acctEmail: string; expectedState: string; authUrl: string }): Promise<AuthRes> {
130132
/* eslint-disable @typescript-eslint/naming-convention */
131133
try {
134+
// eslint-disable-next-line @typescript-eslint/no-deprecated
132135
const redirectUri = await chrome.identity.launchWebAuthFlow({ url: authUrl, interactive: true });
136+
// eslint-disable-next-line @typescript-eslint/no-deprecated
133137
if (chrome.runtime.lastError || !redirectUri || redirectUri?.includes('access_denied')) {
134138
return { acctEmail, result: 'Denied', error: `Failed to launch web auth flow`, id_token: undefined };
135139
}
@@ -203,6 +207,7 @@ export class ConfiguredIdpOAuth extends OAuth {
203207
grant_type: 'authorization_code',
204208
code,
205209
client_id: authConf.oauth.clientId,
210+
// eslint-disable-next-line @typescript-eslint/no-deprecated
206211
redirect_uri: chrome.identity.getRedirectURL('oauth'),
207212
},
208213
dataType: 'JSON',

extension/js/common/api/authentication/google/google-oauth.ts

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export class GoogleOAuth extends OAuth {
8888
const performAjaxRequest = async <RT>(req: Ajax): Promise<RT> => {
8989
// temporary use jquery for upload requests https://github.com/FlowCrypt/flowcrypt-browser/issues/5612
9090
if (req.progress?.upload) {
91+
// eslint-disable-next-line @typescript-eslint/no-deprecated
9192
return (await Api.ajaxWithJquery(req, 'json')) as RT;
9293
} else {
9394
return (await Api.ajax(req, 'json')) as RT;

extension/js/common/api/flowcrypt-website.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class FlowCryptWebsite extends Api {
3030
for (const post of Browser.arrFromDomNodeList(xml.querySelectorAll('entry'))) {
3131
const children = Browser.arrFromDomNodeList(post.childNodes);
3232
const title = children.find(n => n.nodeName.toLowerCase() === 'title')?.textContent;
33-
const date = children.find(n => n.nodeName.toLowerCase() === 'published')?.textContent?.substr(0, 10);
33+
const date = children.find(n => n.nodeName.toLowerCase() === 'published')?.textContent?.substring(0, 10);
3434
const url = (children.find(n => n.nodeName.toLowerCase() === 'link') as HTMLAnchorElement).getAttribute('href');
3535
if (title && date && url) {
3636
posts.push({ title, date, url });

extension/js/common/api/shared/api-error.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ export class AjaxErr extends ApiCallErr {
9696
const status = resCode || (typeof xhr.status === 'number' ? xhr.status : -1);
9797
if (status === 400 || status === 403 || (status === 200 && responseText && !responseText.startsWith('{'))) {
9898
// RawAjaxErr with status 200 can happen when it fails to parse response - eg non-json result
99-
const redactedRes = AjaxErr.redactSensitiveData(responseText.substr(0, 1000));
100-
const redactedPayload = AjaxErr.redactSensitiveData(Catch.stringify(req.data).substr(0, 1000));
99+
const redactedRes = AjaxErr.redactSensitiveData(responseText.substring(0, 1000));
100+
const redactedPayload = AjaxErr.redactSensitiveData(Catch.stringify(req.data).substring(0, 1000));
101101
stack += `\n\nresponseText(0, 1000):\n${redactedRes}\n\npayload(0, 1000):\n${redactedPayload}`;
102102
}
103103
const message = `${String(xhr.statusText || '(no status text)')}: ${String(xhr.status || -1)} when ${ApiCallErr.describeApiAction(req)} -> ${

extension/js/common/api/shared/api.ts

+1
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ export class Api {
410410
// as of October 2023 fetch upload progress (through ReadableStream)
411411
// is supported only by Chrome and requires HTTP/2 on backend
412412
// as temporary solution we use XMLHTTPRequest for such requests
413+
// eslint-disable-next-line @typescript-eslint/no-deprecated
413414
const result = await Api.ajaxWithJquery(req, resFmt, formattedData);
414415
return result as FetchResult<T, RT>;
415416
} else {

0 commit comments

Comments
 (0)