Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js] chore: fix linter #9639

Merged
merged 2 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions javascript/node/selenium-webdriver/chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,9 @@ class Driver extends chromium.Driver {
*/
static createSession(opt_config, opt_serviceExecutor) {
let caps = opt_config || new Options()
return /** @type {!Driver} */ (super.createSession(
caps,
opt_serviceExecutor
))
return /** @type {!Driver} */ (
super.createSession(caps, opt_serviceExecutor)
)
}
}

Expand Down
11 changes: 5 additions & 6 deletions javascript/node/selenium-webdriver/chromium.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,14 +557,13 @@ class Options extends Capabilities {
* @return {!Options} A self reference.
*/
windowTypes(...args) {
let windowTypes = (this.options_.windowTypes || []).concat(...args);
let windowTypes = (this.options_.windowTypes || []).concat(...args)
if (windowTypes.length) {
this.options_.windowTypes = windowTypes;
this.options_.windowTypes = windowTypes
}
return this;
return this
}


/**
* Converts this instance to its JSON wire protocol representation. Note this
* function is an implementation not intended for general use.
Expand All @@ -581,7 +580,7 @@ class Options extends Capabilities {
return extension.toString('base64')
}
return io
.read(/** @type {string} */(extension))
.read(/** @type {string} */ (extension))
.then((buffer) => buffer.toString('base64'))
})
}
Expand Down Expand Up @@ -634,7 +633,7 @@ class Driver extends webdriver.WebDriver {
* implementation.
* @override
*/
setFileDetector() { }
setFileDetector() {}

/**
* Schedules a command to launch Chrome App with given ID.
Expand Down
18 changes: 8 additions & 10 deletions javascript/node/selenium-webdriver/edge.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ class ServiceBuilder extends chromium.ServiceBuilder {
let exe = opt_exe || locateSynchronously()
if (!exe) {
throw Error(
`The WebDriver for Edge could not be found on the current PATH. Please download the `+
`latest version of ${EDGEDRIVER_CHROMIUM_EXE} from `+
`https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ `+
`and ensure it can be found on your PATH.`
`The WebDriver for Edge could not be found on the current PATH. Please download the ` +
`latest version of ${EDGEDRIVER_CHROMIUM_EXE} from ` +
`https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ ` +
`and ensure it can be found on your PATH.`
)
}
super(exe)
Expand Down Expand Up @@ -152,10 +152,9 @@ class Driver extends chromium.Driver {
*/
static createSession(opt_config, opt_serviceExecutor) {
let caps = opt_config || new Options()
return /** @type {!Driver} */ (super.createSession(
caps,
opt_serviceExecutor
))
return /** @type {!Driver} */ (
super.createSession(caps, opt_serviceExecutor)
)
}

/**
Expand All @@ -175,7 +174,7 @@ function setDefaultService(service) {
if (defaultService && defaultService.isRunning()) {
throw Error(
'The previously configured EdgeDriver service is still running. ' +
'You must shut it down before you may adjust its configuration.'
'You must shut it down before you may adjust its configuration.'
)
}
defaultService = service
Expand All @@ -194,7 +193,6 @@ function getDefaultService() {
return defaultService
}


/**
* _Synchronously_ attempts to locate the chromedriver executable on the current
* system.
Expand Down
18 changes: 9 additions & 9 deletions javascript/node/selenium-webdriver/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ async function buildProfile(template, extensions) {
dir = await io.tmpDir()
if (template) {
await io.copyDir(
/** @type {string} */(template),
/** @type {string} */ (template),
dir,
/(parent\.lock|lock|\.parentlock)/
)
Expand Down Expand Up @@ -432,11 +432,11 @@ function findGeckoDriver() {
if (!exe) {
throw Error(
'The ' +
GECKO_DRIVER_EXE +
' executable could not be found on the current ' +
'PATH. Please download the latest version from ' +
'https://github.com/mozilla/geckodriver/releases/ ' +
'and ensure it can be found on your PATH.'
GECKO_DRIVER_EXE +
' executable could not be found on the current ' +
'PATH. Please download the latest version from ' +
'https://github.com/mozilla/geckodriver/releases/ ' +
'and ensure it can be found on your PATH.'
)
}
return exe
Expand All @@ -457,8 +457,8 @@ function findInProgramFiles(file) {
return exists
? files[0]
: io.exists(files[1]).then(function (exists) {
return exists ? files[1] : null
})
return exists ? files[1] : null
})
})
}

Expand Down Expand Up @@ -592,7 +592,7 @@ class Driver extends webdriver.WebDriver {
* implementation.
* @override
*/
setFileDetector() { }
setFileDetector() {}

/**
* Get the context that is currently in effect.
Expand Down
6 changes: 3 additions & 3 deletions javascript/node/selenium-webdriver/ie.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ class Driver extends webdriver.WebDriver {
let client = service.start().then((url) => new http.HttpClient(url))
let executor = new http.Executor(client)

return /** @type {!Driver} */ (super.createSession(executor, options, () =>
service.kill()
))
return /** @type {!Driver} */ (
super.createSession(executor, options, () => service.kill())
)
}

/**
Expand Down
3 changes: 2 additions & 1 deletion javascript/node/selenium-webdriver/io/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class Result {
}
}

const COMMAND_RESULT = /** !WeakMap<!Command, !Promise<!Result>> */ new WeakMap()
const COMMAND_RESULT =
/** !WeakMap<!Command, !Promise<!Result>> */ new WeakMap()
const KILL_HOOK = /** !WeakMap<!Command, function(string)> */ new WeakMap()

/**
Expand Down
6 changes: 4 additions & 2 deletions javascript/node/selenium-webdriver/lib/capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const Platform = {
*
* @record
*/
function Timeouts() { }
function Timeouts() {}

/**
* Defines when, in milliseconds, to interrupt a script that is being
Expand Down Expand Up @@ -263,7 +263,9 @@ class Capabilities {
* @return {!Capabilities} A basic set of capabilities for Firefox.
*/
static firefox() {
return new Capabilities().setBrowserName(Browser.FIREFOX).set("moz:debuggerAddress", true)
return new Capabilities()
.setBrowserName(Browser.FIREFOX)
.set('moz:debuggerAddress', true)
}

/**
Expand Down
3 changes: 2 additions & 1 deletion javascript/node/selenium-webdriver/lib/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ function buildRequest(customCommands, w3c, command) {
}
}

const CLIENTS = /** !WeakMap<!Executor, !(Client|IThenable<!Client>)> */ new WeakMap()
const CLIENTS =
/** !WeakMap<!Executor, !(Client|IThenable<!Client>)> */ new WeakMap()

/**
* A command executor that communicates with the server using JSON over HTTP.
Expand Down
15 changes: 4 additions & 11 deletions javascript/node/selenium-webdriver/lib/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
* @fileoverview Defines types related to user input with the WebDriver API.
*/
const { Command, Name } = require('./command')
const {
InvalidArgumentError
} = require('./error')
const { InvalidArgumentError } = require('./error')

/**
* Enumeration of the buttons used in the advanced interactions API.
Expand Down Expand Up @@ -499,7 +497,6 @@ class Actions {
* sequence (see class description for details).
*/
constructor(executor, { async = false } = {}) {

/** @private @const */
this.executor_ = executor

Expand Down Expand Up @@ -878,13 +875,9 @@ class Actions {
return Promise.resolve()
}

try {
await this.executor_.execute(
new Command(Name.ACTIONS).setParameter('actions', _actions)
)
} catch (ex) {
throw ex
}
await this.executor_.execute(
new Command(Name.ACTIONS).setParameter('actions', _actions)
)
}
}

Expand Down
30 changes: 14 additions & 16 deletions javascript/node/selenium-webdriver/lib/until.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,13 @@ exports.alertIsPresent = function alertIsPresent() {
* @return {!Condition<boolean>} The new condition.
*/
exports.titleIs = function titleIs(title) {
return new Condition(
'for title to be ' + JSON.stringify(title),
function (driver) {
return driver.getTitle().then(function (t) {
return t === title
})
}
)
return new Condition('for title to be ' + JSON.stringify(title), function (
driver
) {
return driver.getTitle().then(function (t) {
return t === title
})
})
}

/**
Expand Down Expand Up @@ -189,14 +188,13 @@ exports.titleMatches = function titleMatches(regex) {
* @return {!Condition<boolean>} The new condition.
*/
exports.urlIs = function urlIs(url) {
return new Condition(
'for URL to be ' + JSON.stringify(url),
function (driver) {
return driver.getCurrentUrl().then(function (u) {
return u === url
})
}
)
return new Condition('for URL to be ' + JSON.stringify(url), function (
driver
) {
return driver.getCurrentUrl().then(function (u) {
return u === url
})
})
}

/**
Expand Down
6 changes: 3 additions & 3 deletions javascript/node/selenium-webdriver/opera.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,9 @@ class Driver extends webdriver.WebDriver {
caps = options.toCapabilities(caps)
}

return /** @type {!Driver} */ (super.createSession(executor, caps, () =>
service.kill()
))
return /** @type {!Driver} */ (
super.createSession(executor, caps, () => service.kill())
)
}

/**
Expand Down
6 changes: 3 additions & 3 deletions javascript/node/selenium-webdriver/safari.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ class Driver extends webdriver.WebDriver {
service.start().then((url) => new http.HttpClient(url))
)

return /** @type {!Driver} */ (super.createSession(executor, caps, () =>
service.kill()
))
return /** @type {!Driver} */ (
super.createSession(executor, caps, () => service.kill())
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ test.suite(
await driver.onLogException(cdpConnection, function (event) {
assert.strictEqual(
event['exceptionDetails']['stackTrace']['callFrames'][0][
'functionName'
'functionName'
],
'onmouseover'
)
Expand Down Expand Up @@ -139,7 +139,6 @@ test.suite(
})

describe('Basic Auth Injection', function () {

it('denies entry if username and password do not match', async function () {
const pageCdpConnection = await driver.createCDPConnection('page')

Expand Down
44 changes: 29 additions & 15 deletions javascript/node/selenium-webdriver/test/chrome/options_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ describe('chrome.Options', function () {
assert.strictEqual(options.options_.extensions, undefined)

options.addExtensions(['a', 'b'], 'c', [1, 2], 3)
assert.deepStrictEqual(options.options_.extensions, ['a', 'b', 'c', 1, 2, 3])
assert.deepStrictEqual(options.options_.extensions, [
'a',
'b',
'c',
1,
2,
3,
])
})
})

Expand All @@ -92,21 +99,28 @@ describe('chrome.Options', function () {
})
})

describe('windowTypes', function() {
it('takes var_args', function() {
let options = new chrome.Options();
assert.strictEqual(options.options_.windowTypes, undefined);
options.windowTypes('a', 'b');
assert.deepStrictEqual(options.options_.windowTypes, ['a', 'b']);
describe('windowTypes', function () {
it('takes var_args', function () {
let options = new chrome.Options()
assert.strictEqual(options.options_.windowTypes, undefined)

options.windowTypes('a', 'b')
assert.deepStrictEqual(options.options_.windowTypes, ['a', 'b'])
})

it('flattens input arrays', function() {
let options = new chrome.Options();
assert.strictEqual(options.options_.windowTypes, undefined);

options.windowTypes(['a', 'b'], 'c', [1, 2], 3);
assert.deepStrictEqual(options.options_.windowTypes, ['a', 'b', 'c', 1, 2, 3]);

it('flattens input arrays', function () {
let options = new chrome.Options()
assert.strictEqual(options.options_.windowTypes, undefined)

options.windowTypes(['a', 'b'], 'c', [1, 2], 3)
assert.deepStrictEqual(options.options_.windowTypes, [
'a',
'b',
'c',
1,
2,
3,
])
})
})
})
Expand Down
Loading