Skip to content

Commit

Permalink
chore: Bump eslint version
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Jan 2, 2025
1 parent 57463a8 commit 19e5f28
Show file tree
Hide file tree
Showing 74 changed files with 136 additions and 173 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

22 changes: 0 additions & 22 deletions .eslintrc.json

This file was deleted.

10 changes: 10 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import appiumConfig from '@appium/eslint-config-appium-ts';

export default [
...appiumConfig,
{
ignores: [
'docs/**',
],
},
];
2 changes: 1 addition & 1 deletion lib/commands/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default {
style = /** @type {Style} */ (
await /** @type {import('../driver').Simulator} */ (this.device).getAppearance()
);
} catch (ign) {}
} catch {}
}
if (!style) {
style = /** @type {Style} */ (
Expand Down
6 changes: 3 additions & 3 deletions lib/commands/certificate.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ async function clickElement(driver, locator, options = {}) {
lookupDelay,
() => driver.findNativeElementOrElements(locator.type, locator.value, false),
);
} catch (err) {
} catch {
if (skipIfInvisible) {
return false;
}
Expand Down Expand Up @@ -362,7 +362,7 @@ export default {
async () => {
try {
return (await checkPortStatus(tmpPort, host)) === 'open';
} catch (ign) {
} catch {
return false;
}
},
Expand All @@ -372,7 +372,7 @@ export default {
},
);
this.log.debug(`The temporary web server is running at http://${host}:${tmpPort}`);
} catch (e) {
} catch {
throw new Error(
`The temporary web server cannot be started at http://${host}:${tmpPort}.`,
);
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/context.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {createRemoteDebugger, RemoteDebugger} from 'appium-remote-debugger';
import {errors, isErrorType} from 'appium/driver';
import {util, timing} from 'appium/support';
import IOSPerformanceLog from '../device-log/ios-performance-log';
import {IOSPerformanceLog} from '../device-log/ios-performance-log';
import _ from 'lodash';
import { NATIVE_WIN } from '../utils';
import {
Expand Down Expand Up @@ -478,7 +478,6 @@ const commands = {
* @this {XCUITestDriver}
* @returns {Promise<string>}
*/
// eslint-disable-next-line require-await
async getCurrentContext() {
if (this.curContext && this.curContext !== NATIVE_WIN) {
return `${WEBVIEW_BASE}${this.curContext}`;
Expand Down Expand Up @@ -638,7 +637,6 @@ const commands = {
* @this {XCUITestDriver}
* @returns {Promise<string>}
*/
// eslint-disable-next-line require-await
async getWindowHandle() {
if (!this.isWebContext()) {
// https://github.com/appium/appium/issues/20710
Expand Down Expand Up @@ -701,7 +699,7 @@ function isUrlIgnored(url, safariIgnoreWebHostnames) {
if (hostname === ignoredHost) {
return true;
}
} catch (ign) {
} catch {
// do nothing if invalid URL
}
}
Expand Down
1 change: 0 additions & 1 deletion lib/commands/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export default {
* @deprecated
* @privateRemarks It's unclear what this is for. Don't use it.
*/
// eslint-disable-next-line require-await
async receiveAsyncResponse(status, value) {
this.log.debug(`Received async response: ${JSON.stringify(value)}`);
if (!util.hasValue(this.asyncPromise)) {
Expand Down
3 changes: 1 addition & 2 deletions lib/commands/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export default {
els = /** @type {Element[]|undefined} */ (
await this.proxyCommand(endpoint, method, body)
);
} catch (err) {
} catch {
els = [];
}
// we succeed if we get some elements
Expand Down Expand Up @@ -162,7 +162,6 @@ export default {
// error, when the index gets higher than the number of child elements. This
// is what we want because that error will halt the loop and make it all the
// way to the client.
// eslint-disable-next-line no-constant-condition
while (true) {
const strategy = WDA_CLASS_CHAIN_STRATEGY;
const selector = `*[${index}]`;
Expand Down
2 changes: 0 additions & 2 deletions lib/commands/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ const commands = {
/**
* @this {XCUITestDriver}
*/
// eslint-disable-next-line require-await
async launchApp() {
throw new Error(
`The launchApp API has been deprecated and is not supported anymore. ` +
Expand All @@ -145,7 +144,6 @@ const commands = {
/**
* @this {XCUITestDriver}
*/
// eslint-disable-next-line require-await
async closeApp() {
throw new Error(
`The closeApp API has been deprecated and is not supported anymore. ` +
Expand Down
1 change: 0 additions & 1 deletion lib/commands/gesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const commands = {
/**
* @this {XCUITestDriver}
*/
// eslint-disable-next-line require-await
async releaseActions() {
this.log.warn('On this platform, releaseActions is a no-op');
},
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {
try {
await this.findNativeElementOrElements('class name', 'XCUIElementTypeKeyboard', false);
return true;
} catch (ign) {
} catch {
return false;
}
},
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {IOSCrashLog} from '../device-log/ios-crash-log';
import {IOSSimulatorLog} from '../device-log/ios-simulator-log';
import {IOSDeviceLog} from '../device-log/ios-device-log';
import WebSocket from 'ws';
import SafariConsoleLog from '../device-log/safari-console-log';
import SafariNetworkLog from '../device-log/safari-network-log';
import { SafariConsoleLog } from '../device-log/safari-console-log';
import { SafariNetworkLog } from '../device-log/safari-network-log';
import { toLogEntry } from '../device-log/helpers';
import { NATIVE_WIN } from '../utils';
import { BIDI_EVENT_NAME } from './bidi/constants';
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const commands = {
waitMs: CLOSE_WINDOW_TIMEOUT,
intervalMs: CLOSE_WINDOW_INTERVAL,
});
} catch (ign) {
} catch {
this.log.debug('Context has not yet been changed after closing window. Continuing...');
}
}
Expand Down
21 changes: 11 additions & 10 deletions lib/commands/performance.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async function requireXctrace() {
async function requireInstruments() {
try {
return await fs.which(INSTRUMENTS);
} catch (e) {
} catch {
throw new Error(
`${INSTRUMENTS} has not been found in PATH. ` +
`Please make sure XCode development tools are installed`,
Expand Down Expand Up @@ -106,7 +106,7 @@ export class PerfRecorder {
this._logger.debug('Force-stopping the currently running perf recording');
try {
await this._process.stop('SIGKILL');
} catch (ign) {}
} catch {}
}
this._process = null;
const performCleanup = async () => {
Expand All @@ -121,14 +121,15 @@ export class PerfRecorder {
}
};
if (this._archivePromise) {
this._archivePromise
// eslint-disable-next-line promise/prefer-await-to-then
.finally(async () => {
(async () => {
try {
await this._archivePromise;
} catch {
} finally {
await performCleanup();
this._archivePromise = null;
})
// eslint-disable-next-line promise/prefer-await-to-then, @typescript-eslint/no-empty-function
.catch(() => {});
}
})();
}
await performCleanup();
return '';
Expand Down Expand Up @@ -219,7 +220,7 @@ export class PerfRecorder {
intervalMs: 500,
},
);
} catch (e) {
} catch {
await this._enforceTermination();
const listProfilesCommand =
toolName === XCTRACE ? `${XCRUN} ${XCTRACE} list templates` : `${INSTRUMENTS} -s`;
Expand All @@ -245,7 +246,7 @@ export class PerfRecorder {

try {
await this._process?.stop('SIGINT', STOP_TIMEOUT_MS);
} catch (e) {
} catch {
throw this._logger.errorWithException(
`Performance recording has failed to exit after ${STOP_TIMEOUT_MS}ms`,
);
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/record-audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class AudioRecorder {
async start(timeoutSeconds) {
try {
await fs.which(FFMPEG_BINARY);
} catch (err) {
} catch {
throw new Error(
`'${FFMPEG_BINARY}' binary is not found in PATH. Install it using 'brew install ffmpeg'. ` +
`Check https://www.ffmpeg.org/download.html for more details.`,
Expand Down Expand Up @@ -69,7 +69,7 @@ export class AudioRecorder {
waitMs: PROCESS_STARTUP_TIMEOUT_MS,
intervalMs: 300,
});
} catch (e) {
} catch {
this.log.warn(
`Audio recording process did not start within ${PROCESS_STARTUP_TIMEOUT_MS}ms. Continuing anyway`,
);
Expand Down
8 changes: 4 additions & 4 deletions lib/commands/recordscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import {fs, tempDir, logger, util} from 'appium/support';
import {SubProcess} from 'teen_process';
import {encodeBase64OrUpload, isLocalHost} from '../utils';
import DEVICE_CONNECTIONS_FACTORY from '../device-connections-factory';
import {DEVICE_CONNECTIONS_FACTORY} from '../device-connections-factory';
import {WDA_BASE_URL} from 'appium-webdriveragent';
import {waitForCondition} from 'asyncbox';
import url from 'url';
Expand Down Expand Up @@ -42,7 +42,7 @@ export class ScreenRecorder {
async start(timeoutMs) {
try {
await fs.which(FFMPEG_BINARY);
} catch (err) {
} catch {
throw new Error(
`'${FFMPEG_BINARY}' binary is not found in PATH. Install it using 'brew install ffmpeg'. ` +
`Check https://www.ffmpeg.org/download.html for more details.`,
Expand All @@ -65,7 +65,7 @@ export class ScreenRecorder {
devicePort: remotePort,
usePortForwarding,
});
} catch (err) {
} catch {
this.log.warn(
`Cannot forward the local port ${remotePort} to ${remotePort} ` +
`on the device ${this.udid}. Set the custom value to 'mjpegServerPort' ` +
Expand Down Expand Up @@ -119,7 +119,7 @@ export class ScreenRecorder {
waitMs: startupTimeout,
intervalMs: 300,
});
} catch (e) {
} catch {
this.log.warn(
`Screen capture process did not start within ${startupTimeout}ms. Continuing anyway`,
);
Expand Down
11 changes: 5 additions & 6 deletions lib/commands/web.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {errors, isErrorType} from 'appium/driver';
import {timing, util} from 'appium/support';
import {retryInterval} from 'asyncbox';
import B from 'bluebird';
import B, {TimeoutError, AggregateError} from 'bluebird';
import _ from 'lodash';
import cookieUtils from '../cookies';
import * as cookieUtils from '../cookies';

const IPHONE_TOP_BAR_HEIGHT = 71;
const IPHONE_SCROLLED_TOP_BAR_HEIGHT = 41;
Expand Down Expand Up @@ -702,7 +702,7 @@ const extensions = {
await this.findNativeElementOrElements('class name', 'XCUIElementTypeWebView', false),
)
);
} catch (ign) {}
} catch {}

if (!webview) {
throw new Error(`No WebView found. Unable to translate web coordinates for native web tap.`);
Expand Down Expand Up @@ -783,9 +783,9 @@ const extensions = {
try {
return await p;
} catch (err) {
const originalError = err instanceof B.AggregateError ? err[0] : err;
const originalError = err instanceof AggregateError ? err[0] : err;
this.log.debug(`Error received while executing atom: ${originalError.message}`);
if (originalError instanceof B.TimeoutError) {
if (originalError instanceof TimeoutError) {
throw new errors.TimeoutError(
`Did not get any response for atom execution after ` +
`${timer.getDuration().asMilliSeconds.toFixed(0)}ms`,
Expand Down Expand Up @@ -833,7 +833,6 @@ const extensions = {
this._waitingAtoms.alertNotifier.once(ON_OBSTRUCTING_ALERT_EVENT, onAlertCallback);
this._waitingAtoms.alertNotifier.once(ON_APP_CRASH_EVENT, onAppCrashCallback);
handlePromiseError(timedAtomPromise)
// eslint-disable-next-line promise/prefer-await-to-then
.then(resolve)
.catch(reject);
});
Expand Down
7 changes: 4 additions & 3 deletions lib/commands/xctest.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ export default {

if (stderr) {
lastErrorMessage = stderr;
xctestLog.error(stderr);
}
if (stdout) {
xctestLog.info(stdout);
}

stdout && xctestLog.info(stdout);
stderr && xctestLog.error(stderr);
});

subproc.on('exit', (code, signal) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/device-connections-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,15 @@ class DeviceConnectionsFactory {
isPortBusy = false;
return true;
}
} catch (ign) {}
} catch {}
return false;
},
{
waitMs: PORT_CLOSE_TIMEOUT,
intervalMs: 300,
},
);
} catch (ign) {
} catch {
log.warn(
`Did not know how to release port #${port} in ` +
`${timer.getDuration().asMilliSeconds.toFixed(0)}ms`,
Expand Down
3 changes: 1 addition & 2 deletions lib/device-log/ios-crash-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import B from 'bluebird';
import path from 'path';
import _ from 'lodash';
import {Pyidevice} from '../real-device-clients/py-ios-device-client';
import IOSLog from './ios-log';
import {IOSLog} from './ios-log';
import { toLogEntry, grepFile } from './helpers';
import type { AppiumLogger } from '@appium/types';
import type { BaseDeviceClient } from '../real-device-clients/base-device-client';
Expand Down Expand Up @@ -59,7 +59,6 @@ export class IOSCrashLog extends IOSLog<TSerializedEntry, TSerializedEntry> {
this._started = true;
}

// eslint-disable-next-line require-await
override async stopCapture(): Promise<void> {
this._started = false;
}
Expand Down
1 change: 0 additions & 1 deletion lib/device-log/ios-device-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class IOSDeviceLog extends LineConsumingLog {
return !!this.service;
}

// eslint-disable-next-line require-await
override async stopCapture(): Promise<void> {
if (!this.service) {
return;
Expand Down
Loading

0 comments on commit 19e5f28

Please sign in to comment.