From 25ebaa72e594510b2dfd66ce0d04dc91cf476427 Mon Sep 17 00:00:00 2001 From: Kazuaki Matsuo Date: Thu, 2 Jan 2025 23:36:14 -0800 Subject: [PATCH] chore: use "@appium/eslint-config-appium-ts": "^1.0.0" --- .eslintignore | 2 -- .eslintrc.json | 22 ---------------------- eslint.config.mjs | 3 +++ index.js | 2 +- lib/commands/record-screen.js | 10 +++++----- lib/driver.js | 2 +- lib/safari.js | 8 ++++---- package.json | 3 +-- test/functional/mobile-driver-e2e-specs.js | 2 +- test/unit/driver-specs.js | 2 +- 10 files changed, 17 insertions(+), 39 deletions(-) delete mode 100644 .eslintignore delete mode 100644 .eslintrc.json create mode 100644 eslint.config.mjs diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index fb7020d..0000000 --- a/.eslintignore +++ /dev/null @@ -1,2 +0,0 @@ -coverage -build diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 950cea2..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "extends": ["@appium/eslint-config-appium-ts"], - "overrides": [ - { - "files": "test/**/*.js", - "rules": { - "func-names": "off", - "@typescript-eslint/no-var-requires": "off" - } - }, - { - "files": "scripts/**/*", - "parserOptions": {"sourceType": "script"}, - "rules": { - "@typescript-eslint/no-var-requires": "off" - } - } - ], - "rules": { - "require-await": "error" - } -} diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..09be1a7 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,3 @@ +import appiumConfig from '@appium/eslint-config-appium-ts'; + +export default appiumConfig; diff --git a/index.js b/index.js index 258964e..1c691c4 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -import SafariDriver from './lib/driver'; +import * as SafariDriver from './lib/driver'; export default SafariDriver; export { SafariDriver }; diff --git a/lib/commands/record-screen.js b/lib/commands/record-screen.js index be770cd..345cafc 100644 --- a/lib/commands/record-screen.js +++ b/lib/commands/record-screen.js @@ -1,7 +1,7 @@ import _ from 'lodash'; import { util, fs, net, tempDir } from 'appium/support'; import { waitForCondition } from 'asyncbox'; -import Simctl from 'node-simctl'; +import * as Simctl from 'node-simctl'; const commands = {}; @@ -43,7 +43,7 @@ process.on('exit', () => { for (const videoFile of VIDEO_FILES) { try { fs.rimrafSync(videoFile); - } catch (ign) {} + } catch {} } }); @@ -89,7 +89,7 @@ class ScreenRecorder { this.log.debug('Force-stopping the currently running video recording'); try { await /** @type {import('teen_process').SubProcess} */ (this._process).stop('SIGKILL'); - } catch (ign) {} + } catch {} } this._process = null; const videoPath = await this.getVideoPath(); @@ -145,7 +145,7 @@ class ScreenRecorder { waitMs: STARTUP_TIMEOUT_MS, intervalMs: STARTUP_INTERVAL_MS, }); - } catch (e) { + } catch { await this._enforceTermination(); throw this.log.errorWithException( `The expected screen record file '${this._videoPath}' does not exist after ${STARTUP_TIMEOUT_MS}ms. ` + @@ -181,7 +181,7 @@ class ScreenRecorder { try { await /** @type {import('teen_process').SubProcess} */ (this._process).stop('SIGINT', PROCESS_SHUTDOWN_TIMEOUT_MS); - } catch (e) { + } catch { await this._enforceTermination(); throw new Error(`Screen recording has failed to stop after ${PROCESS_SHUTDOWN_TIMEOUT_MS}ms`); } diff --git a/lib/driver.js b/lib/driver.js index 45f358a..c108c40 100644 --- a/lib/driver.js +++ b/lib/driver.js @@ -2,7 +2,7 @@ import _ from 'lodash'; import { BaseDriver } from 'appium/driver'; import SafariDriverServer from './safari'; import { desiredCapConstraints } from './desired-caps'; -import commands from './commands/index'; +import * as commands from './commands/index'; import { formatCapsForServer } from './utils'; import { newMethodMap } from './method-map'; diff --git a/lib/safari.js b/lib/safari.js index 336d5d3..a2515b7 100644 --- a/lib/safari.js +++ b/lib/safari.js @@ -52,7 +52,7 @@ class SafariDriverProcess { const [startPort, endPort] = SAFARI_PORT_RANGE; try { this.port = await findAPortNotInUse(startPort, endPort); - } catch (e) { + } catch { throw new Error( `Cannot find any free port in range ${startPort}..${endPort}. ` + `Double check the processes that are locking ports within this range and terminate ` + @@ -62,7 +62,7 @@ class SafariDriverProcess { let safariBin; try { safariBin = await fs.which(SD_BINARY); - } catch (e) { + } catch { throw new Error(`${SD_BINARY} binary cannot be found in PATH. ` + `Please make sure it is present on your system`); } @@ -83,7 +83,7 @@ class SafariDriverProcess { if (this.isRunning) { try { await this.proc?.stop('SIGKILL'); - } catch (ign) {} + } catch {} } } } @@ -94,7 +94,7 @@ process.once('exit', () => { if (SAFARI_DRIVER_PROCESS.isRunning) { try { execSync(`kill ${SAFARI_DRIVER_PROCESS.proc?.pid}`); - } catch (ign) {} + } catch {} } }); diff --git a/package.json b/package.json index db340e4..bce1c54 100644 --- a/package.json +++ b/package.json @@ -62,8 +62,7 @@ "appium": "^2.0.0" }, "devDependencies": { - "@appium/eslint-config-appium": "^8.0.4", - "@appium/eslint-config-appium-ts": "^0.x", + "@appium/eslint-config-appium-ts": "^1.0.0", "@appium/tsconfig": "^0.x", "@appium/types": "^0.x", "@semantic-release/changelog": "^6.0.1", diff --git a/test/functional/mobile-driver-e2e-specs.js b/test/functional/mobile-driver-e2e-specs.js index 1e712e0..b5dffb9 100644 --- a/test/functional/mobile-driver-e2e-specs.js +++ b/test/functional/mobile-driver-e2e-specs.js @@ -1,5 +1,5 @@ import { remote } from 'webdriverio'; -import Simctl from 'node-simctl'; +import * as Simctl from 'node-simctl'; import { HOST, PORT, MOCHA_TIMEOUT } from '../utils'; const PLATFORM_VERSION = process.env.PLATFORM_VERSION || '14.1'; diff --git a/test/unit/driver-specs.js b/test/unit/driver-specs.js index 8543361..421e7e7 100644 --- a/test/unit/driver-specs.js +++ b/test/unit/driver-specs.js @@ -1,4 +1,4 @@ -import SafariDriver from '../../lib/driver'; +import * as SafariDriver from '../../lib/driver'; describe('SafariDriver', function () { let chai;