diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 84930aead..000000000 --- a/.eslintignore +++ /dev/null @@ -1,3 +0,0 @@ -Resources -coverage -build diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index 3d7db0846..000000000 --- a/.eslintrc.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "extends": ["@appium/eslint-config-appium-ts"], - "overrides": [ - { - "files": "test/**/*.js", - "rules": { - "func-names": "off", - "@typescript-eslint/no-var-requires": "off" - } - }, - { - "files": "Scripts/**/*.js", - "parserOptions": {"sourceType": "script"}, - "rules": { - "@typescript-eslint/no-var-requires": "off" - } - }, - { - "files": "ci-jobs/scripts/*.js", - "parserOptions": {"sourceType": "script"}, - "rules": { - "@typescript-eslint/no-var-requires": "off" - } - } - ], - "rules": { - "require-await": "error" - } -} diff --git a/Scripts/build-webdriveragent.js b/Scripts/build-webdriveragent.js index 1958b876d..b37bcbbc9 100644 --- a/Scripts/build-webdriveragent.js +++ b/Scripts/build-webdriveragent.js @@ -34,7 +34,7 @@ async function buildWebDriverAgent (xcodeVersion) { await exec('xcodebuild', ['clean', '-derivedDataPath', DERIVED_DATA_PATH, '-scheme', 'WebDriverAgentRunner'], { cwd: ROOT_DIR }); - } catch (ign) {} + } catch {} // Get Xcode version xcodeVersion = xcodeVersion || await xcode.getVersion(); diff --git a/Scripts/fetch-prebuilt-wda.js b/Scripts/fetch-prebuilt-wda.js index 8bedd9a3d..4bd6840fa 100644 --- a/Scripts/fetch-prebuilt-wda.js +++ b/Scripts/fetch-prebuilt-wda.js @@ -47,7 +47,7 @@ async function fetchPrebuiltWebDriverAgentAssets () { try { const nameOfAgent = _.last(url.split('/')); agentsDownloading.push(downloadAgent(url, path.join(webdriveragentsDir, nameOfAgent))); - } catch (ign) { } + } catch { } } // Wait for them all to finish diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 000000000..020f8c2d2 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,13 @@ +import appiumConfig from '@appium/eslint-config-appium-ts'; + +export default [ + ...appiumConfig, + { + ignores: [ + 'Configurations/**', + 'Fastlane/**', + 'PrivateHeaders/**', + 'WebDriverAgent*/**' + ], + }, +]; diff --git a/lib/check-dependencies.js b/lib/check-dependencies.js index 21c68de60..49903671d 100644 --- a/lib/check-dependencies.js +++ b/lib/check-dependencies.js @@ -2,8 +2,8 @@ import { fs } from '@appium/support'; import _ from 'lodash'; import { exec } from 'teen_process'; import path from 'path'; -import XcodeBuild from './xcodebuild'; -import xcode from 'appium-xcode'; +import {XcodeBuild} from './xcodebuild'; +import * as xcode from 'appium-xcode'; import { WDA_SCHEME, SDK_SIMULATOR, WDA_RUNNER_APP } from './constants'; @@ -22,7 +22,6 @@ async function buildWDASim () { await exec('xcodebuild', args); } -// eslint-disable-next-line require-await export async function checkForDependencies () { log.debug('Dependencies are up to date'); return false; diff --git a/lib/utils.js b/lib/utils.js index f8e7007c1..77ca8f53a 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -27,7 +27,7 @@ const getModuleRoot = _.memoize(function getModuleRoot () { JSON.parse(_fs.readFileSync(manifestPath, 'utf8')).name === 'appium-webdriveragent') { return currentDir; } - } catch (ign) {} + } catch {} currentDir = path.dirname(currentDir); isAtFsRoot = currentDir.length <= path.dirname(currentDir).length; } @@ -86,7 +86,7 @@ async function killAppUsingPattern (pgrepPattern) { intervalMs: 100, }); return; - } catch (ign) { + } catch { // try the next signal } } @@ -121,7 +121,7 @@ async function updateProjectFile (agentPath, newBundleId) { try { // Assuming projectFilePath is in the correct state, create .old from projectFilePath await fs.copyFile(projectFilePath, `${projectFilePath}.old`); - await replaceInFile(projectFilePath, new RegExp(_.escapeRegExp(WDA_RUNNER_BUNDLE_ID), 'g'), newBundleId); // eslint-disable-line no-useless-escape + await replaceInFile(projectFilePath, new RegExp(_.escapeRegExp(WDA_RUNNER_BUNDLE_ID), 'g'), newBundleId); log.debug(`Successfully updated '${projectFilePath}' with bundle id '${newBundleId}'`); } catch (err) { log.debug(`Error updating project file: ${err.message}`); diff --git a/lib/webdriveragent.js b/lib/webdriveragent.js index f5cda7ee3..e47b9c752 100644 --- a/lib/webdriveragent.js +++ b/lib/webdriveragent.js @@ -10,7 +10,7 @@ import { NoSessionProxy } from './no-session-proxy'; import { getWDAUpgradeTimestamp, resetTestProcesses, getPIDsListeningOnPort, BOOTSTRAP_PATH } from './utils'; -import XcodeBuild from './xcodebuild'; +import {XcodeBuild} from './xcodebuild'; import AsyncLock from 'async-lock'; import { exec } from 'teen_process'; import { bundleWDASim } from './check-dependencies'; @@ -417,7 +417,7 @@ export class WebDriverAgent { let status; try { status = await this.getStatus(this.wdaLaunchTimeout); - } catch (err) { + } catch { throw new Error( `Failed to start the preinstalled WebDriverAgent in ${this.wdaLaunchTimeout} ms. ` + `The WebDriverAgent might not be properly built or the device might be locked. ` + diff --git a/package.json b/package.json index 55dfe122e..b1c5ad616 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ }, "homepage": "https://github.com/appium/WebDriverAgent#readme", "devDependencies": { - "@appium/eslint-config-appium-ts": "^0.x", + "@appium/eslint-config-appium-ts": "^1.0.0", "@appium/test-support": "^3.0.0", "@appium/tsconfig": "^0.x", "@appium/types": "^0.x", diff --git a/test/functional/helpers/simulator.js b/test/functional/helpers/simulator.js index 4dd7359df..f315f2035 100644 --- a/test/functional/helpers/simulator.js +++ b/test/functional/helpers/simulator.js @@ -1,5 +1,5 @@ import _ from 'lodash'; -import Simctl from 'node-simctl'; +import { Simctl } from 'node-simctl'; import { retryInterval } from 'asyncbox'; import { killAllSimulators as simKill } from 'appium-ios-simulator'; import { resetTestProcesses } from '../../../lib/utils'; @@ -34,7 +34,7 @@ async function deleteDeviceWithRetry (udid) { const simctl = new Simctl({udid}); try { await retryInterval(10, 1000, simctl.deleteDevice.bind(simctl)); - } catch (ign) {} + } catch {} } diff --git a/test/functional/webdriveragent-e2e-specs.js b/test/functional/webdriveragent-e2e-specs.js index 3cf2862f1..bb1ce67c9 100644 --- a/test/functional/webdriveragent-e2e-specs.js +++ b/test/functional/webdriveragent-e2e-specs.js @@ -1,4 +1,4 @@ -import Simctl from 'node-simctl'; +import { Simctl } from 'node-simctl'; import { getVersion } from 'appium-xcode'; import { getSimulator } from 'appium-ios-simulator'; import { killAllSimulators, shutdownSimulator } from './helpers/simulator'; @@ -89,7 +89,7 @@ describe('WebDriverAgent', function () { await retryInterval(5, 1000, async function () { await shutdownSimulator(device); }); - } catch (ign) {} + } catch {} }); it('should launch agent on a sim', async function () { @@ -106,7 +106,7 @@ describe('WebDriverAgent', function () { const agent = new WebDriverAgent(xcodeVersion, getStartOpts(device)); - agent.xcodebuild.createSubProcess = async function () { // eslint-disable-line require-await + agent.xcodebuild.createSubProcess = async function () { let args = [ '-workspace', `${this.agentPath}dfgs`,