diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 5d126348..00000000 --- a/.editorconfig +++ /dev/null @@ -1,13 +0,0 @@ -# editorconfig.org -root = true - -[*] -indent_style = space -indent_size = 2 -end_of_line = lf -charset = utf-8 -trim_trailing_whitespace = true -insert_final_newline = true - -[*.md] -trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index fb7020db..00000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -coverage -build diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 00000000..4d523257 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,5 @@ +import appiumConfig from '@appium/eslint-config-appium-ts'; + +export default [ + ...appiumConfig, +]; diff --git a/lib/chromedriver.js b/lib/chromedriver.js index 83de4531..b67d4b1d 100644 --- a/lib/chromedriver.js +++ b/lib/chromedriver.js @@ -12,11 +12,11 @@ import { getChromedriverBinaryPath, generateLogPrefix, } from './utils'; -import semver from 'semver'; +import * as semver from 'semver'; import _ from 'lodash'; import path from 'path'; import {compareVersions} from 'compare-versions'; -import ChromedriverStorageClient from './storage-client/storage-client'; +import { ChromedriverStorageClient } from './storage-client/storage-client'; import {toW3cCapNames, getCapValue} from './protocol-helpers'; const NEW_CD_VERSION_FORMAT_MAJOR_VERSION = 73; @@ -839,7 +839,7 @@ export class Chromedriver extends events.EventEmitter { try { await B.promisify(cp.exec)(cmd); this.log.debug('Successfully cleaned up old chromedrivers'); - } catch (err) { + } catch { this.log.warn('No old chromedrivers seem to exist'); } @@ -878,7 +878,7 @@ export class Chromedriver extends events.EventEmitter { try { await this.jwproxy.command('/url', 'GET'); return true; - } catch (e) { + } catch { return false; } } diff --git a/lib/storage-client/chromelabs.js b/lib/storage-client/chromelabs.js index 92daae5d..47675215 100644 --- a/lib/storage-client/chromelabs.js +++ b/lib/storage-client/chromelabs.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import path from 'path'; import {logger} from '@appium/support'; -import semver from 'semver'; +import * as semver from 'semver'; import {ARCH, CPU} from '../constants'; const log = logger.getLogger('ChromedriverChromelabsStorageClient'); diff --git a/lib/storage-client/googleapis.js b/lib/storage-client/googleapis.js index b590230e..b0091790 100644 --- a/lib/storage-client/googleapis.js +++ b/lib/storage-client/googleapis.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -import xpath from 'xpath'; +import {select as xpathSelect} from 'xpath'; import {util, logger} from '@appium/support'; import {retrieveData} from '../utils'; import B from 'bluebird'; @@ -99,7 +99,7 @@ export async function parseGoogleapiStorageXml(xml, shouldParseNotes = true) { const driverNodes = /** @type {Array} */ ( // @ts-expect-error Misssing Node properties are not needed. // https://github.com/xmldom/xmldom/issues/724 - xpath.select(`//*[local-name(.)='Contents']`, doc) + xpathSelect(`//*[local-name(.)='Contents']`, doc) ); log.debug(`Parsed ${driverNodes.length} entries from storage XML`); if (_.isEmpty(driverNodes)) { diff --git a/lib/storage-client/storage-client.js b/lib/storage-client/storage-client.js index 0f92bfd2..0002f775 100644 --- a/lib/storage-client/storage-client.js +++ b/lib/storage-client/storage-client.js @@ -21,7 +21,7 @@ import { import {parseGoogleapiStorageXml} from './googleapis'; import {parseKnownGoodVersionsWithDownloadsJson, parseLatestKnownGoodVersionsJson} from './chromelabs'; import {compareVersions} from 'compare-versions'; -import semver from 'semver'; +import * as semver from 'semver'; const MAX_PARALLEL_DOWNLOADS = 5; const STORAGE_INFOS = /** @type {readonly StorageInfo[]} */ ([{ diff --git a/lib/types.ts b/lib/types.ts index 4bb5830f..f6a74142 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -1,4 +1,4 @@ -import type ADB from 'appium-adb'; +import type { ADB } from 'appium-adb'; export interface ChromedriverOpts { host?: string; diff --git a/lib/utils.js b/lib/utils.js index 752a84e0..41bc7f38 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -133,7 +133,6 @@ const getOsInfo = _.memoize( } ); -// @ts-expect-error // error TS2345: Argument of type '{}' is not assignable to parameter of type 'DriverOpts>>' // Type '{}' is missing the following properties from type 'ServerArgs': address, allowCors, allowInsecure, basePath, and 26 more. const getBaseDriverInstance = _.memoize(() => new BaseDriver({}, false)); diff --git a/test/functional/chromedriver-e2e-specs.js b/test/functional/chromedriver-e2e-specs.js index 0d4d4f0a..59e2fe0f 100644 --- a/test/functional/chromedriver-e2e-specs.js +++ b/test/functional/chromedriver-e2e-specs.js @@ -17,7 +17,6 @@ function nextState(cd) { function nextError(cd) { return new B((resolve) => { cd.on(Chromedriver.EVENT_ERROR, (err) => { - // eslint-disable-line promise/prefer-await-to-callbacks resolve(err); }); }); @@ -48,7 +47,7 @@ function buildReqRes(url, method, body) { send: (body) => { try { body = JSON.parse(body); - } catch (e) {} + } catch {} res.sentBody = body; }, }; diff --git a/test/functional/storage-client-e2e-specs.js b/test/functional/storage-client-e2e-specs.js index fb48ca5d..4005e6e1 100644 --- a/test/functional/storage-client-e2e-specs.js +++ b/test/functional/storage-client-e2e-specs.js @@ -1,4 +1,4 @@ -import ChromedriverStorageClient from '../../lib/storage-client/storage-client'; +import { ChromedriverStorageClient } from '../../lib/storage-client/storage-client'; import _ from 'lodash'; import { fs, tempDir } from '@appium/support'; diff --git a/test/helpers/install.js b/test/helpers/install.js index 001210c0..b5665aa6 100644 --- a/test/helpers/install.js +++ b/test/helpers/install.js @@ -1,5 +1,5 @@ import { fs, mkdirp } from '@appium/support'; -import ChromedriverStorageClient from '../../lib/storage-client/storage-client'; +import { ChromedriverStorageClient } from '../../lib/storage-client/storage-client'; import { CD_VER, getOsInfo, getChromedriverDir, } from '../../lib/utils'; diff --git a/test/unit/storage-client-specs.js b/test/unit/storage-client-specs.js index dac80fdd..9e1bf8c8 100644 --- a/test/unit/storage-client-specs.js +++ b/test/unit/storage-client-specs.js @@ -1,4 +1,4 @@ -import ChromedriverStorageClient from '../../lib/storage-client/storage-client'; +import { ChromedriverStorageClient } from '../../lib/storage-client/storage-client'; import _ from 'lodash'; describe('ChromedriverStorageClient', function () {