Skip to content

Commit

Permalink
fix'em all
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach committed Jan 3, 2025
1 parent b67411f commit 4f0dcb5
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 56 deletions.
3 changes: 0 additions & 3 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: [
'test/assets/**',
],
},
];
2 changes: 1 addition & 1 deletion lib/defaults-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';
import { DOMParser, XMLSerializer } from '@xmldom/xmldom';
import { exec } from 'teen_process';
import B from 'bluebird';
import log from './logger';
import { log } from './logger';

/**
* Serializes the given value to plist-compatible
Expand Down
2 changes: 1 addition & 1 deletion lib/device-utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Simctl from 'node-simctl';
import { Simctl } from 'node-simctl';

/**
* @param {import('@appium/types').StringRecord} [simctlOpts]
Expand Down
10 changes: 5 additions & 5 deletions lib/extensions/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export async function getUserInstalledBundleIdsByBundleName (bundleName) {
bundleInfoPromises.push((async () => {
try {
return await plist.parsePlistFile(infoPlist);
} catch (ign) {}
} catch {}
})());
}
const bundleInfos = (await B.all(bundleInfoPromises)).filter(_.isPlainObject);
Expand Down Expand Up @@ -69,14 +69,14 @@ export async function isAppInstalled (bundleId) {
return false;
}
return await fs.exists(appContainer);
} catch (err) {
} catch {
// get_app_container subcommand fails for system applications,
// so we try the hidden appinfo subcommand, which prints correct info for
// system/hidden apps
try {
const info = await this.simctl.appInfo(bundleId);
return info.includes('ApplicationType');
} catch (ign) {}
} catch {}
}
return false;
}
Expand Down Expand Up @@ -113,7 +113,7 @@ export async function launchApp (bundleId, opts = {}) {
waitMs: timeoutMs,
intervalMs: 300
});
} catch (e) {
} catch {
throw new Error(`App '${bundleId}' is not runnning after ${timeoutMs}ms timeout.`);
}
}
Expand Down Expand Up @@ -160,7 +160,7 @@ export async function scrubApp (bundleId) {

try {
await this.terminateApp(bundleId);
} catch (ign) {}
} catch {}
await B.all(appFiles.map((p) => fs.rimraf(p)));
}

Expand Down
2 changes: 1 addition & 1 deletion lib/extensions/geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function setGeolocation (latitude, longitude) {
async function setLocationWithLyft (udid, latitude, longitude) {
try {
await fs.which(LYFT_SET_LOCATION);
} catch (e) {
} catch {
throw new Error(`'${LYFT_SET_LOCATION}' binary has not been found in your PATH. ` +
'Please install it as "brew install lyft/formulae/set-simulator-location" by brew or ' +
'read https://github.com/MobileNativeFoundation/set-simulator-location to set ' +
Expand Down
2 changes: 0 additions & 2 deletions lib/extensions/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export async function shake () {
* @returns {Promise<boolean>} `true` if the certificate has been successfully installed
* or `false` if it has already been there
*/
// eslint-disable-next-line require-await
export async function addCertificate (payload, opts = {}) {
throw new Error(`Xcode SDK '${this.xcodeVersion}' is too old add certificates`);
}
Expand All @@ -35,7 +34,6 @@ export async function addCertificate (payload, opts = {}) {
* @returns {Promise<void>}
* @since Xcode SDK 11.4
*/
// eslint-disable-next-line require-await
export async function pushNotification (payload) {
throw new Error(`Xcode SDK '${this.xcodeVersion}' is too old to push notifications`);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/extensions/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ async function execSQLiteQuery (db, query) {
async function execWix (args) {
try {
await fs.which(WIX_SIM_UTILS);
} catch (e) {
} catch {
throw new Error(
`${WIX_SIM_UTILS} binary has not been found in your PATH. ` +
`Please install it ('brew tap wix/brew && brew install wix/brew/applesimutils') to ` +
Expand Down
4 changes: 2 additions & 2 deletions lib/extensions/safari.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export async function openUrl (url) {
waitMs: SAFARI_STARTUP_TIMEOUT_MS,
intervalMs: 500,
});
} catch (err) {
} catch {
const secondsElapsed = timer.getDuration().asSeconds;
if (psError) {
this.log.warn(`Mobile Safari process existence cannot be verified after ${secondsElapsed.toFixed(3)}s. ` +
Expand All @@ -73,7 +73,7 @@ export async function openUrl (url) {
export async function scrubSafari (keepPrefs = true) {
try {
await this.terminateApp(MOBILE_SAFARI_BUNDLE_ID);
} catch (ign) {}
} catch {}

this.log.debug('Scrubbing Safari data files');
const safariData = await this.simctl.getAppContainer(MOBILE_SAFARI_BUNDLE_ID, 'data');
Expand Down
4 changes: 2 additions & 2 deletions lib/extensions/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function updateSettings (domain, updates) {
* @since Xcode SDK 11.4
* @returns {Promise<void>}
*/
export async function setAppearance (value) { // eslint-disable-line require-await
export async function setAppearance (value) {
throw new Error(`Xcode SDK '${this.xcodeVersion}' is too old to set UI appearance`);
}

Expand All @@ -99,7 +99,7 @@ export async function setAppearance (value) { // eslint-disable-line require-awa
* @returns {Promise<string>}
* @since Xcode SDK 11.4
*/
export async function getAppearance () { // eslint-disable-line require-await
export async function getAppearance () {
throw new Error(`Xcode SDK '${this.xcodeVersion}' is too old to get UI appearance`);
}

Expand Down
10 changes: 5 additions & 5 deletions lib/simulator-xcode-10.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import _ from 'lodash';
import path from 'path';
import B from 'bluebird';
import { getPath as getXcodePath } from 'appium-xcode';
import Simctl from 'node-simctl';
import { Simctl } from 'node-simctl';
import * as appExtensions from './extensions/applications';
import * as biometricExtensions from './extensions/biometric';
import * as safariExtensions from './extensions/safari';
Expand Down Expand Up @@ -238,7 +238,7 @@ export class SimulatorXcode10 extends EventEmitter {
try {
await this.simctl.getEnv('dummy');
return true;
} catch (e) {
} catch {
return false;
}
}
Expand Down Expand Up @@ -269,7 +269,7 @@ export class SimulatorXcode10 extends EventEmitter {
let stdout;
try {
({stdout} = await exec('pgrep', ['-fn', `${SIMULATOR_APP_NAME}/Contents/MacOS/`]));
} catch (e) {
} catch {
return null;
}
if (isNaN(parseInt(stdout, 10))) {
Expand Down Expand Up @@ -383,7 +383,7 @@ export class SimulatorXcode10 extends EventEmitter {
waitMs,
intervalMs: 100,
});
} catch (err) {
} catch {
throw new Error(`Simulator is not in 'Shutdown' state after ${waitMs}ms`);
}
}
Expand Down Expand Up @@ -458,7 +458,7 @@ export class SimulatorXcode10 extends EventEmitter {
waitMs: 5000,
intervalMs: 100,
});
} catch (e) {
} catch {
if (!await this.isRunning()) {
throw new Error(`Simulator with UDID '${this.udid}' cannot be transitioned to headless mode`);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/simulator-xcode-15.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class SimulatorXcode15 extends SimulatorXcode14 {
'-c', 'print CFBundleIdentifier', infoPlistPath
]);
return _.trim(stdout);
} catch (ign) {
} catch {
return null;
}
};
Expand All @@ -65,7 +65,7 @@ export class SimulatorXcode15 extends SimulatorXcode14 {
try {
const appContainer = await this.simctl.getAppContainer(bundleId);
return appContainer.endsWith('.app') && await fs.exists(appContainer);
} catch (ign) {
} catch {
// get_app_container subcommand fails for system applications,
// as well as the hidden appinfo command
return (await this._fetchSystemAppBundleIds()).has(bundleId);
Expand Down
2 changes: 1 addition & 1 deletion lib/simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SimulatorXcode11_4 } from './simulator-xcode-11.4';
import { SimulatorXcode14 } from './simulator-xcode-14';
import { SimulatorXcode15 } from './simulator-xcode-15';
import { getSimulatorInfo } from './utils';
import xcode from 'appium-xcode';
import * as xcode from 'appium-xcode';
import { log } from './logger';

const MIN_SUPPORTED_XCODE_VERSION = 10;
Expand Down
8 changes: 4 additions & 4 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import log from './logger';
import { log } from './logger';
import _ from 'lodash';
import { exec } from 'teen_process';
import { waitForCondition } from 'asyncbox';
Expand Down Expand Up @@ -53,7 +53,7 @@ export async function killAllSimulators (timeout = DEFAULT_SIM_SHUTDOWN_TIMEOUT_

try {
await exec('xcrun', ['simctl', 'shutdown', xcodeVersion.major > 8 ? 'all' : 'booted'], {timeout});
} catch (ign) {}
} catch {}

const pids = [];
try {
Expand All @@ -74,13 +74,13 @@ export async function killAllSimulators (timeout = DEFAULT_SIM_SHUTDOWN_TIMEOUT_
log.debug(`Killing processes: ${pids.join(', ')}`);
try {
await exec('kill', ['-9', ...(pids.map((pid) => `${pid}`))]);
} catch (ign) {}
} catch {}
}

log.debug(`Using pkill to kill application: ${appName}`);
try {
await pkill(appName, true);
} catch (ign) {}
} catch {}

// wait for all the devices to be shutdown before Continuing
// but only print out the failed ones when they are actually fully failed
Expand Down
2 changes: 1 addition & 1 deletion test/functional/simulator-e2e-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import _ from 'lodash';
import { killAllSimulators, MOBILE_SAFARI_BUNDLE_ID } from '../../lib/utils';
import { getSimulator } from '../../lib/simulator';
import Simctl from 'node-simctl';
import { Simctl } from 'node-simctl';
import B from 'bluebird';
import { retryInterval, waitForCondition } from 'asyncbox';
import path from 'path';
Expand Down
4 changes: 2 additions & 2 deletions test/functional/utils-e2e-specs.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// transpile:mocha
import { killAllSimulators } from '../../lib/utils';
import { getSimulator } from '../../lib/simulator';
import Simctl from 'node-simctl';
import { Simctl } from 'node-simctl';
import { LONG_TIMEOUT, verifyStates } from './helpers';

const OS_VERSION = process.env.MOBILE_OS_VERSION || '14.0';
Expand Down Expand Up @@ -35,7 +35,7 @@ describe('killAllSimulators', function () {
await killAllSimulators();
try {
await sim.simctl.deleteDevice();
} catch (ign) {}
} catch {}
});
it('should be able to kill the simulators', async function () {
await verifyStates(sim, true, true);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/utils-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('util', function () {

try {
await killAllSimulators(500);
} catch (e) {}
} catch {}
execStub.callCount.should.equal(3);
});
});
Expand Down

0 comments on commit 4f0dcb5

Please sign in to comment.