From 6680e4f681221f694b8de200fe83cb8ffc015f88 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 5 Jan 2025 16:02:25 +0100 Subject: [PATCH] chore: Bump @appium/eslint-config-appium-ts from 0.3.3 to 1.0.1 (#191) --- .eslintignore | 2 - .eslintrc.json | 22 -------- eslint.config.mjs | 5 ++ lib/afc/index.js | 6 +-- lib/afc/streams.js | 53 +++++++++++-------- lib/house-arrest/index.js | 8 +-- lib/imagemounter/index.js | 2 +- .../utils/list_developer_image.js | 2 +- lib/instrument/headers.js | 3 +- lib/instrument/transformer/dtx-decode.js | 2 +- lib/instrument/transformer/nskeyed.js | 4 +- lib/logger.js | 4 +- lib/notification-proxy/index.js | 6 +-- lib/plist-service/index.js | 6 +-- lib/services.js | 4 +- lib/syslog/index.js | 2 +- lib/usbmux/index.js | 14 ++--- lib/util/transformer/length-based-splitter.js | 5 +- lib/util/transformer/stream-logger.js | 5 +- lib/utilities.js | 4 +- lib/webinspector/index.js | 14 ++--- lib/xctest.js | 2 +- package.json | 2 +- test/afc/afc-specs.js | 2 +- test/fixtures/index.js | 1 - .../installation-proxy-service-specs.js | 2 +- test/lockdown/lockdown-specs.js | 2 +- test/syslog/syslog-service-specs.js | 2 +- test/usbmux/usbmux-specs.js | 4 +- .../webinspector-service-specs.js | 4 +- 30 files changed, 88 insertions(+), 106 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..4d52325 --- /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/afc/index.js b/lib/afc/index.js index e09ff6e..f12dd4a 100644 --- a/lib/afc/index.js +++ b/lib/afc/index.js @@ -1,9 +1,9 @@ -import LengthBasedSplitter from '../util/transformer/length-based-splitter'; +import { LengthBasedSplitter } from '../util/transformer/length-based-splitter'; import { Operations, operationCode, Errors, errorCode, FileModes } from './protocol'; import { AfcWritableFileStream, AfcReadableFileStream } from './streams'; -import AfcEncoder from './transformer/afcencoder'; -import AfcDecoder from './transformer/afcdecoder'; +import { AfcEncoder } from './transformer/afcencoder'; +import { AfcDecoder } from './transformer/afcdecoder'; import { MB } from '../constants'; import B from 'bluebird'; import path from 'path'; diff --git a/lib/afc/streams.js b/lib/afc/streams.js index 5e8ee2e..cd03bb5 100644 --- a/lib/afc/streams.js +++ b/lib/afc/streams.js @@ -1,9 +1,8 @@ -/* eslint-disable promise/prefer-await-to-then */ import stream from 'stream'; import _ from 'lodash'; -import log from '../logger'; +import { log } from '../logger'; -class AfcReadableFileStream extends stream.Readable { +export class AfcReadableFileStream extends stream.Readable { constructor (fileHandle, afcService, options) { super(options); @@ -14,19 +13,20 @@ class AfcReadableFileStream extends stream.Readable { } _read (size) { - this._afcService.readFile(this._fileHandle, size) - .then((data) => { + (async () => { + try { + const data = await this._afcService.readFile(this._fileHandle, size); if (!this._destroyed) { this.push(_.isEmpty(data) ? null : data); } - }) - .catch((e) => { + } catch (e) { if (this._autoDestroy) { this.destroy(e); } else { this.emit('error', e); } - }); + } + })(); } _destroy (err, done) { @@ -35,20 +35,23 @@ class AfcReadableFileStream extends stream.Readable { } this._destroyed = true; this.push(null); - this._afcService.closeFileHandle(this._fileHandle) - .then(() => done(err)) - .catch((e) => { + (async () => { + try { + await this._afcService.closeFileHandle(this._fileHandle); + done(err); + } catch (e) { if (err) { log.debug(e); } else { err = e; } done(err); - }); + } + })(); } } -class AfcWritableFileStream extends stream.Writable { +export class AfcWritableFileStream extends stream.Writable { constructor (fileHandle, afcService, options) { super(options); @@ -59,14 +62,17 @@ class AfcWritableFileStream extends stream.Writable { } _write (chunk, encoding, next) { - this._afcService.writeFile(this._fileHandle, chunk) - .then(() => next()) - .catch((e) => { + (async () => { + try { + await this._afcService.writeFile(this._fileHandle, chunk); + next(); + } catch (e) { if (this._autoDestroy) { this.destroy(e); } next(e); - }); + } + })(); } _destroy (err, done) { @@ -74,17 +80,18 @@ class AfcWritableFileStream extends stream.Writable { return; } this._destroyed = true; - this._afcService.closeFileHandle(this._fileHandle) - .then(() => done(err)) - .catch((e) => { + (async () => { + try { + await this._afcService.closeFileHandle(this._fileHandle); + done(err); + } catch (e) { if (err) { log.debug(e); } else { err = e; } done(err); - }); + } + })(); } } - -export { AfcReadableFileStream, AfcWritableFileStream }; diff --git a/lib/house-arrest/index.js b/lib/house-arrest/index.js index 955b7f4..e954db0 100644 --- a/lib/house-arrest/index.js +++ b/lib/house-arrest/index.js @@ -1,8 +1,8 @@ -import PlistServiceDecoder from '../plist-service/transformer/plist-service-decoder'; -import PlistServiceEncoder from '../plist-service/transformer/plist-service-encoder'; -import LengthBasedSplitter from '../util/transformer/length-based-splitter'; +import { PlistServiceDecoder } from '../plist-service/transformer/plist-service-decoder'; +import { PlistServiceEncoder } from '../plist-service/transformer/plist-service-encoder'; +import { LengthBasedSplitter } from '../util/transformer/length-based-splitter'; import { KB } from '../constants'; -import AfcService from '../afc'; +import { AfcService } from '../afc'; import B from 'bluebird'; import { BaseServiceSocket } from '../base-service'; diff --git a/lib/imagemounter/index.js b/lib/imagemounter/index.js index 110f4f2..0173a10 100644 --- a/lib/imagemounter/index.js +++ b/lib/imagemounter/index.js @@ -1,7 +1,7 @@ import { BaseServicePlist } from '../base-service'; import { fs } from '@appium/support'; import B from 'bluebird'; -import log from '../logger'; +import { log } from '../logger'; const { lstat, readFile, createReadStream } = fs; const MOBILE_IMAGE_MOUNTER_SERVICE_NAME = 'com.apple.mobile.mobile_image_mounter'; diff --git a/lib/imagemounter/utils/list_developer_image.js b/lib/imagemounter/utils/list_developer_image.js index c6c3b72..5283ca1 100644 --- a/lib/imagemounter/utils/list_developer_image.js +++ b/lib/imagemounter/utils/list_developer_image.js @@ -2,7 +2,7 @@ import _ from 'lodash'; import { zip, net, env, fs } from '@appium/support'; import { join as joinPath } from 'path'; import axios from 'axios'; -import log from '../../logger'; +import { log } from '../../logger'; const { exists, readdir, mkdir, rimraf } = fs; /** diff --git a/lib/instrument/headers.js b/lib/instrument/headers.js index 9de67fd..b57b9e4 100644 --- a/lib/instrument/headers.js +++ b/lib/instrument/headers.js @@ -382,7 +382,6 @@ class DTXMessage { flags: this._flags, auxLength: aux.length, // need to convert to bigint in any case - // eslint-disable-next-line no-undef totalLength: BigInt(aux.length + sel.length), }); @@ -428,7 +427,7 @@ class DTXMessage { try { ret.selector = fun(data); break; - } catch (e) { + } catch { ret.selector = new InstrumentRPCParseError(data); } } diff --git a/lib/instrument/transformer/dtx-decode.js b/lib/instrument/transformer/dtx-decode.js index 74e8302..7f12114 100644 --- a/lib/instrument/transformer/dtx-decode.js +++ b/lib/instrument/transformer/dtx-decode.js @@ -3,7 +3,7 @@ import { DTX_MESSAGE_HEADER_LENGTH, DTX_MESSAGE_HEADER_MAGIC, DTX_MESSAGE_HEADER_MAGIC_LEN, DTXMessageHeader, DTXMessage, } from '../headers'; -import log from '../../logger'; +import { log } from '../../logger'; class DTXDecoder extends Stream.Transform { diff --git a/lib/instrument/transformer/nskeyed.js b/lib/instrument/transformer/nskeyed.js index 4c32914..2c5262e 100644 --- a/lib/instrument/transformer/nskeyed.js +++ b/lib/instrument/transformer/nskeyed.js @@ -3,7 +3,7 @@ import bplistCreate from 'bplist-creator'; import { parse as uuidParse, stringify as uuidStringify } from 'uuid'; import _ from 'lodash'; import { format as stringFormat } from 'node:util'; -import log from '../../logger'; +import { log } from '../../logger'; const NSKEYED_ARCHIVE_VERSION = 100_000; // @ts-ignore UID is not exposed to typedefs @@ -375,7 +375,7 @@ class Unarchive { const createPlistIssue = (/** @type {string} */ message) => { try { log.debug(`Source plist: ${_.truncate(JSON.stringify(plist), {length: 250})}`); - } catch (ign) {} + } catch {} return new Error(message); }; if (plist.$archiver !== NSKEYEDARCHIVER) { diff --git a/lib/logger.js b/lib/logger.js index e9b9221..7dcc36c 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -1,5 +1,3 @@ import { logger } from '@appium/support'; -const log = logger.getLogger('ios-device'); - -export default log; \ No newline at end of file +export const log = logger.getLogger('ios-device'); diff --git a/lib/notification-proxy/index.js b/lib/notification-proxy/index.js index 725c493..13da4c1 100644 --- a/lib/notification-proxy/index.js +++ b/lib/notification-proxy/index.js @@ -1,6 +1,6 @@ -import PlistServiceEncoder from '../plist-service/transformer/plist-service-encoder'; -import PlistServiceDecoder from '../plist-service/transformer/plist-service-decoder'; -import LengthBasedSplitter from '../util/transformer/length-based-splitter'; +import { PlistServiceEncoder } from '../plist-service/transformer/plist-service-encoder'; +import { PlistServiceDecoder } from '../plist-service/transformer/plist-service-decoder'; +import { LengthBasedSplitter } from '../util/transformer/length-based-splitter'; import { KB } from '../constants'; import _ from 'lodash'; import { BaseServiceSocket } from '../base-service'; diff --git a/lib/plist-service/index.js b/lib/plist-service/index.js index 413dd55..9e558cb 100644 --- a/lib/plist-service/index.js +++ b/lib/plist-service/index.js @@ -1,8 +1,8 @@ import B from 'bluebird'; import { upgradeToSSL } from '../ssl-helper'; -import PlistServiceEncoder from './transformer/plist-service-encoder'; -import PlistServiceDecoder from './transformer/plist-service-decoder'; -import LengthBasedSplitter from '../util/transformer/length-based-splitter'; +import { PlistServiceEncoder } from './transformer/plist-service-encoder'; +import { PlistServiceDecoder } from './transformer/plist-service-decoder'; +import { LengthBasedSplitter } from '../util/transformer/length-based-splitter'; import { BaseServiceSocket } from '../base-service'; import { MB } from '../constants'; diff --git a/lib/services.js b/lib/services.js index 29e3918..fd1765a 100644 --- a/lib/services.js +++ b/lib/services.js @@ -10,8 +10,8 @@ import { InstrumentService, INSTRUMENT_SERVICE_NAME_VERSION_14, INSTRUMENT_SERVI import { TestmanagerdService, TESTMANAGERD_SERVICE_NAME_VERSION_14, TESTMANAGERD_SERVICE_NAME } from './testmanagerd'; import { MCInstallProxyService, MC_INSTALL_SERVICE_NAME } from './mcinstall'; import { ImageMounter, MOBILE_IMAGE_MOUNTER_SERVICE_NAME } from './imagemounter'; -import PlistService from './plist-service'; -import semver from 'semver'; +import { PlistService } from './plist-service'; +import * as semver from 'semver'; const CRASH_LOG_SERVICE_NAME = 'com.apple.crashreportcopymobile'; diff --git a/lib/syslog/index.js b/lib/syslog/index.js index 1c3edf9..8c7b200 100644 --- a/lib/syslog/index.js +++ b/lib/syslog/index.js @@ -1,4 +1,4 @@ -import SyslogDecoder from './transformer/syslog-decoder'; +import { SyslogDecoder } from './transformer/syslog-decoder'; import { KB } from '../constants'; import { BaseServiceSocket } from '../base-service'; diff --git a/lib/usbmux/index.js b/lib/usbmux/index.js index 0b3d41a..315a575 100644 --- a/lib/usbmux/index.js +++ b/lib/usbmux/index.js @@ -3,15 +3,15 @@ import os from 'os'; import _ from 'lodash'; import B from 'bluebird'; import { plist, fs } from '@appium/support'; -import LengthBasedSplitter from '../util/transformer/length-based-splitter'; -import UsbmuxDecoder from './transformer/usbmux-decoder.js'; -import UsbmuxEncoder from './transformer/usbmux-encoder.js'; +import { LengthBasedSplitter } from '../util/transformer/length-based-splitter'; +import { UsbmuxDecoder } from './transformer/usbmux-decoder.js'; +import { UsbmuxEncoder } from './transformer/usbmux-encoder.js'; import path from 'path'; -import PlistService from '../plist-service'; +import { PlistService } from '../plist-service'; import { Lockdown, LOCKDOWN_PORT } from '../lockdown'; import { BaseServiceSocket } from '../base-service'; import { MB } from '../constants'; -import log from '../logger'; +import { log } from '../logger'; const MAX_FRAME_SIZE = 1 * MB; @@ -27,7 +27,7 @@ let name, version; try { // first try assuming this is in the `build` folder ({ name, version } = require(path.resolve(__dirname, '..', '..', '..', 'package.json'))); -} catch (err) { +} catch { // then try assuming it is not ({ name, version } = require(path.resolve(__dirname, '..', '..', 'package.json'))); } @@ -171,7 +171,7 @@ class Usbmux extends BaseServiceSocket { } try { return plist.parsePlist(data.payload.PairRecordData); - } catch (err) { + } catch { throw new Error(`Unexpected data: ${JSON.stringify(data)}`); } }); diff --git a/lib/util/transformer/length-based-splitter.js b/lib/util/transformer/length-based-splitter.js index 515ebce..5966406 100644 --- a/lib/util/transformer/length-based-splitter.js +++ b/lib/util/transformer/length-based-splitter.js @@ -1,7 +1,7 @@ import Stream from 'stream'; -import log from '../../logger'; +import { log } from '../../logger'; -class LengthBasedSplitter extends Stream.Transform { +export class LengthBasedSplitter extends Stream.Transform { constructor (opts) { super(); @@ -108,5 +108,4 @@ class LengthBasedSplitter extends Stream.Transform { } } -export { LengthBasedSplitter}; export default LengthBasedSplitter; diff --git a/lib/util/transformer/stream-logger.js b/lib/util/transformer/stream-logger.js index 12656a9..25f3d72 100644 --- a/lib/util/transformer/stream-logger.js +++ b/lib/util/transformer/stream-logger.js @@ -1,6 +1,6 @@ import Stream from 'stream'; import _ from 'lodash'; -import log from '../../logger'; +import { log } from '../../logger'; const MIN_PRINTABLE_CHAR = 32; @@ -8,7 +8,7 @@ const MAX_PRINTABLE_CHAR = 126; const CHARACTERS_PER_LINE = 19; -class StreamLogger extends Stream.Transform { +export class StreamLogger extends Stream.Transform { constructor (direction, verbose = false) { super({ objectMode: true }); @@ -64,5 +64,4 @@ class StreamLogger extends Stream.Transform { StreamLogger.SEND = 0; StreamLogger.RECEIVE = 1; -export { StreamLogger }; export default StreamLogger; diff --git a/lib/utilities.js b/lib/utilities.js index 766b297..340f6ed 100644 --- a/lib/utilities.js +++ b/lib/utilities.js @@ -1,7 +1,7 @@ -import Usbmux, { getDefaultSocket } from './usbmux'; +import { Usbmux, getDefaultSocket } from './usbmux'; import { upgradeToSSL, enableSSLHandshakeOnly } from './ssl-helper'; import _ from 'lodash'; -import log from './logger'; +import { log } from './logger'; import { findDeveloperImage } from './imagemounter/utils/list_developer_image'; // https://github.com/samdmarshall/iOS-Internals/blob/master/lockbot/lockbot/lockdown_keys.h diff --git a/lib/webinspector/index.js b/lib/webinspector/index.js index 9030676..f48132b 100644 --- a/lib/webinspector/index.js +++ b/lib/webinspector/index.js @@ -1,13 +1,13 @@ -import WebInspectorDecoder from './transformer/webinspector-decoder'; -import WebInspectorEncoder from './transformer/webinspector-encoder'; -import PlistServiceDecoder from '../plist-service/transformer/plist-service-decoder'; -import PlistServiceEncoder from '../plist-service/transformer/plist-service-encoder'; -import LengthBasedSplitter from '../util/transformer/length-based-splitter'; -import StreamLogger from '../util/transformer/stream-logger'; +import { WebInspectorDecoder } from './transformer/webinspector-decoder'; +import { WebInspectorEncoder } from './transformer/webinspector-encoder'; +import { PlistServiceDecoder } from '../plist-service/transformer/plist-service-decoder'; +import { PlistServiceEncoder } from '../plist-service/transformer/plist-service-encoder'; +import { LengthBasedSplitter } from '../util/transformer/length-based-splitter'; +import { StreamLogger } from '../util/transformer/stream-logger'; import _ from 'lodash'; import { util } from '@appium/support'; import { MB } from '../constants'; -import log from '../logger'; +import { log } from '../logger'; import { BaseServiceSocket } from '../base-service'; diff --git a/lib/xctest.js b/lib/xctest.js index ddbbab1..e314f40 100644 --- a/lib/xctest.js +++ b/lib/xctest.js @@ -5,7 +5,7 @@ import { NSUUID, XCTestConfiguration } from './instrument/transformer/nskeyed'; import { TESTMANAGERD_CHANNEL } from './testmanagerd'; import { util } from '@appium/support'; import { getOSVersion } from './utilities'; -import log from './logger'; +import { log } from './logger'; import B from 'bluebird'; const { DAEMON_CONNECTION_INTERFACE } = TESTMANAGERD_CHANNEL; diff --git a/package.json b/package.json index d0fe2f8..cc2ff41 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,7 @@ "singleQuote": true }, "devDependencies": { - "@appium/eslint-config-appium-ts": "^0.x", + "@appium/eslint-config-appium-ts": "^1.x", "@appium/tsconfig": "^0.x", "@appium/types": "^0.x", "@semantic-release/changelog": "^6.0.1", diff --git a/test/afc/afc-specs.js b/test/afc/afc-specs.js index 22b8931..7c4bb45 100644 --- a/test/afc/afc-specs.js +++ b/test/afc/afc-specs.js @@ -1,4 +1,4 @@ -import AfcService from '../../lib/afc'; +import { AfcService } from '../../lib/afc'; import { getServerWithFixtures, fixtures } from '../fixtures'; describe('afc', function () { diff --git a/test/fixtures/index.js b/test/fixtures/index.js index 0b54dad..a1f8bfe 100644 --- a/test/fixtures/index.js +++ b/test/fixtures/index.js @@ -40,7 +40,6 @@ async function initFixtures () { return; } - // eslint-disable-next-line require-atomic-updates fixtureContents = { [fixtures.DEVICE_LIST]: await fs.readFile(getFixturePath('usbmuxlistdevicemessage.bin')), [fixtures.DEVICE_LIST_2]: await fs.readFile(getFixturePath('usbmuxlistdevicemessage2.bin')), diff --git a/test/installation-proxy/installation-proxy-service-specs.js b/test/installation-proxy/installation-proxy-service-specs.js index c184102..e925314 100644 --- a/test/installation-proxy/installation-proxy-service-specs.js +++ b/test/installation-proxy/installation-proxy-service-specs.js @@ -1,5 +1,5 @@ import InstallationServiceProxy from '../../lib/installation-proxy'; -import PlistService from '../../lib/plist-service'; +import { PlistService } from '../../lib/plist-service'; import { getServerWithFixtures, fixtures } from '../fixtures'; describe('installation proxy', function () { diff --git a/test/lockdown/lockdown-specs.js b/test/lockdown/lockdown-specs.js index 44892a1..6c65c32 100644 --- a/test/lockdown/lockdown-specs.js +++ b/test/lockdown/lockdown-specs.js @@ -17,7 +17,7 @@ describe('lockdown', function () { afterEach(function () { try { server.close(); - } catch (ign) {} + } catch {} }); it('should lockdown get value', async function () { diff --git a/test/syslog/syslog-service-specs.js b/test/syslog/syslog-service-specs.js index e23608e..1e1110f 100644 --- a/test/syslog/syslog-service-specs.js +++ b/test/syslog/syslog-service-specs.js @@ -1,5 +1,5 @@ import B from 'bluebird'; -import SyslogService from '../../lib/syslog'; +import { SyslogService } from '../../lib/syslog'; import { getServerWithFixtures, fixtures } from '../fixtures'; import { toUtf8String } from '../../lib/syslog/transformer/syslog-decoder'; diff --git a/test/usbmux/usbmux-specs.js b/test/usbmux/usbmux-specs.js index e412a38..cf31a93 100644 --- a/test/usbmux/usbmux-specs.js +++ b/test/usbmux/usbmux-specs.js @@ -15,10 +15,10 @@ describe('usbmux', function () { afterEach(function () { try { usbmux.close(); - } catch (ign) {} + } catch {} try { server.close(); - } catch (ign) {} + } catch {} }); it('should read usbmux message', async function () { diff --git a/test/webinspector/webinspector-service-specs.js b/test/webinspector/webinspector-service-specs.js index f5e13cd..2e359c8 100644 --- a/test/webinspector/webinspector-service-specs.js +++ b/test/webinspector/webinspector-service-specs.js @@ -1,6 +1,6 @@ import B from 'bluebird'; -import semver from 'semver'; -import WebInspectorService from '../../lib/webinspector'; +import * as semver from 'semver'; +import { WebInspectorService } from '../../lib/webinspector'; import { getServerWithFixtures, fixtures } from '../fixtures'; describe('webinspector', function () {