Skip to content

Commit 31e38f6

Browse files
authored
chore(deps): bump ESlint to v9 and update other lint-related packages (#1882)
* chore: bump ESLint-related packages * chore: tune some linting errors/warnings * chore: fix more lint warnings * chore: fix last warning * chore: remove duplicate line in Ignores block * chore: run prettier
1 parent 1ecb5aa commit 31e38f6

File tree

19 files changed

+429
-550
lines changed

19 files changed

+429
-550
lines changed

app/common/renderer/actions/Inspector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ export function setLocatorTestElement(elementId) {
562562
location: {x: commandRes.x, y: commandRes.y},
563563
size: {width: commandRes.width, height: commandRes.height},
564564
});
565-
} catch (ign) {}
565+
} catch {}
566566
}
567567
};
568568
}
@@ -817,7 +817,7 @@ export function runKeepAliveLoop() {
817817
log.info('Pinging Appium server to keep session active');
818818
try {
819819
await driver.getTimeouts(); // Pings the Appium server to keep it alive
820-
} catch (ign) {}
820+
} catch {}
821821
const now = Date.now();
822822

823823
// If the new command limit has been surpassed, prompt user if they want to keep session going
@@ -948,7 +948,7 @@ export function uploadGesturesFromFile(fileList) {
948948

949949
gesture.description = gesture.description || i18n.t('gestureImportedFrom', {fileName});
950950
parsedGestures.push(_.omit(gesture, ['id']));
951-
} catch (e) {
951+
} catch {
952952
invalidGestures[fileName] = [i18n.t('gestureInvalidJsonError')];
953953
}
954954
}

app/common/renderer/actions/Session.js

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {notification} from 'antd';
2-
import {includes, isPlainObject, isUndefined, toPairs, union, values, without} from 'lodash';
2+
import _ from 'lodash';
33
import moment from 'moment';
44
import {Web2Driver} from 'web2driver';
55

@@ -110,7 +110,7 @@ export function getCapsObject(caps) {
110110
try {
111111
let obj = JSON.parse(cap.value);
112112
return {[cap.name]: obj};
113-
} catch (ign) {}
113+
} catch {}
114114
}
115115
return {[cap.name]: cap.value};
116116
}),
@@ -134,7 +134,7 @@ export function showError(e, params = {methodName: null, secs: 5, url: null}) {
134134
} else if (e.data) {
135135
try {
136136
e.data = JSON.parse(e.data);
137-
} catch (ign) {}
137+
} catch {}
138138
if (e.data.value && e.data.value.message) {
139139
errMessage = e.data.value.message;
140140
} else {
@@ -149,8 +149,8 @@ export function showError(e, params = {methodName: null, secs: 5, url: null}) {
149149
}
150150
if (
151151
errMessage === 'ECONNREFUSED' ||
152-
includes(errMessage, 'Failed to fetch') ||
153-
includes(errMessage, 'The requested resource could not be found')
152+
_.includes(errMessage, 'Failed to fetch') ||
153+
_.includes(errMessage, 'The requested resource could not be found')
154154
) {
155155
errMessage = i18n.t('couldNotConnect', {url});
156156
}
@@ -265,7 +265,7 @@ export function newSession(caps, attachSessId = null) {
265265
return false;
266266
}
267267
https = false;
268-
if (!isPlainObject(desiredCapabilities[SAUCE_OPTIONS_CAP])) {
268+
if (!_.isPlainObject(desiredCapabilities[SAUCE_OPTIONS_CAP])) {
269269
desiredCapabilities[SAUCE_OPTIONS_CAP] = {};
270270
}
271271
if (!desiredCapabilities[SAUCE_OPTIONS_CAP].name) {
@@ -277,7 +277,7 @@ export function newSession(caps, attachSessId = null) {
277277
let headspinUrl;
278278
try {
279279
headspinUrl = new URL(session.server.headspin.webDriverUrl);
280-
} catch (ign) {
280+
} catch {
281281
showError(new Error(`${i18n.t('Invalid URL:')} ${session.server.headspin.webDriverUrl}`));
282282
return false;
283283
}
@@ -328,15 +328,19 @@ export function newSession(caps, attachSessId = null) {
328328
desiredCapabilities['lt:options'].source = 'appiumdesktop';
329329
desiredCapabilities['lt:options'].isRealMobile = true;
330330
if (session.server.advanced.useProxy) {
331-
desiredCapabilities['lt:options'].proxyUrl = isUndefined(session.server.advanced.proxy)
331+
desiredCapabilities['lt:options'].proxyUrl = _.isUndefined(
332+
session.server.advanced.proxy,
333+
)
332334
? ''
333335
: session.server.advanced.proxy;
334336
}
335337
} else {
336338
desiredCapabilities['lambdatest:source'] = 'appiumdesktop';
337339
desiredCapabilities['lambdatest:isRealMobile'] = true;
338340
if (session.server.advanced.useProxy) {
339-
desiredCapabilities['lambdatest:proxyUrl'] = isUndefined(session.server.advanced.proxy)
341+
desiredCapabilities['lambdatest:proxyUrl'] = _.isUndefined(
342+
session.server.advanced.proxy,
343+
)
340344
? ''
341345
: session.server.advanced.proxy;
342346
}
@@ -422,7 +426,7 @@ export function newSession(caps, attachSessId = null) {
422426
let experitestUrl;
423427
try {
424428
experitestUrl = new URL(session.server.experitest.url);
425-
} catch (ign) {
429+
} catch {
426430
showError(new Error(`${i18n.t('Invalid URL:')} ${session.server.experitest.url}`));
427431
return false;
428432
}
@@ -464,7 +468,7 @@ export function newSession(caps, attachSessId = null) {
464468
let mobitruUrl;
465469
try {
466470
mobitruUrl = new URL(webDriverUrl);
467-
} catch (ign) {
471+
} catch {
468472
showError(new Error(`${i18n.t('Invalid URL:')} ${webDriverUrl}`));
469473
return false;
470474
}
@@ -524,13 +528,13 @@ export function newSession(caps, attachSessId = null) {
524528
// If a newCommandTimeout wasn't provided, set it to 60 * 60 so that sessions don't close on users in short term.
525529
// I saw sometimes infinit session timeout was not so good for cloud providers.
526530
// So, let me define this value as NEW_COMMAND_TIMEOUT_SEC by default.
527-
if (isUndefined(desiredCapabilities[CAPS_NEW_COMMAND])) {
531+
if (_.isUndefined(desiredCapabilities[CAPS_NEW_COMMAND])) {
528532
desiredCapabilities[CAPS_NEW_COMMAND] = NEW_COMMAND_TIMEOUT_SEC;
529533
}
530534

531535
// If someone didn't specify connectHardwareKeyboard, set it to true by
532536
// default
533-
if (isUndefined(desiredCapabilities[CAPS_CONNECT_HARDWARE_KEYBOARD])) {
537+
if (_.isUndefined(desiredCapabilities[CAPS_CONNECT_HARDWARE_KEYBOARD])) {
534538
desiredCapabilities[CAPS_CONNECT_HARDWARE_KEYBOARD] = true;
535539
}
536540

@@ -602,7 +606,7 @@ export function newSession(caps, attachSessId = null) {
602606
try {
603607
mode = APP_MODE.WEB_HYBRID;
604608
await driver.navigateTo('https://appium.io');
605-
} catch (ign) {}
609+
} catch {}
606610
}
607611

608612
let mjpegScreenshotUrl =
@@ -836,7 +840,7 @@ export function setSavedServerParams() {
836840
if (server) {
837841
// if we have a cloud provider as a saved server, but for some reason the
838842
// cloud provider is no longer in the list, revert server type to remote
839-
if (values(SERVER_TYPES).includes(serverType) && !currentProviders.includes(serverType)) {
843+
if (_.values(SERVER_TYPES).includes(serverType) && !currentProviders.includes(serverType)) {
840844
serverType = SERVER_TYPES.REMOTE;
841845
}
842846
dispatch({type: SET_SERVER, server, serverType});
@@ -953,7 +957,7 @@ async function fetchAllSessions(baseUrl, authToken) {
953957
try {
954958
const res = await fetchSessionInformation({url, authToken});
955959
return res.data.value ?? [];
956-
} catch (err) {
960+
} catch {
957961
return [];
958962
}
959963
}
@@ -963,7 +967,7 @@ async function fetchAllSessions(baseUrl, authToken) {
963967
try {
964968
const res = await fetchSessionInformation({url, authToken});
965969
return formatSeleniumGridSessions(res);
966-
} catch (err) {
970+
} catch {
967971
return [];
968972
}
969973
}
@@ -1023,7 +1027,7 @@ export function saveRawDesiredCaps() {
10231027
}
10241028

10251029
// Translate the caps JSON to array format
1026-
let newCapsArray = toPairs(newCaps).map(([name, value]) => ({
1030+
let newCapsArray = _.toPairs(newCaps).map(([name, value]) => ({
10271031
type: (() => {
10281032
let type = typeof value;
10291033

@@ -1078,7 +1082,7 @@ export function stopAddCloudProvider() {
10781082
export function addVisibleProvider(provider) {
10791083
return async (dispatch, getState) => {
10801084
let currentProviders = getState().session.visibleProviders;
1081-
const providers = union(currentProviders, [provider]);
1085+
const providers = _.union(currentProviders, [provider]);
10821086
await setSetting(VISIBLE_PROVIDERS, providers);
10831087
dispatch({type: SET_PROVIDERS, providers});
10841088
};
@@ -1091,7 +1095,7 @@ export function removeVisibleProvider(provider) {
10911095
const action = changeServerType('remote');
10921096
await action(dispatch, getState);
10931097
}
1094-
const providers = without(visibleProviders, provider);
1098+
const providers = _.without(visibleProviders, provider);
10951099
await setSetting(VISIBLE_PROVIDERS, providers);
10961100
dispatch({type: SET_PROVIDERS, providers});
10971101
};
@@ -1172,7 +1176,7 @@ export function initFromQueryString(loadNewSession) {
11721176
try {
11731177
const state = JSON.parse(initialState);
11741178
dispatch({type: SET_STATE_FROM_URL, state});
1175-
} catch (e) {
1179+
} catch {
11761180
showError(new Error('Could not parse initial state from URL'), {secs: 0});
11771181
}
11781182
}

app/common/renderer/components/Inspector/Inspector.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
ThunderboltOutlined,
1414
} from '@ant-design/icons';
1515
import {Button, Card, Modal, Space, Spin, Switch, Tabs, Tooltip} from 'antd';
16-
import {debounce} from 'lodash';
16+
import _ from 'lodash';
1717
import {useEffect, useRef, useState} from 'react';
1818
import {useNavigate} from 'react-router';
1919

@@ -123,7 +123,7 @@ const Inspector = (props) => {
123123
setScaleRatio(windowSize.width / newImgWidth);
124124
};
125125

126-
const updateScreenshotScaleDebounced = debounce(updateScreenshotScale, 50);
126+
const updateScreenshotScaleDebounced = _.debounce(updateScreenshotScale, 50);
127127

128128
const checkMjpegStream = async () => {
129129
const {setAwaitingMjpegStream} = props;
@@ -133,7 +133,7 @@ const Inspector = (props) => {
133133
try {
134134
await img.decode();
135135
imgReady = true;
136-
} catch (ign) {}
136+
} catch {}
137137
if (imgReady && isAwaitingMjpegStream) {
138138
setAwaitingMjpegStream(false);
139139
updateScreenshotScaleDebounced();

app/common/renderer/lib/appium-client.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class AppiumClient {
4040
if (methodName === 'quit') {
4141
try {
4242
await this.driver.quit();
43-
} catch (ign) {}
43+
} catch {}
4444

4545
_instance = null;
4646

@@ -193,7 +193,7 @@ export default class AppiumClient {
193193
let element = null;
194194
try {
195195
element = await this.driver.findElement(strategy, selector);
196-
} catch (err) {
196+
} catch {
197197
return {};
198198
}
199199

@@ -301,13 +301,13 @@ export default class AppiumClient {
301301
try {
302302
const systemBars = await this.driver.executeScript('mobile:getSystemBars', []);
303303
webviewTopOffset = systemBars.statusBar.height;
304-
} catch (e) {
304+
} catch {
305305
try {
306306
// to minimize the endpoint call which gets error in newer chromedriver.
307307
const sessionDetails = await this.driver.getSession();
308308
// in case driver does not support mobile:getSystemBars
309309
webviewTopOffset = sessionDetails.viewportRect.top;
310-
} catch (ign) {}
310+
} catch {}
311311
}
312312
}
313313
} else if (this.driver.client.isIOS) {
@@ -316,7 +316,7 @@ export default class AppiumClient {
316316
// emulate optional chaining of deeply embedded property which might not exist using
317317
// a try catch
318318
browserName = this.driver.client.capabilities.browserName.toLowerCase();
319-
} catch (ign) {}
319+
} catch {}
320320
const isSafari = browserName === 'safari';
321321
if (isSafari) {
322322
// on iOS, if we're in Safari simply find the top status bar and address bar and use its Y endpoint
@@ -336,12 +336,12 @@ export default class AppiumClient {
336336
[],
337337
);
338338
webviewLeftOffset = deviceScreenInfo.statusBarSize.height;
339-
} catch (e) {
339+
} catch {
340340
try {
341341
const sessionDetails = await this.driver.getSession();
342342
// in case driver does not support mobile:deviceScreenInfo
343343
webviewLeftOffset = sessionDetails.statBarHeight;
344-
} catch (ign) {}
344+
} catch {}
345345
}
346346
}
347347
} else {
@@ -406,7 +406,7 @@ export default class AppiumClient {
406406
try {
407407
await this.driver.getContexts();
408408
return true;
409-
} catch (ign) {}
409+
} catch {}
410410

411411
// If the app under test returns non JSON format response
412412
return false;
@@ -454,7 +454,7 @@ export default class AppiumClient {
454454
let descriptionJSON = {attached: false};
455455
try {
456456
descriptionJSON = JSON.parse(page.description);
457-
} catch (ign) {}
457+
} catch {}
458458

459459
// You can have multiple `type` of pages, like service workers
460460
// We need to have pages with or 1. an attached view or 2. with an empty description

app/common/renderer/lib/client-frameworks/dotnet-nunit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ _driver.PerformActions(new List<ActionSequence> { swipe });
329329
settings.push(`_driver.SetSetting("${settingName}", ${this.getCSharpVal(settingValue)});`);
330330
}
331331
return settings.join('\n');
332-
} catch (e) {
332+
} catch {
333333
return `// Could not parse: ${settingsJson}`;
334334
}
335335
}

app/common/renderer/lib/client-frameworks/java-common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ driver.perform(Arrays.asList(swipe));
309309
settings.push(`driver.setSetting("${settingName}", ${this.getJavaVal(settingValue)});`);
310310
}
311311
return settings.join('\n');
312-
} catch (e) {
312+
} catch {
313313
return `// Could not parse: ${settingsJson}`;
314314
}
315315
}

0 commit comments

Comments
 (0)