Skip to content

Commit 941da9b

Browse files
authored
update code format, public API exports (#10097)
1 parent 83c97eb commit 941da9b

11 files changed

Lines changed: 94 additions & 88 deletions

File tree

javascript/node/selenium-webdriver/chrome.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,9 @@ class Driver extends chromium.Driver {
236236
*/
237237
static createSession(opt_config, opt_serviceExecutor) {
238238
let caps = opt_config || new Options()
239-
return /** @type {!Driver} */ (super.createSession(
240-
caps,
241-
opt_serviceExecutor
242-
))
239+
return /** @type {!Driver} */ (
240+
super.createSession(caps, opt_serviceExecutor)
241+
)
243242
}
244243
}
245244

javascript/node/selenium-webdriver/chromium.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,8 @@ class ServiceBuilder extends remote.DriverService.Builder {
217217
* Enables Chrome logging.
218218
* @returns {!ServiceBuilder} A self reference.
219219
*/
220-
enableChromeLogging() {
221-
return this.addArguments('--enable-chrome-logs');
220+
enableChromeLogging() {
221+
return this.addArguments('--enable-chrome-logs')
222222
}
223223

224224
/**
@@ -292,7 +292,7 @@ class Options extends Capabilities {
292292
* @return {!Options} A self reference.
293293
*/
294294
debuggerAddress(address) {
295-
this.options_.debuggerAddress = address;
295+
this.options_.debuggerAddress = address
296296
return this
297297
}
298298

@@ -882,6 +882,8 @@ class Driver extends webdriver.WebDriver {
882882

883883
// PUBLIC API
884884

885-
exports.Driver = Driver
886-
exports.Options = Options
887-
exports.ServiceBuilder = ServiceBuilder
885+
module.exports = {
886+
Driver,
887+
Options,
888+
ServiceBuilder,
889+
}

javascript/node/selenium-webdriver/edge.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ Driver.getDefaultService = getDefaultService
210210

211211
// PUBLIC API
212212

213-
exports.Driver = Driver
214-
exports.Options = Options
215-
exports.ServiceBuilder = ServiceBuilder
216-
exports.getDefaultService = getDefaultService
217-
exports.setDefaultService = setDefaultService
218-
exports.locateSynchronously = locateSynchronously
213+
module.exports = {
214+
Driver,
215+
Options,
216+
ServiceBuilder,
217+
getDefaultService,
218+
setDefaultService,
219+
locateSynchronously,
220+
}

javascript/node/selenium-webdriver/firefox.js

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ async function buildProfile(template, extensions) {
222222
dir = await io.tmpDir()
223223
if (template) {
224224
await io.copyDir(
225-
/** @type {string} */(template),
225+
/** @type {string} */ (template),
226226
dir,
227227
/(parent\.lock|lock|\.parentlock)/
228228
)
@@ -400,7 +400,11 @@ class Options extends Capabilities {
400400
* @param {string} androidPackage The package to use
401401
* @return {!Options} A self reference
402402
*/
403-
enableMobile(androidPackage = "org.mozilla.firefox", androidActivity = null, deviceSerial = null) {
403+
enableMobile(
404+
androidPackage = 'org.mozilla.firefox',
405+
androidActivity = null,
406+
deviceSerial = null
407+
) {
404408
this.firefoxOptions_().androidPackage = androidPackage
405409

406410
if (androidActivity) {
@@ -457,11 +461,11 @@ function findGeckoDriver() {
457461
if (!exe) {
458462
throw Error(
459463
'The ' +
460-
GECKO_DRIVER_EXE +
461-
' executable could not be found on the current ' +
462-
'PATH. Please download the latest version from ' +
463-
'https://github.com/mozilla/geckodriver/releases/ ' +
464-
'and ensure it can be found on your PATH.'
464+
GECKO_DRIVER_EXE +
465+
' executable could not be found on the current ' +
466+
'PATH. Please download the latest version from ' +
467+
'https://github.com/mozilla/geckodriver/releases/ ' +
468+
'and ensure it can be found on your PATH.'
465469
)
466470
}
467471
return exe
@@ -482,8 +486,8 @@ function findInProgramFiles(file) {
482486
return exists
483487
? files[0]
484488
: io.exists(files[1]).then(function (exists) {
485-
return exists ? files[1] : null
486-
})
489+
return exists ? files[1] : null
490+
})
487491
})
488492
}
489493

@@ -617,7 +621,7 @@ class Driver extends webdriver.WebDriver {
617621
* implementation.
618622
* @override
619623
*/
620-
setFileDetector() { }
624+
setFileDetector() {}
621625

622626
/**
623627
* Get the context that is currently in effect.
@@ -805,9 +809,11 @@ Channel.NIGHTLY = new Channel(
805809

806810
// PUBLIC API
807811

808-
exports.Channel = Channel
809-
exports.Context = Context
810-
exports.Driver = Driver
811-
exports.Options = Options
812-
exports.ServiceBuilder = ServiceBuilder
813-
exports.locateSynchronously = locateSynchronously
812+
module.exports = {
813+
Channel,
814+
Context,
815+
Driver,
816+
Options,
817+
ServiceBuilder,
818+
locateSynchronously,
819+
}

javascript/node/selenium-webdriver/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const Capabilities = capabilities.Capabilities
4545
const Capability = capabilities.Capability
4646
const WebDriver = webdriver.WebDriver
4747

48-
var seleniumServer
48+
let seleniumServer
4949

5050
/**
5151
* Starts an instance of the Selenium server if not yet running.

javascript/node/selenium-webdriver/io/index.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ function checkedCall(fn) {
4242
})
4343
}
4444

45-
// PUBLIC API
46-
4745
/**
4846
* Recursively removes a directory and all of its contents. This is equivalent
4947
* to {@code rm -rf} on a POSIX system.
@@ -114,18 +112,18 @@ function copyDir(src, dst, opt_exclude) {
114112
files = files.filter(/** @type {function(string): boolean} */ (predicate))
115113
}
116114

117-
var results = []
115+
const results = []
118116
files.forEach(function (file) {
119-
var stats = fs.statSync(file)
120-
var target = path.join(dst, path.basename(file))
117+
const stats = fs.statSync(file)
118+
const target = path.join(dst, path.basename(file))
121119

122120
if (stats.isDirectory()) {
123121
if (!fs.existsSync(target)) {
124122
fs.mkdirSync(target, stats.mode)
125123
}
126-
results.push(exports.copyDir(file, target, predicate))
124+
results.push(copyDir(file, target, predicate))
127125
} else {
128-
results.push(exports.copy(file, target))
126+
results.push(copy(file, target))
129127
}
130128
})
131129

@@ -137,7 +135,7 @@ function copyDir(src, dst, opt_exclude) {
137135
* @param {string} aPath The path to test.
138136
* @return {!Promise<boolean>} A promise for whether the file exists.
139137
*/
140-
exports.exists = function (aPath) {
138+
function exists(aPath) {
141139
return new Promise(function (fulfill, reject) {
142140
let type = typeof aPath
143141
if (type !== 'string') {
@@ -153,7 +151,7 @@ exports.exists = function (aPath) {
153151
* @param {string} aPath The path to stat.
154152
* @return {!Promise<!fs.Stats>} A promise for the file stats.
155153
*/
156-
exports.stat = function stat(aPath) {
154+
function stat(aPath) {
157155
return checkedCall((callback) => fs.stat(aPath, callback))
158156
}
159157

@@ -335,15 +333,19 @@ function walkDir(rootPath) {
335333
}
336334

337335
// PUBLIC API
338-
module.exports.walkDir = walkDir
339-
module.exports.rmDir = rmDir
340-
module.exports.mkdirp = mkdirp
341-
module.exports.mkdir = mkdir
342-
module.exports.write = write
343-
module.exports.read = read
344-
module.exports.findInPath = findInPath
345-
module.exports.tmpFile = tmpFile
346-
module.exports.tmpDir = tmpDir
347-
module.exports.unlink = unlink
348-
module.exports.copy = copy
349-
module.exports.copyDir = copyDir
336+
module.exports = {
337+
walkDir,
338+
rmDir,
339+
mkdirp,
340+
mkdir,
341+
write,
342+
read,
343+
findInPath,
344+
tmpFile,
345+
tmpDir,
346+
unlink,
347+
copy,
348+
copyDir,
349+
exists,
350+
stat,
351+
}

javascript/node/selenium-webdriver/io/zip.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,4 @@ function unzip(src, dst) {
218218
}
219219

220220
// PUBLIC API
221-
module.exports.Zip = Zip
222-
module.exports.load = load
223-
module.exports.unzip = unzip
221+
module.exports = { Zip, load, unzip }

javascript/node/selenium-webdriver/lib/by.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,10 @@ function check(locator) {
424424
// PUBLIC API
425425

426426
module.exports = {
427-
By: By,
428-
RelativeBy: RelativeBy,
429-
withTagName: withTagName,
430-
locateWith: locateWith,
427+
By,
428+
RelativeBy,
429+
withTagName,
430+
locateWith,
431+
escapeCss,
431432
checkedLocator: check,
432-
escapeCss: escapeCss
433433
}

javascript/node/selenium-webdriver/lib/error.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class NoSuchElementError extends WebDriverError {
217217
class NoSuchShadowRootError extends WebDriverError {
218218
/** @param {string=} opt_error the error message, if any. */
219219
constructor(opt_error) {
220-
super(opt_error);
220+
super(opt_error)
221221
}
222222
}
223223

javascript/node/selenium-webdriver/opera.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@
7272

7373
'use strict'
7474

75-
const http = require('./http'),
76-
io = require('./io'),
77-
capabilities = require('./lib/capabilities'),
78-
Symbols = require('./lib/symbols'),
79-
webdriver = require('./lib/webdriver'),
80-
remote = require('./remote')
75+
const http = require('./http')
76+
const io = require('./io')
77+
const capabilities = require('./lib/capabilities')
78+
const Symbols = require('./lib/symbols')
79+
const webdriver = require('./lib/webdriver')
80+
const remote = require('./remote')
8181

8282
/**
8383
* Name of the OperaDriver executable.
@@ -153,7 +153,7 @@ class ServiceBuilder extends remote.DriverService.Builder {
153153
}
154154

155155
/** @type {remote.DriverService} */
156-
var defaultService = null
156+
let defaultService = null
157157

158158
/**
159159
* Sets the default service to use for new OperaDriver instances.
@@ -187,7 +187,7 @@ function getDefaultService() {
187187
* @type {string}
188188
* @const
189189
*/
190-
var OPTIONS_CAPABILITY_KEY = 'chromeOptions'
190+
const OPTIONS_CAPABILITY_KEY = 'chromeOptions'
191191

192192
/**
193193
* Class for managing {@linkplain Driver OperaDriver} specific options.
@@ -217,8 +217,8 @@ class Options {
217217
* @return {!Options} The OperaDriver options.
218218
*/
219219
static fromCapabilities(caps) {
220-
var options
221-
var o = caps.get(OPTIONS_CAPABILITY_KEY)
220+
let options
221+
const o = caps.get(OPTIONS_CAPABILITY_KEY)
222222
if (o instanceof Options) {
223223
options = o
224224
} else if (o) {
@@ -249,8 +249,8 @@ class Options {
249249
* @param {...(string|!Array.<string>)} var_args The arguments to add.
250250
* @return {!Options} A self reference.
251251
*/
252-
addArguments(var_args) { // eslint-disable-line
253-
this.args_ = this.args_.concat.apply(this.args_, arguments)
252+
addArguments(...var_args) {
253+
this.args_ = this.args_.concat.apply(this.args_, var_args)
254254
return this
255255
}
256256

@@ -262,11 +262,8 @@ class Options {
262262
* extensions to add.
263263
* @return {!Options} A self reference.
264264
*/
265-
addExtensions(var_args) { // eslint-disable-line
266-
this.extensions_ = this.extensions_.concat.apply(
267-
this.extensions_,
268-
arguments
269-
)
265+
addExtensions(...var_args) {
266+
this.extensions_ = this.extensions_.concat.apply(this.extensions_, var_args)
270267
return this
271268
}
272269

@@ -358,19 +355,19 @@ class Driver extends webdriver.WebDriver {
358355
* @return {!Driver} A new driver instance.
359356
*/
360357
static createSession(opt_config, opt_service) {
361-
var service = opt_service || getDefaultService()
362-
var client = service.start().then((url) => new http.HttpClient(url))
363-
var executor = new http.Executor(client)
358+
const service = opt_service || getDefaultService()
359+
const client = service.start().then((url) => new http.HttpClient(url))
360+
const executor = new http.Executor(client)
364361

365-
var caps =
362+
let caps =
366363
opt_config instanceof Options
367364
? opt_config.toCapabilities()
368365
: opt_config || capabilities.Capabilities.opera()
369366

370367
// On Linux, the OperaDriver does not look for Opera on the PATH, so we
371368
// must explicitly find it. See: operachromiumdriver #9.
372369
if (process.platform === 'linux') {
373-
var options = Options.fromCapabilities(caps)
370+
const options = Options.fromCapabilities(caps)
374371
if (!options.binary_) {
375372
let exe = io.findInPath('opera', true)
376373
if (!exe) {

0 commit comments

Comments
 (0)