fix: Reduce linter warnings (#20860)

This commit is contained in:
Mykola Mokhnach
2024-12-28 09:30:05 +01:00
committed by GitHub
parent 25ea9f73bc
commit 65658ccbdd
74 changed files with 127 additions and 63 deletions
+2 -2
View File
@@ -91,7 +91,7 @@ export function onBidiConnection(this: AppiumDriver, ws: WebSocket, req: Incomin
this.log.error(err);
try {
ws.close();
} catch (ign) {}
} catch {}
}
}
@@ -211,7 +211,7 @@ function initBidiSocket(this: AppiumDriver, ws: WebSocket, req: IncomingMessage)
if (bidiProxyUrl) {
try {
new URL(bidiProxyUrl);
} catch (ign) {
} catch {
throw new Error(
`Got request for ${driverName} to proxy bidi connections to upstream socket with ` +
`url ${bidiProxyUrl}, but this was not a valid url`,
+5 -5
View File
@@ -115,7 +115,7 @@ export async function getGitRev(useGithubApiFallback = false) {
cwd: __dirname,
});
return stdout.trim();
} catch (ign) {}
} catch {}
}
if (!useGithubApiFallback) {
@@ -132,7 +132,7 @@ export async function getGitRev(useGithubApiFallback = false) {
},
})
).data?.object?.sha;
} catch (ign) {}
} catch {}
return null;
}
@@ -149,7 +149,7 @@ async function getGitTimestamp(commitSha, useGithubApiFallback = false) {
cwd: __dirname,
});
return stdout.trim();
} catch (ign) {}
} catch {}
}
if (!useGithubApiFallback) {
@@ -164,7 +164,7 @@ async function getGitTimestamp(commitSha, useGithubApiFallback = false) {
},
})
).data?.tagger?.date;
} catch (ign) {}
} catch {}
return null;
}
@@ -356,7 +356,7 @@ export async function requireDir(root, requireWriteable = true, displayName = 'f
if (requireWriteable) {
try {
await fs.access(root, fs.constants.W_OK);
} catch (e) {
} catch {
throw new Error(
`The ${displayName} '${root}' must be ` +
`writeable for the current user account '${os.userInfo().username}'`
@@ -571,7 +571,9 @@ export class ExtensionConfig {
try {
entryPointPath = JSON.parse(await fs.readFile(packageJsonPath, 'utf8')).main ?? 'index.js';
} catch (e) {
throw new ReferenceError(`Could not find a ${this.extensionType} installed at ${moduleRoot}`);
throw new ReferenceError(
`Could not find a ${this.extensionType} installed at ${moduleRoot}: ${e.message}`
);
}
if (entryPointPath) {
entryPointPath = path.resolve(moduleRoot, entryPointPath);
+2 -2
View File
@@ -1,4 +1,4 @@
import Ajv from 'ajv';
import {Ajv} from 'ajv';
import addFormats from 'ajv-formats';
import _ from 'lodash';
import path from 'path';
@@ -453,7 +453,7 @@ class AppiumSchema {
let refSchema;
try {
refSchema = this.getSchema($ref);
} catch (err) {
} catch {
// this can happen if an extension schema supplies a $ref to a non-existent schema
throw new SchemaUnknownSchemaError($ref);
}
+1 -1
View File
@@ -250,7 +250,7 @@ export function adjustNodePath() {
require('module').Module._initPaths();
return true;
} catch (e) {
} catch {
return false;
}
};
@@ -85,10 +85,10 @@ async function init() {
}
try {
({env, util, logger} = require('@appium/support'));
// @ts-ignore
// @ts-ignore This is OK
({runExtensionCommand} = require('../build/lib/cli/extension'));
({DRIVER_TYPE, PLUGIN_TYPE} = require('../build/lib/constants'));
// @ts-ignore
// @ts-ignore This is OK
({loadExtensions} = require('../build/lib/extension'));
logger.getLogger('Appium').level = 'error';
@@ -119,7 +119,7 @@ async function main() {
if (!driverEnv && !pluginEnv) {
spinner.succeed(
wrap(`No drivers or plugins to automatically install.
wrap(`No drivers or plugins to automatically install.
If desired, provide arguments with comma-separated values "--drivers=<known_driver>[,known_driver...]" and/or "--plugins=<known_plugin>[,known_plugin...]" to the "npm install appium" command. The specified extensions will be installed automatically with Appium. Note: to see the list of known extensions, run "appium <driver|plugin> list".`)
);
return;
@@ -193,7 +193,7 @@ async function checkAndInstallExtension({
spinner,
}) {
const extList = await runExtensionCommand(
// @ts-ignore
// @ts-ignore This is OK
{
appiumHome,
subcommand: type,
@@ -209,7 +209,7 @@ async function checkAndInstallExtension({
}
spinner.start(`Installing ${type} "${ext}"...`);
await runExtensionCommand(
// @ts-ignore
// @ts-ignore this is OK
{
subcommand: type,
appiumHome,
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {getGitRev, getBuildInfo, updateBuildInfo, APPIUM_VER} from '../../lib/config';
import axios from 'axios';
@@ -6,6 +6,7 @@ import {fs, tempDir} from '@appium/support';
import axios from 'axios';
import B from 'bluebird';
import _ from 'lodash';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {remote as wdio} from 'webdriverio';
import {runExtensionCommand} from '../../lib/cli/extension';
@@ -6,6 +6,7 @@ import {BaseDriver} from '@appium/base-driver';
import {FakeDriver} from '@appium/fake-driver';
import {sleep} from 'asyncbox';
import _ from 'lodash';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {finalizeSchema, registerSchema, resetSchema} from '../../lib/schema/schema';
import {insertAppiumPrefixes, removeAppiumPrefixes} from '../../lib/utils';
@@ -2,6 +2,7 @@ import {tempDir, fs, npm} from '@appium/support';
import {loadExtensions} from '../../../lib/extension';
import {Manifest} from '../../../lib/extension/manifest';
import DriverCommand from '../../../lib/cli/driver-command';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
describe('DriverCommand', function () {
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {finalizeSchema, resetSchema, SchemaFinalizationError} from '../../../lib/schema/schema';
import {rewiremock} from '../../helpers';
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {system} from '@appium/support';
import {getPresetDrivers} from '../../../lib/cli/setup-command';
@@ -1,6 +1,7 @@
// @ts-check
import fs from 'fs';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import YAML from 'yaml';
import * as schema from '../../lib/schema/schema';
+1
View File
@@ -1,6 +1,7 @@
// @ts-check
import _ from 'lodash';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {getParser} from '../../lib/cli/parser';
import {
@@ -7,6 +7,7 @@
import {EventEmitter} from 'events';
import path from 'path';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {version as APPIUM_VER} from '../../../package.json';
@@ -1,5 +1,6 @@
// @ts-check
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {rewiremock} from '../helpers';
+1
View File
@@ -1,4 +1,5 @@
import {init as logsinkInit, clear as logsinkClear} from '../../lib/logsink';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {logger} from '@appium/support';
@@ -1,6 +1,7 @@
// @ts-check
import _ from 'lodash';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {DRIVER_TYPE, PLUGIN_TYPE} from '../../../lib/constants';
import {AppiumConfigJsonSchema} from '@appium/schema';
+1
View File
@@ -10,6 +10,7 @@ import {
import {BASE_CAPS, W3C_CAPS} from '../helpers';
import _ from 'lodash';
import {stripColors} from '@colors/colors';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import logger from '../../lib/logger';
import {fs} from '@appium/support';
@@ -76,19 +76,23 @@ const TimeoutCommands: ITimeoutCommands = {
},
// pageLoad
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async pageLoadTimeoutW3C<C extends Constraints>(this: BaseDriver<C>, ms) {
throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async pageLoadTimeoutMJSONWP<C extends Constraints>(this: BaseDriver<C>, ms) {
throw new errors.NotImplementedError('Not implemented yet for pageLoad.');
},
// script
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async scriptTimeoutW3C<C extends Constraints>(this: BaseDriver<C>, ms) {
throw new errors.NotImplementedError('Not implemented yet for script.');
},
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async scriptTimeoutMJSONWP<C extends Constraints>(this: BaseDriver<C>, ms) {
throw new errors.NotImplementedError('Not implemented yet for script.');
},
+8 -3
View File
@@ -24,8 +24,8 @@ import {
MAX_LOG_BODY_LENGTH,
} from '../constants';
import {errors} from '../protocol';
import DeviceSettings from './device-settings';
import helpers, {BASEDRIVER_VER} from './helpers';
import {DeviceSettings} from './device-settings';
import * as helpers from './helpers';
import {BIDI_COMMANDS} from '../protocol/bidi-commands';
const NEW_COMMAND_TIMEOUT_MS = 60 * 1000;
@@ -42,7 +42,7 @@ export class DriverCore<const C extends Constraints, Settings extends StringReco
* Make the basedriver version available so for any driver which inherits from this package, we
* know which version of basedriver it inherited from
*/
static baseVersion = BASEDRIVER_VER;
static baseVersion = helpers.BASEDRIVER_VER;
sessionId: string | null;
@@ -239,6 +239,7 @@ export class DriverCore<const C extends Constraints, Settings extends StringReco
* method required by MJSONWP in order to determine if the command should
* be proxied directly to the driver
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
driverForSession(sessionId: string): Core<Constraints> | null {
return this as Core<Constraints>;
}
@@ -364,14 +365,17 @@ export class DriverCore<const C extends Constraints, Settings extends StringReco
return null;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
proxyActive(sessionId: string): boolean {
return false;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getProxyAvoidList(sessionId: string): RouteMatcher[] {
return [];
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
canProxy(sessionId: string): boolean {
return false;
}
@@ -389,6 +393,7 @@ export class DriverCore<const C extends Constraints, Settings extends StringReco
*
* @returns whether the route should be avoided
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
proxyRouteIsAvoided(sessionId: string, method: HTTPMethod, url: string, body?: any): boolean {
for (const avoidSchema of this.getProxyAvoidList(sessionId)) {
if (!_.isArray(avoidSchema) || avoidSchema.length !== 2) {
@@ -24,7 +24,7 @@ import {calcSignature} from '../helpers/session';
import {DELETE_SESSION_COMMAND, determineProtocol, errors} from '../protocol';
import {processCapabilities, validateCaps} from './capabilities';
import {DriverCore} from './core';
import helpers from './helpers';
import * as helpers from './helpers';
const EVENT_SESSION_INIT = 'newSessionRequested';
const EVENT_SESSION_START = 'newSessionStarted';
@@ -389,8 +389,8 @@ export function parseCapsArray(cap) {
if (_.isArray(parsedCaps)) {
return parsedCaps;
}
} catch (ign) {
logger.warn(`Failed to parse capability as JSON array`);
} catch (e) {
logger.warn(`Failed to parse capability as JSON array: ${e.message}`);
}
if (_.isString(cap)) {
return [cap];
@@ -406,6 +406,7 @@ export function parseCapsArray(cap) {
* This parameter is deprecated and is not used.
* @returns {string}
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function generateDriverLogPrefix(obj, sessionId = null) {
return `${obj.constructor.name}@${node.getObjectId(obj).substring(0, 4)}`;
}
@@ -49,7 +49,7 @@ const startLogFormatter = morgan(
reqBody = _.truncate(_.isString(req.body) ? req.body : JSON.stringify(req.body), {
length: MAX_LOG_BODY_LENGTH,
});
} catch (ign) {}
} catch {}
}
log.info(requestStartLoggingFormat(tokens, req, res), reqBody.grey);
},
@@ -151,6 +151,7 @@ function configureServer({
// set up static assets
app.use(favicon(path.resolve(STATIC_DIR, 'favicon.ico')));
// eslint-disable-next-line import/no-named-as-default-member
app.use(express.static(STATIC_DIR));
// crash routes, for testing
@@ -41,7 +41,7 @@ async function removeWebSocketHandler(handlerPathname) {
client.terminate();
}
return true;
} catch (ign) {
} catch {
// ignore
} finally {
delete this.webSocketsMapping[handlerPathname];
+1 -1
View File
@@ -4,7 +4,7 @@ try {
B.config({
cancellation: true,
});
} catch (ign) {
} catch {
// sometimes during testing this somehow gets required twice and results in an error about
// cancellation not being able to be enabled after promise has been configured
}
@@ -207,7 +207,7 @@ class JWProxy {
if (typeof body !== 'object') {
try {
reqOpts.data = JSON.parse(body);
} catch (e) {
} catch {
throw new Error(`Cannot interpret the request body as valid JSON: ${truncateBody(body)}`);
}
} else {
@@ -1,5 +1,6 @@
import {server} from '../../../lib';
import axios from 'axios';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import B from 'bluebird';
import _ from 'lodash';
@@ -85,7 +86,11 @@ describe('server', function () {
}).should.be.rejectedWith(/EADDRINUSE/);
});
it('should not wait for the server close connections before finishing closing', async function () {
let bodyPromise = axios.get(`http://${TEST_HOST}:${port}/pause`).catch(() => {});
const bodyPromise = (async () => {
try {
return await axios.get(`http://${TEST_HOST}:${port}/pause`);
} catch {}
})();
// relinquish control so that we don't close before the request is received
await B.delay(100);
@@ -188,7 +193,7 @@ describe('server plugins', function () {
afterEach(async function () {
try {
await hwServer.close();
} catch (ign) {}
} catch {}
});
function updaterWithGetRoute(route, reply) {
@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-named-as-default
import Express from 'express';
import bodyParser from 'body-parser';
@@ -1,6 +1,7 @@
import {server, routeConfiguringFunction, errors, JWProxy, BaseDriver} from '../../../lib';
import {FakeDriver} from './fake-driver';
import axios from 'axios';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {StatusCodes as HTTPStatusCodes} from 'http-status-codes';
import {createProxyServer} from './helpers';
@@ -3,6 +3,7 @@
import B from 'bluebird';
import {BaseDriver, errors} from '../../../lib/index';
import {validator} from '../../../lib/basedriver/desired-caps';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
// TODO: we need module-level mocks for the logger
@@ -1,4 +1,5 @@
// @ts-check
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import _ from 'lodash';
import {BaseDriver} from '../../../../lib';
@@ -1,6 +1,7 @@
// @ts-check
import {BaseDriver} from '../../../lib';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
describe('timeout', function () {
@@ -2,6 +2,7 @@
import {server, routeConfiguringFunction} from '../../../lib';
import {configureServer, normalizeBasePath} from '../../../lib/express/server';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {getTestPort} from '@appium/driver-test-support';
@@ -1,4 +1,5 @@
import {welcome} from '../../../lib/express/static';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
describe('welcome', function () {
@@ -17,7 +17,7 @@ function buildReqRes(url, method, body) {
res.send = (body) => {
try {
body = JSON.parse(body);
} catch (e) {}
} catch {}
res.sentBody = body;
};
return [req, res];
@@ -1,4 +1,4 @@
import BasePlugin from '../../lib/plugin';
import {BasePlugin} from '../../lib/plugin';
describe('base plugin', function () {
let should;
+1
View File
@@ -10,6 +10,7 @@ import {getLogger} from '../logger';
import {fs} from '@appium/support';
import _ from 'lodash';
// eslint-disable-next-line import/named
import {sync as readPkg} from 'read-pkg';
import {hideBin} from 'yargs/helpers';
import yargs from 'yargs/yargs';
+1
View File
@@ -7,6 +7,7 @@
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {ConsolaInstance, createConsola, LogLevel} = require('consola');
import _ from 'lodash';
import {DEFAULT_LOG_LEVEL, LogLevelMap} from './constants';
+2 -2
View File
@@ -1,5 +1,5 @@
import getPort from 'get-port';
import {curry} from 'lodash';
import _ from 'lodash';
/**
* Default test host
@@ -31,7 +31,7 @@ async function getTestPort(force = false) {
* To rearrange arguments (if needed), use the placeholder from Lodash (`_`).
*
*/
const createAppiumURL = curry(
const createAppiumURL = _.curry(
/**
* @param {string} address - Base address (w/ optional protocol)
* @param {string|number} port - Port number
@@ -1,5 +1,6 @@
import _ from 'lodash';
import B from 'bluebird';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
// wrap these tests in a function so we can export the tests and re-use them
@@ -74,7 +74,7 @@ function coerceScriptResult(obj) {
// get rid of custom objects, functions, etc... and turn them into POJOs
try {
obj = JSON.parse(JSON.stringify(obj));
} catch (e) {
} catch {
log.warn(
'Could not convert executeDriverScript to safe response!' +
`Result was: ${JSON.stringify(obj)}. Will make it null`,
+1 -1
View File
@@ -46,7 +46,7 @@ const AlertMixin: FakeDriverAlertMixin = {
this.assertAlert();
try {
this.appModel.setAlertText(text);
} catch (e) {
} catch {
throw new errors.InvalidElementStateError();
}
},
+2 -1
View File
@@ -1,7 +1,8 @@
import {ActionSequence, Location, Rect, Size} from '@appium/types';
import {errors} from 'appium/driver';
import {FakeDriver, Orientation} from '../driver';
import {FakeDriver} from '../driver';
import {mixin} from './mixin';
import type {Orientation} from '../driver';
const ORIENTATIONS = new Set(['LANDSCAPE', 'PORTRAIT']);
+1 -1
View File
@@ -2,7 +2,7 @@ import {fs} from 'appium/support';
import {readFileSync} from 'fs';
import path from 'path';
import XMLDom from '@xmldom/xmldom';
import xpath from 'xpath';
import * as xpath from 'xpath';
import log from './logger';
import _ from 'lodash';
import {FakeElement} from './fake-element';
+1 -1
View File
@@ -41,7 +41,7 @@ async function initSession(w3cPrefixedCaps) {
async function deleteSession(driver) {
try {
await driver.deleteSession();
} catch (ign) {}
} catch {}
}
export {
+1 -1
View File
@@ -44,7 +44,7 @@ async function compareImages(mode, firstImage, secondImage, options = {}) {
result = await getImagesMatches(
img1, img2, /** @type {import('@appium/opencv').MatchingOptions} */(options)
);
} catch (err) {
} catch {
// might throw if no matches
result = /** @type {import('@appium/opencv').MatchingResult} */({count: 0});
}
+1 -1
View File
@@ -157,7 +157,7 @@ export default class ImageElement {
ignoreDefaultImageTemplateScale: true,
containerRect: this.containerRect,
}));
} catch (err) {
} catch {
throw new errors.StaleElementReferenceError();
}
+1 -1
View File
@@ -24,7 +24,7 @@ export class OpenCvAutoreleasePool {
for (const item of this._items) {
try {
item.delete();
} catch (ign) {}
} catch {}
}
this._items.clear();
}
@@ -2,6 +2,7 @@
import {fs} from 'appium/support';
import {main as appiumServer} from 'appium';
import getPort from 'get-port';
// eslint-disable-next-line import/named
import {info, success, warning} from 'log-symbols';
import {exec} from 'teen_process';
@@ -35,6 +36,7 @@ export function pluginE2EHarness(opts) {
*/
let server;
// eslint-disable-next-line mocha/no-top-level-hooks
before(async function () {
const chai = await import('chai');
const chaiAsPromised = await import('chai-as-promised');
@@ -134,6 +136,7 @@ export function pluginE2EHarness(opts) {
await createServer();
});
// eslint-disable-next-line mocha/no-top-level-hooks
after(async function () {
if (server) {
await server.close();
@@ -41,7 +41,7 @@ async function write() {
let schema;
try {
({AppiumConfigJsonSchema: schema} = require(SCHEMA_SRC));
} catch (err) {
} catch {
throw new Error(
`${error} Failed to read ${SCHEMA_SRC}; did you execute \`npm run build\` first?`
);
@@ -1,6 +1,11 @@
import path from 'node:path';
import rewiremock from 'rewiremock/node';
import {createSandbox, SinonSandbox, SinonStubbedMember} from 'sinon';
import {
// eslint-disable-next-line import/named
createSandbox,
SinonSandbox,
SinonStubbedMember
} from 'sinon';
import type fs from 'node:fs/promises';
import {Item, Strongbox} from '../../lib';
@@ -1,7 +1,13 @@
import path from 'node:path';
import rewiremock from 'rewiremock/node';
import type {Strongbox as TStrongbox, StrongboxOpts, Item, Value} from '../../lib';
import {createSandbox, SinonSandbox, SinonStubbedMember, SinonStub} from 'sinon';
import {
// eslint-disable-next-line import/named
createSandbox,
SinonSandbox,
SinonStubbedMember,
SinonStub
} from 'sinon';
import type fs from 'node:fs/promises';
type MockFs = {
+2 -2
View File
@@ -16,7 +16,7 @@ async function initMJpegConsumer() {
if (!MJpegConsumer) {
try {
MJpegConsumer = await requirePackage('mjpeg-consumer');
} catch (ign) {}
} catch {}
}
if (!MJpegConsumer) {
throw new Error(
@@ -78,7 +78,7 @@ class MJpegStream extends Writable {
try {
return await requireSharp()(lastChunk).png().toBuffer();
} catch (e) {
} catch {
return null;
}
}
+2 -2
View File
@@ -1,10 +1,10 @@
import _ from 'lodash';
import fs from './fs';
import {fs} from './fs';
import B from 'bluebird';
import {toReadableSizeString} from './util';
import log from './logger';
import Ftp from 'jsftp';
import Timer from './timing';
import {Timer} from './timing';
import axios from 'axios';
import FormData from 'form-data';
+2 -2
View File
@@ -189,7 +189,7 @@ function deepFreeze(object) {
let propNames;
try {
propNames = Object.getOwnPropertyNames(object);
} catch (ign) {
} catch {
return object;
}
for (const name of propNames) {
@@ -220,7 +220,7 @@ function getModuleRootSync (moduleName, filePath) {
JSON.parse(_fs.readFileSync(manifestPath, 'utf8')).name === moduleName) {
return currentDir;
}
} catch (ign) {}
} catch {}
currentDir = path.dirname(currentDir);
isAtFsRoot = currentDir.length <= path.dirname(currentDir).length;
}
+1 -1
View File
@@ -77,7 +77,7 @@ export class NPM {
// guaranteed to be parseable
try {
ret.json = JSON.parse(stdout);
} catch (ign) {}
} catch {}
} catch (e) {
const {
stdout = '',
+2 -2
View File
@@ -1,7 +1,7 @@
import xmlplist from 'plist';
import bplistCreate from 'bplist-creator';
import bplistParse from 'bplist-parser';
import fs from './fs';
import {fs} from './fs';
import log from './logger';
import _ from 'lodash';
@@ -47,7 +47,7 @@ async function parsePlistFile(plist, mustExist = true, quiet = true) {
} else {
throw new Error(`Binary file '${plist}'' appears to be empty`);
}
} catch (ign) {
} catch {
try {
obj = await parseXmlPlistFile(plist);
type = 'xml';
+1 -1
View File
@@ -1,5 +1,5 @@
/* This library is originated from temp.js at http://github.com/bruce/node-temp */
import fs from './fs';
import {fs} from './fs';
import os from 'os';
import nodePath from 'path';
import cnst from 'constants';
+2 -1
View File
@@ -113,6 +113,7 @@ function cancellableDelay(ms) {
// a promise, since `resolve`/`reject` are never called
delay.cancel = function () {
clearTimeout(timer);
// eslint-disable-next-line import/no-named-as-default-member
reject(new B.CancellationError());
};
return delay;
@@ -131,7 +132,7 @@ function multiResolve(roots, ...args) {
function safeJsonParse(obj) {
try {
return JSON.parse(obj);
} catch (ign) {
} catch {
// ignore: this is not json parsable
return obj;
}
+4 -3
View File
@@ -5,11 +5,11 @@ import archiver from 'archiver';
import {createWriteStream} from 'fs';
import path from 'path';
import stream from 'stream';
import fs from './fs';
import {fs} from './fs';
import {isWindows} from './system';
import {Base64Encode} from 'base64-stream';
import {toReadableSizeString, GiB} from './util';
import Timer from './timing';
import {Timer} from './timing';
import log from './logger';
import getStream from 'get-stream';
import {exec} from 'teen_process';
@@ -17,6 +17,7 @@ import {exec} from 'teen_process';
/**
* @type {(path: string, options?: yauzl.Options) => Promise<yauzl.ZipFile>}
*/
// eslint-disable-next-line import/no-named-as-default-member
const openZip = B.promisify(yauzl.open);
/**
* @type {(source: NodeJS.ReadableStream, destination: NodeJS.WritableStream) => Promise<NodeJS.WritableStream>}
@@ -229,7 +230,7 @@ async function extractWithSystemUnzip(zipFilePath, destDir) {
let executablePath;
try {
executablePath = await getExecutablePath(isWindowsHost ? 'powershell.exe' : 'unzip');
} catch (e) {
} catch {
throw new Error('Could not find system unzip');
}
+1 -1
View File
@@ -1,4 +1,4 @@
import fs from '../../lib/fs';
import {fs} from '../../lib/fs';
import {isWindows} from '../../lib/system';
describe('isExecutable()', function () {
+1 -1
View File
@@ -61,7 +61,7 @@ describe('#util', function () {
afterEach(async function () {
try {
await B.all([lockFile, testFile].map((p) => fs.unlink(p)));
} catch (ign) {}
} catch {}
});
it('should lock a file during the given behavior', async function () {
+1
View File
@@ -6,6 +6,7 @@
*/
import path from 'path';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
export function initMocks(sandbox = createSandbox()) {
+1
View File
@@ -1,5 +1,6 @@
import {fs, system, tempDir} from '../../lib';
import path from 'path';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {exec} from 'teen_process';
import _ from 'lodash';
@@ -1,4 +1,5 @@
import * as teenProcess from 'teen_process';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {process, system} from '../../lib';
import {retryInterval} from 'asyncbox';
@@ -1,5 +1,6 @@
import {system} from '../../lib';
import os from 'os';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import * as teen_process from 'teen_process';
import _ from 'lodash';
@@ -1,4 +1,5 @@
import _ from 'lodash';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import {timing} from '../../lib';
+1
View File
@@ -1,5 +1,6 @@
import {util, fs, tempDir} from '../../lib';
import B from 'bluebird';
// eslint-disable-next-line import/named
import {createSandbox} from 'sinon';
import os from 'os';
import path from 'path';
+1 -1
View File
@@ -1,5 +1,5 @@
import {AsyncReturnType} from 'type-fest';
import {BidiModuleMap, ExecuteMethodMap, MethodMap} from './command';
import {ExecuteMethodMap, MethodMap} from './command';
import {DriverCommand, ExternalDriver} from './driver';
import {AppiumLogger} from './logger';
import {UpdateServerCallback} from './server';
+1 -1
View File
@@ -1,4 +1,4 @@
import UniversalXMLPlugin from './plugin';
import {UniversalXMLPlugin} from './plugin';
import {transformSourceXml} from './source';
import fs from 'fs';
export default UniversalXMLPlugin;
@@ -1,5 +1,5 @@
import {UniversalXMLPlugin} from '../..';
import BaseDriver from 'appium/driver';
import {BaseDriver} from 'appium/driver';
import {
XML_IOS,
XML_ANDROID,
+1 -1
View File
@@ -36,7 +36,7 @@ export async function walk(dir, ext) {
let stats;
try {
stats = await fs.stat(fullPath);
} catch (e) {
} catch {
continue;
}
if (stats.isDirectory()) {