From 87020a909ebae6d790e26026b40cfdfdc544249a Mon Sep 17 00:00:00 2001 From: yihuineng <471110230@qq.com> Date: Thu, 12 Oct 2023 16:45:59 +0800 Subject: [PATCH] fix: lint --- .eslintrc.js | 64 ++++++++++++----------- lib/helper/assert.js | 8 +-- lib/helper/coverage.js | 2 +- lib/helper/element.js | 8 +-- lib/helper/index.js | 2 +- lib/helper/macaca-datahub.js | 2 +- lib/helper/reporter.js | 2 +- lib/macaca-wd.js | 2 +- lib/next/index.js | 8 +-- lib/web/react-router-helper.js | 2 +- package.json | 8 ++- test/alert.test.js | 5 +- test/assert.test.js | 7 +-- test/browser.test.js | 5 +- test/cookie.test.js | 7 +-- test/excecute.test.js | 5 +- test/helper.js | 6 +-- test/screenshot.test.js | 5 +- test/session.test.js | 5 +- test/source.test.js | 5 +- test/title.test.js | 5 +- test/url.test.js | 5 +- test/utility.test.js | 7 +-- test/window.test.js | 5 +- wd/lib/actions.js | 11 ++++ wd/lib/asserters.js | 19 ++++--- wd/lib/bin.js | 2 + wd/lib/callbacks.js | 2 + wd/lib/commands.js | 94 ++++++++++++++++++++++++++++------ wd/lib/config.js | 4 ++ wd/lib/deprecated-chain.js | 2 + wd/lib/element-commands.js | 59 +++++++++++++++++++++ wd/lib/element.js | 2 + wd/lib/http-utils.js | 4 +- wd/lib/jsonwire-errors.js | 2 + wd/lib/lodash.js | 2 + wd/lib/main.js | 7 ++- wd/lib/promise-webdriver.js | 3 ++ wd/lib/tmp.js | 2 + wd/lib/utils.js | 2 + wd/lib/webdriver.js | 3 ++ 41 files changed, 294 insertions(+), 106 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 904c0ca7..5b26c8ad 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,35 +1,41 @@ -module.exports = { - root: true, - extends: 'eslint-config-egg/typescript', - globals: { - window: true, +'use strict'; + +/* eslint-env node */ +const eslintConfig = { + extends: 'eslint-config-egg', + env: { + browser: true, + es6: true, + node: true, }, + settings: { + 'import/resolver': { + alias: { + map: [ + [ '@', `${__dirname}/src` ], + ], + extensions: [ '.js', '.jsx', '.json' ], + }, + }, + }, + parserOptions: { + ecmaVersion: 2020, + ecmaFeatures: { + experimentalObjectRestSpread: true, + }, + }, + plugins: [ + 'import' + ], + ignorePatterns: [ '*.d.ts' ], rules: { - 'jsdoc/check-tag-names': 0, - 'valid-jsdoc': 0, - 'no-script-url': 0, - 'no-multi-spaces': 0, - 'default-case': 0, - 'no-case-declarations': 0, - 'one-var-declaration-per-line': 0, - 'no-restricted-syntax': 0, - 'jsdoc/require-param': 0, - 'jsdoc/check-param-names': 0, + 'import/extensions': 0, + 'jsdoc/require-param-type': 0, 'jsdoc/require-param-description': 0, + 'jsdoc/check-tag-names': 0, 'jsdoc/require-returns-description': 0, - 'arrow-parens': 0, - 'prefer-promise-reject-errors': 0, - 'no-control-regex': 0, - 'no-use-before-define': 0, - 'array-callback-return': 0, - 'no-bitwise': 0, - 'no-self-compare': 0, - '@typescript-eslint/no-var-requires': 0, - '@typescript-eslint/ban-ts-ignore': 0, - '@typescript-eslint/no-use-before-define': 0, - '@typescript-eslint/no-this-alias': 0, - 'one-var': 0, - 'no-sparse-arrays': 0, - 'no-useless-concat': 0, }, + overrides: [], }; + +module.exports = eslintConfig; diff --git a/lib/helper/assert.js b/lib/helper/assert.js index 6157f6f0..7c217d56 100644 --- a/lib/helper/assert.js +++ b/lib/helper/assert.js @@ -1,4 +1,4 @@ - +'use strict'; const { assert } = require('chai'); @@ -47,7 +47,7 @@ module.exports = wd => { return this.title().then(realTitle => { assert( title === realTitle, - `expect title to be '${title}' but got ${realTitle}`, + `expect title to be '${title}' but got ${realTitle}` ); }); }); @@ -63,11 +63,11 @@ module.exports = wd => { */ wd.addPromiseChainMethod('assertAttribute', function(attribute, value) { return this.execute( - `return window.__macaca_current_element.getAttribute('${attribute}')`, + `return window.__macaca_current_element.getAttribute('${attribute}')` ).then(realValue => { assert( value === realValue, - `expect attribute ${attribute} to be '${value}' but got '${realValue}'`, + `expect attribute ${attribute} to be '${value}' but got '${realValue}'` ); }); }); diff --git a/lib/helper/coverage.js b/lib/helper/coverage.js index 9035cc1d..32ae7103 100644 --- a/lib/helper/coverage.js +++ b/lib/helper/coverage.js @@ -1,4 +1,4 @@ - +'use strict'; const fs = require('fs'); const path = require('path'); diff --git a/lib/helper/element.js b/lib/helper/element.js index 8720a200..79b73d59 100644 --- a/lib/helper/element.js +++ b/lib/helper/element.js @@ -1,4 +1,4 @@ - +'use strict'; const fs = require('fs'); const path = require('path'); @@ -46,6 +46,7 @@ module.exports = wd => { .get(url) .execute('return location.protocol') .then(protocol => { + // eslint-disable-next-line no-bitwise if (!~[ 'http:', 'https:' ].indexOf(protocol)) { return new Promise(resolve => { const handle = () => { @@ -53,6 +54,7 @@ module.exports = wd => { this.get(url) .execute('return location.protocol') .then(protocol => { + // eslint-disable-next-line no-bitwise if (~[ 'http:', 'https:' ].indexOf(protocol)) { setTimeout(resolve, 3000); } else { @@ -92,7 +94,7 @@ module.exports = wd => { */ wd.addPromiseChainMethod('saveVideos', function(context, params = {}) { params.video = true; - return this.saveScreenshot(null, params).then((filepath) => { + return this.saveScreenshot(null, params).then(filepath => { appendToContext(context, `${path.relative(reportspath, filepath)}`); }); }); @@ -185,7 +187,7 @@ module.exports = wd => { ${domEventLibSource} var _element_${uuid} = window.__macaca_current_element; _macaca_simulate.domEvent(_element_${uuid}, '${eventName}', ${JSON.stringify( - options, + options )}); `; return this.execute(script); diff --git a/lib/helper/index.js b/lib/helper/index.js index 89418341..a9adb37e 100644 --- a/lib/helper/index.js +++ b/lib/helper/index.js @@ -1,4 +1,4 @@ - +'use strict'; const extendsMixIn = wd => { require('../next')(wd); diff --git a/lib/helper/macaca-datahub.js b/lib/helper/macaca-datahub.js index 8e1a2798..7c8a5cbf 100644 --- a/lib/helper/macaca-datahub.js +++ b/lib/helper/macaca-datahub.js @@ -1,4 +1,4 @@ - +'use strict'; const DataHubClient = require('datahub-nodejs-sdk'); diff --git a/lib/helper/reporter.js b/lib/helper/reporter.js index 91930b38..0f09c982 100644 --- a/lib/helper/reporter.js +++ b/lib/helper/reporter.js @@ -1,4 +1,4 @@ - +'use strict'; const path = require('path'); const _ = require('xutil'); diff --git a/lib/macaca-wd.js b/lib/macaca-wd.js index 398b42d6..6dc3bfce 100644 --- a/lib/macaca-wd.js +++ b/lib/macaca-wd.js @@ -1,4 +1,4 @@ - +'use strict'; const helper = require('./helper'); const wd = require('../wd/lib/main'); diff --git a/lib/next/index.js b/lib/next/index.js index 9ccac259..a5333862 100644 --- a/lib/next/index.js +++ b/lib/next/index.js @@ -1,11 +1,11 @@ - +'use strict'; module.exports = wd => { [ 'page', 'pagePopup', 'browser', - ].map(method => { + ].forEach(method => { wd.addPromiseChainMethod(method, function(...params) { const [ func, ...args ] = params; return this.next(method, [{ func, args }]); @@ -15,7 +15,7 @@ module.exports = wd => { [ 'fileChooser', 'elementStatus', - ].map(method => { + ].forEach(method => { wd.addPromiseChainMethod(method, function(...params) { return this.next(method, params); }); @@ -24,7 +24,7 @@ module.exports = wd => { [ 'mouse', 'keyboard', - ].map(method => { + ].forEach(method => { wd.addPromiseChainMethod(method, function(...params) { const [ type, ...args ] = params; return this.next(method, [{ type, args }]); diff --git a/lib/web/react-router-helper.js b/lib/web/react-router-helper.js index f84ef67f..955f0c18 100644 --- a/lib/web/react-router-helper.js +++ b/lib/web/react-router-helper.js @@ -1,4 +1,4 @@ - +'use strict'; const fs = require('fs'); const _ = require('lodash'); diff --git a/package.json b/package.json index 07a3e6f3..a44ab032 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "xutil": "1" }, "devDependencies": { - "eslint": "7", + "eslint": "8", + "eslint-config-egg": "^12.2.1", "git-contributor": "1", "husky": "^1.3.1", "jsdom": "^11.10.0", @@ -50,10 +51,7 @@ "mocha": "*", "nyc": "^11.6.0", "stoppable": "^1.1.0", - "vuepress": "^1.9.8", - "ts-node": "^10.9.1", - "typescript": "^4.8.2", - "eslint-config-egg": "^11.0.1" + "vuepress": "^1.9.8" }, "scripts": { "docs:dev": "vuepress dev docs", diff --git a/test/alert.test.js b/test/alert.test.js index 6c4093ee..cd5f75f7 100644 --- a/test/alert.test.js +++ b/test/alert.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/alert.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); diff --git a/test/assert.test.js b/test/assert.test.js index 372e868a..69ce93c7 100644 --- a/test/assert.test.js +++ b/test/assert.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -8,7 +8,8 @@ const { elFuncFullType, elFuncSuffix } = require('../wd/lib/utils'); const wd = require('../lib/macaca-wd'); describe('test/asserter.test.js', function() { - let driver, server; + let driver, + server; const mockServer = async (mockKey, mockValue) => { server = new Server(); @@ -57,7 +58,7 @@ describe('test/asserter.test.js', function() { const { script, args } = server.ctx.request.body; assert.equal( script, - "return window.__macaca_current_element.getAttribute('class')", + "return window.__macaca_current_element.getAttribute('class')" ); assert.equal(args.length, 0); }); diff --git a/test/browser.test.js b/test/browser.test.js index 0643bf25..b63b95c4 100644 --- a/test/browser.test.js +++ b/test/browser.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/browser.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); diff --git a/test/cookie.test.js b/test/cookie.test.js index 6e781f21..c8db9a27 100644 --- a/test/cookie.test.js +++ b/test/cookie.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/cookie.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); @@ -71,7 +72,7 @@ describe('test/cookie.test.js', function() { await driver.deleteCookie('test_cookie'); assert.equal( server.ctx.url, - '/wd/hub/session/sessionId/cookie/test_cookie', + '/wd/hub/session/sessionId/cookie/test_cookie' ); assert.equal(server.ctx.method, 'DELETE'); assert.deepEqual(server.ctx.request.body, {}); diff --git a/test/excecute.test.js b/test/excecute.test.js index 032835a1..5bda83f9 100644 --- a/test/excecute.test.js +++ b/test/excecute.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/execute.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); diff --git a/test/helper.js b/test/helper.js index e5ab6877..e0da69fe 100644 --- a/test/helper.js +++ b/test/helper.js @@ -1,4 +1,4 @@ - +'use strict'; const http = require('http'); const Koa = require('koa'); @@ -12,7 +12,7 @@ class Server { { port: 3456, }, - options || {}, + options || {} ); this.app = new Koa(); this.app.use(bodyParser()); @@ -40,7 +40,7 @@ class Server { }); } this.server = stoppable( - http.createServer(this.app.callback()).listen(this.options.port), + http.createServer(this.app.callback()).listen(this.options.port) ); } diff --git a/test/screenshot.test.js b/test/screenshot.test.js index 1c9a129c..c72ddfaf 100644 --- a/test/screenshot.test.js +++ b/test/screenshot.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/screenshot.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); diff --git a/test/session.test.js b/test/session.test.js index 93838eda..442a94b1 100644 --- a/test/session.test.js +++ b/test/session.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/session.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); diff --git a/test/source.test.js b/test/source.test.js index 19f73ae1..a4caaf8d 100644 --- a/test/source.test.js +++ b/test/source.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/source.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); diff --git a/test/title.test.js b/test/title.test.js index 69603f86..c698a10b 100644 --- a/test/title.test.js +++ b/test/title.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/title.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); diff --git a/test/url.test.js b/test/url.test.js index e81d4d49..e98ed490 100644 --- a/test/url.test.js +++ b/test/url.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/url.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); diff --git a/test/utility.test.js b/test/utility.test.js index 3107e22a..30519c2e 100644 --- a/test/utility.test.js +++ b/test/utility.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/utility.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); @@ -130,7 +131,7 @@ describe('test/utility.test.js', function() { }); assert.equal( server.ctx.url, - '/wd/hub/session/sessionId/window/current/size', + '/wd/hub/session/sessionId/window/current/size' ); assert.equal(server.ctx.method, 'POST'); assert.deepEqual(server.ctx.request.body, { diff --git a/test/window.test.js b/test/window.test.js index 785bc3dd..bffbdf65 100644 --- a/test/window.test.js +++ b/test/window.test.js @@ -1,4 +1,4 @@ - +'use strict'; const assert = require('assert'); @@ -7,7 +7,8 @@ const { Server } = require('./helper'); const wd = require('../lib/macaca-wd'); describe('test/window.test.js', function() { - let driver, server; + let driver, + server; before(() => { server = new Server(); server.start(); diff --git a/wd/lib/actions.js b/wd/lib/actions.js index c1f3210f..967c7934 100644 --- a/wd/lib/actions.js +++ b/wd/lib/actions.js @@ -1,3 +1,5 @@ +'use strict'; + const _ = require('lodash'); const __slice = Array.prototype.slice; const Webdriver = require('./webdriver'); @@ -7,6 +9,7 @@ const Element = require('./element'); * new wd.TouchAction() * TouchAction constructor * + * @param driver * @actions */ const TouchAction = function(driver) { @@ -52,6 +55,7 @@ TouchAction.prototype.toJSON = function() { * touchAction.longPress({el, x, y}) * pass el or (x,y) or both * + * @param opts * @actions */ TouchAction.prototype.longPress = function(opts) { @@ -63,6 +67,7 @@ TouchAction.prototype.longPress = function(opts) { * touchAction.moveTo({el, x, y}) * pass el or (x,y) or both * + * @param opts * @actions */ TouchAction.prototype.moveTo = function(opts) { @@ -74,6 +79,7 @@ TouchAction.prototype.moveTo = function(opts) { * touchAction.press({el, x, y}) * pass el or (x,y) or both * + * @param opts * @actions */ TouchAction.prototype.press = function(opts) { @@ -96,6 +102,7 @@ TouchAction.prototype.release = function() { * pass el or (x,y) or both * count is optional * + * @param opts * @actions */ TouchAction.prototype.tap = function(opts) { @@ -108,6 +115,7 @@ TouchAction.prototype.tap = function(opts) { * touchAction.wait(ms) * ms is optional * + * @param opts * @actions */ TouchAction.prototype.wait = function(opts) { @@ -128,6 +136,7 @@ TouchAction.prototype.cancel = function() { /** * perform the action * + * @param cb * @actions */ TouchAction.prototype.perform = function(cb) { @@ -142,6 +151,7 @@ TouchAction.prototype.perform = function(cb) { * new wd.MultiAction() * MultiAction constructor * + * @param browserOrElement * @actions */ const MultiAction = function(browserOrElement) { @@ -186,6 +196,7 @@ MultiAction.prototype.cancel = function() { /** * multiAction.perform() * + * @param cb * @actions */ MultiAction.prototype.perform = function(cb) { diff --git a/wd/lib/asserters.js b/wd/lib/asserters.js index 84212319..5db535e9 100644 --- a/wd/lib/asserters.js +++ b/wd/lib/asserters.js @@ -1,3 +1,5 @@ +'use strict'; + const _ = require('./lodash'); const __slice = Array.prototype.slice; const utils = require('./utils'); @@ -19,12 +21,13 @@ const nonEmptyText = new Asserter( const satisfied = text && _(text).trim().value().length > 0; cb(null, satisfied, satisfied ? text : undefined); }); - }, + } ); /** * asserters.textInclude(content) -> Asserter * + * @param content * @asserter */ function textInclude(content) { @@ -35,7 +38,7 @@ function textInclude(content) { const satisfied = text && _(text).includeString(content).value(); cb(null, satisfied, satisfied ? text : undefined); }); - }, + } ); } @@ -50,14 +53,14 @@ const isDisplayed = new Asserter( if (err) { return cb(err); } cb(null, displayed); }); - }, + } ); const isVisible = new Asserter( function() { deprecator.warn('isVisible asserter', 'isVisible asserter has been deprecated, use isDisplayed asserter instead.'); const args = __slice.call(arguments, 0); isDisplayed.assert.apply(this, args); - }, + } ); /** @@ -71,20 +74,22 @@ const isNotDisplayed = new Asserter( if (err) { return cb(err); } cb(null, !displayed); }); - }, + } ); const isHidden = new Asserter( function() { deprecator.warn('isHidden asserter', 'isHidden asserter has been deprecated, use isNotDisplayed asserter instead.'); const args = __slice.call(arguments, 0); isNotDisplayed.assert.apply(this, args); - }, + } ); /** * asserters.jsCondition(jsConditionExpr) -> Asserter * jsConditionExpr: js script expression, should evaluate as boolean. * + * @param jsConditionExpr + * @param safe * @asserter */ function jsCondition(jsConditionExpr, safe) { @@ -97,7 +102,7 @@ function jsCondition(jsConditionExpr, safe) { if (err) { return cb(err); } cb(null, res, res); } ]); - }, + } ); } diff --git a/wd/lib/bin.js b/wd/lib/bin.js index 2ab419ba..aa4c7a5e 100755 --- a/wd/lib/bin.js +++ b/wd/lib/bin.js @@ -1,5 +1,7 @@ #!/usr/bin/env node +'use strict'; + const net = require('net'); const repl = require('repl'); const assert = require('assert'); diff --git a/wd/lib/callbacks.js b/wd/lib/callbacks.js index 3ed6a86e..ad6c4b1c 100644 --- a/wd/lib/callbacks.js +++ b/wd/lib/callbacks.js @@ -1,3 +1,5 @@ +'use strict'; + const utils = require('./utils'); const newError = utils.newError; const getJsonwireError = utils.getJsonwireError; diff --git a/wd/lib/commands.js b/wd/lib/commands.js index 27c6c6ac..2e0bf533 100644 --- a/wd/lib/commands.js +++ b/wd/lib/commands.js @@ -1,3 +1,5 @@ +'use strict'; + const fs = require('fs'); const url = require('url'); const path = require('path'); @@ -174,6 +176,7 @@ commands.safeExecute = function() { * Safely evaluate expression, always returning (using safeExecute): * safeEval(code, cb) -> cb(err, value) * + * @param code * @jsonWire POST /session/:sessionId/execute */ commands.safeEval = function(code) { @@ -322,6 +325,7 @@ commands.currentContext = function() { /** * context(contextRef, cb) -> cb(err, context) * + * @param contextRef * @jsonWire POST /session/:sessionId/context */ commands.context = function(contextRef) { @@ -351,6 +355,7 @@ commands.contexts = function() { /** * window(name, cb) -> cb(err) * + * @param windowRef * @jsonWire POST /session/:sessionId/window */ commands.window = function(windowRef) { @@ -366,6 +371,7 @@ commands.window = function(windowRef) { /** * frame(frameRef, cb) -> cb(err) * + * @param frameRef * @jsonWire POST /session/:sessionId/frame */ commands.frame = function(frameRef) { @@ -441,6 +447,9 @@ commands.getGeoLocation = function() { /** * setGeoLocation(lat, lon, alt, cb) -> cb(err) * + * @param lat + * @param lon + * @param alt * @jsonWire POST /session/:sessionId/location */ commands.setGeoLocation = function(lat, lon, alt) { @@ -459,6 +468,8 @@ commands.setGeoLocation = function(lat, lon, alt) { /** * scroll(xOffset, yOffset, cb) -> cb(err) * + * @param xOffset + * @param yOffset * @jsonWire POST /session/:sessionId/touch/scroll */ commands.scroll = function(xOffset, yOffset) { @@ -488,6 +499,7 @@ commands.logTypes = function() { /** * log(logType, cb) -> cb(err, arrayOfLogs) * + * @param logType * @jsonWire POST /session/:sessionId/log */ commands.log = function(logType) { @@ -520,6 +532,7 @@ commands.quit = function() { * get(url,cb) -> cb(err) * Get a new url. * + * @param _url * @jsonWire POST /session/:sessionId/url */ commands.get = function(_url) { @@ -552,6 +565,7 @@ commands.refresh = function() { /** * maximize(handle, cb) -> cb(err) * + * @param win * @jsonWire POST /session/:sessionId/window/:windowHandle/maximize */ commands.maximize = function(win) { @@ -569,6 +583,9 @@ commands.maximize = function(win) { /** * windowSize(handle, width, height, cb) -> cb(err) * + * @param win + * @param width + * @param height * @jsonWire POST /session/:sessionId/window/:windowHandle/size */ commands.windowSize = function(win, width, height) { @@ -721,6 +738,7 @@ commands.configureHttp = function() { /** * setImplicitWaitTimeout(ms, cb) -> cb(err) * + * @param ms * @jsonWire POST /session/:sessionId/timeouts/implicit_wait */ commands.setImplicitWaitTimeout = function(ms) { @@ -739,6 +757,7 @@ commands.setWaitTimeout = commands.setImplicitWaitTimeout; /** * setAsyncScriptTimeout(ms, cb) -> cb(err) * + * @param ms * @jsonWire POST /session/:sessionId/timeouts/async_script */ commands.setAsyncScriptTimeout = function(ms) { @@ -755,6 +774,7 @@ commands.setAsyncScriptTimeout = function(ms) { * setPageLoadTimeout(ms, cb) -> cb(err) * (use setImplicitWaitTimeout and setAsyncScriptTimeout to set the other timeouts) * + * @param ms * @jsonWire POST /session/:sessionId/timeouts */ commands.setPageLoadTimeout = function(ms) { @@ -770,6 +790,7 @@ commands.setPageLoadTimeout = function(ms) { /** * setCommandTimeout(ms, cb) -> cb(err) * (this is for Appium only) + * @param ms * @jsonWire POST /session/:sessionId/timeouts */ commands.setCommandTimeout = function(ms) { @@ -785,6 +806,8 @@ commands.setCommandTimeout = function(ms) { /** * element(using, value, cb) -> cb(err, element) * + * @param using + * @param value * @jsonWire POST /session/:sessionId/element */ commands.element = function(using, value) { @@ -801,6 +824,8 @@ commands.element = function(using, value) { * Retrieve an element avoiding not found exception and returning null instead: * elementOrNull(using, value, cb) -> cb(err, element) * + * @param using + * @param value * @jsonWire POST /session/:sessionId/elements * @docOrder 3 */ @@ -825,6 +850,8 @@ commands.elementOrNull = function(using, value) { * Retrieve an element avoiding not found exception and returning undefined instead: * elementIfExists(using, value, cb) -> cb(err, element) * + * @param using + * @param value * @jsonWire POST /session/:sessionId/elements * @docOrder 5 */ @@ -848,6 +875,8 @@ commands.elementIfExists = function(using, value) { /** * elements(using, value, cb) -> cb(err, elements) * + * @param using + * @param value * @jsonWire POST /session/:sessionId/elements * @docOrder 1 */ @@ -865,6 +894,8 @@ commands.elements = function(using, value) { * Check if element exists: * hasElement(using, value, cb) -> cb(err, boolean) * + * @param using + * @param value * @jsonWire POST /session/:sessionId/elements * @docOrder 7 */ @@ -930,10 +961,10 @@ commands.waitFor = function() { } else { throw err; } - }, + } ); } - }, + } ); function poll(isFinalCheck) { @@ -968,7 +999,6 @@ commands.waitFor = function() { * asserter like: function(element , cb) -> cb(err, satisfied, el) */ commands.waitForElement = function() { - const cb = findCallback(arguments); const fargs = utils.varargs(arguments); const using = fargs.all[0]; @@ -1010,10 +1040,10 @@ commands.waitForElement = function() { } else { throw err; } - }, + } ); } - }, + } ); const wrappedAsserter = new Asserter( @@ -1047,7 +1077,7 @@ commands.waitForElement = function() { cb(err, !_.isUndefined(satisfiedEl), satisfiedEl); }); }); - }, + } ); commands.waitFor.apply(this, [ @@ -1114,10 +1144,10 @@ commands.waitForElements = function() { } else { throw err; } - }, + } ); } - }, + } ); const wrappedAsserter = new Asserter( @@ -1148,7 +1178,7 @@ commands.waitForElements = function() { cb(err, satisfiedEls.length > 0, satisfiedEls); }); }); - }, + } ); commands.waitFor.apply(this, [ @@ -1318,7 +1348,7 @@ const addMethodsForSuffix = function(type, singular, plural) { } else { cb(err); } - }, + } ); commands.elements.apply(this, args); }; @@ -1356,7 +1386,7 @@ const addMethodsForSuffix = function(type, singular, plural) { } else { cb(err); } - }, + } ); commands.elements.apply(this, args); }; @@ -1468,6 +1498,7 @@ _.each(utils.elementFuncTypes, function(suffix) { /** * getTagName(element, cb) -> cb(err, name) * + * @param element * @jsonWire GET /session/:sessionId/element/:id/name */ commands.getTagName = function(element) { @@ -1550,6 +1581,7 @@ commands.getRect = function() { /** * isDisplayed(element, cb) -> cb(err, displayed) * + * @param element * @jsonWire GET /session/:sessionId/element/:id/displayed */ commands.isDisplayed = function(element) { @@ -1566,6 +1598,7 @@ commands.displayed = commands.isDisplayed; /** * isEnabled(element, cb) -> cb(err, enabled) * + * @param element * @jsonWire GET /session/:sessionId/element/:id/enabled */ commands.isEnabled = function(element) { @@ -1582,6 +1615,7 @@ commands.enabled = commands.isEnabled; /** * isSelected(element, cb) -> cb(err, selected) * + * @param element * @jsonWire GET /session/:sessionId/element/:id/selected */ commands.isSelected = function(element) { @@ -1650,6 +1684,8 @@ commands.takeElementScreenshot = function() { /** * getComputedCss(element, cssProperty , cb) -> cb(err, value) * + * @param element + * @param cssProperty * @jsonWire GET /session/:sessionId/element/:id/css/:propertyName */ commands.getComputedCss = function(element, cssProperty) { @@ -1666,6 +1702,8 @@ commands.getComputedCSS = commands.getComputedCss; /** * equalsElement(element, other , cb) -> cb(err, value) * + * @param element + * @param other * @jsonWire GET /session/:sessionId/element/:id/equals/:other */ commands.equalsElement = function(element, other) { @@ -1735,6 +1773,8 @@ commands.flick = function() { * tapElement(element) -> cb(err) * Taps element * + * @param element + * @param cb * @jsonWire POST /session/:sessionId/touch/click */ commands.tapElement = function(element, cb) { @@ -1936,6 +1976,8 @@ commands.doubleclick = function() { * Type keys (all keys are up at the end of command). * special key map: wd.SPECIAL_KEYS (see lib/special-keys.js) * + * @param element + * @param keys * @jsonWire POST /session/:sessionId/element/:id/value */ commands.type = function(element, keys) { @@ -1980,6 +2022,7 @@ commands.replace = function(element, keys) { * submit(element, cb) -> cb(err) * Submit a `FORM` element. * + * @param element * @jsonWire POST /session/:sessionId/element/:id/submit */ commands.submit = function(element) { @@ -1996,6 +2039,7 @@ commands.submit = function(element) { * Press keys (keys may still be down at the end of command). * special key map: wd.SPECIAL_KEYS (see lib/special-keys.js) * + * @param keys * @jsonWire POST /session/:sessionId/keys */ commands.keys = function(keys) { @@ -2020,6 +2064,7 @@ commands.keys = function(keys) { /** * clear(element, cb) -> cb(err) * + * @param element * @jsonWire POST /session/:sessionId/element/:id/clear */ commands.clear = function(element) { @@ -2099,6 +2144,8 @@ commands.text = function() { * textPresent(searchText, element, cb) -> cb(err, boolean) * element: specific element, 'body', or undefined * + * @param searchText + * @param element * @jsonWire GET /session/:sessionId/element/:id/text * @docOrder 3 */ @@ -2130,6 +2177,7 @@ commands.alertText = function() { /** * alertKeys(keys, cb) -> cb(err) * + * @param keys * @jsonWire POST /session/:sessionId/alert_text */ commands.alertKeys = function(keys) { @@ -2219,6 +2267,7 @@ commands.allCookies = function() { * Optional cookie fields: * path, domain, secure, expiry * + * @param cookie * @jsonWire POST /session/:sessionId/cookie */ commands.setCookie = function(cookie) { @@ -2253,6 +2302,7 @@ commands.deleteAllCookies = function() { /** * deleteCookie(name, cb) -> cb(err) * + * @param name * @jsonWire DELETE /session/:sessionId/cookie/:name */ commands.deleteCookie = function(name) { @@ -2281,6 +2331,7 @@ commands.getOrientation = function() { /** * setOrientation(cb) -> cb(err, orientation) * + * @param orientation * @jsonWire POST /session/:sessionId/orientation */ commands.setOrientation = function(orientation) { @@ -2308,7 +2359,7 @@ commands.setLocalStorageKey = function() { commands.safeExecute.apply( this, - [ 'localStorage.setItem(arguments[0], arguments[1])', [ key, value ], cb ], + [ 'localStorage.setItem(arguments[0], arguments[1])', [ key, value ], cb ] ); }; @@ -2326,7 +2377,7 @@ commands.getLocalStorageKey = function() { commands.safeEval.apply( this, - [ "localStorage.getItem('" + key + "')", cb ], + [ "localStorage.getItem('" + key + "')", cb ] ); }; @@ -2344,7 +2395,7 @@ commands.removeLocalStorageKey = function() { commands.safeExecute.apply( this, - [ 'localStorage.removeItem(arguments[0])', [ key ], cb ], + [ 'localStorage.removeItem(arguments[0])', [ key ], cb ] ); }; @@ -2361,7 +2412,7 @@ commands.clearLocalStorage = function() { commands.safeExecute.apply( this, - [ 'localStorage.clear()', cb ], + [ 'localStorage.clear()', cb ] ); }; @@ -2408,6 +2459,7 @@ commands.isVisible = function() { /** * Retrieves the pageIndex element (added for Appium): * getPageIndex(element, cb) -> cb(err, pageIndex) + * @param element */ commands.getPageIndex = function(element) { const cb = findCallback(arguments); @@ -2421,6 +2473,7 @@ commands.getPageIndex = function(element) { /** * getLocation(element, cb) -> cb(err, location) * + * @param element * @jsonWire GET /session/:sessionId/element/:id/location */ commands.getLocation = function(element) { @@ -2435,6 +2488,7 @@ commands.getLocation = function(element) { /** * getLocationInView(element, cb) -> cb(err, location) * + * @param element * @jsonWire GET /session/:sessionId/element/:id/location_in_view */ commands.getLocationInView = function(element) { @@ -2449,6 +2503,7 @@ commands.getLocationInView = function(element) { /** * getSize(element, cb) -> cb(err, size) * + * @param element * @jsonWire GET /session/:sessionId/element/:id/size */ commands.getSize = function(element) { @@ -2464,6 +2519,7 @@ commands.getSize = function(element) { * Uploads a local file using undocumented * POST /session/:sessionId/file * uploadFile(filepath, cb) -> cb(err, filepath) + * @param filepath */ commands.uploadFile = function(filepath) { const cb = findCallback(arguments); @@ -2492,7 +2548,7 @@ commands.uploadFile = function(filepath) { archive .append( fs.createReadStream(filepath), - { name: path.basename(filepath) }, + { name: path.basename(filepath) } ); archive.finalize(function(err) { @@ -2562,6 +2618,8 @@ commands.waitForConditionInBrowser = function() { /** * sleep(ms, cb) -> cb(err) + * @param ms + * @param cb */ commands.sleep = function(ms, cb) { cb = cb || function() { @@ -2572,6 +2630,7 @@ commands.sleep = function(ms, cb) { /** * noop(cb) -> cb(err) + * @param cb */ commands.noop = function(cb) { if (cb) { @@ -3140,6 +3199,8 @@ commands.getAppStrings = function() { /** * setImmediateValueInApp(element, value, cb) -> cb(err) * + * @param element + * @param value * @jsonWire POST /session/:sessionId/appium/element/:elementId?/value */ commands.setImmediateValueInApp = function(element, value) { @@ -3269,6 +3330,7 @@ commands.availableIMEEngines = function() { /** * activateIMEEngine(cb, engine) -> cb(err) * + * @param engine * @jsonWire POST /session/:sessionId/ime/activate */ commands.activateIMEEngine = function(engine) { diff --git a/wd/lib/config.js b/wd/lib/config.js index b4b85405..a773ffd3 100644 --- a/wd/lib/config.js +++ b/wd/lib/config.js @@ -1,3 +1,5 @@ +'use strict'; + const _ = require('./lodash'); const httpConfig = { @@ -18,6 +20,8 @@ function _configureHttp(httpConfig, opts) { if (opts[key] === 'always') { opts[key] = 0; } if (opts[key] === 'never') { opts[key] = -1; } break; + default: + break; } httpConfig[key] = opts[key]; }, this) diff --git a/wd/lib/deprecated-chain.js b/wd/lib/deprecated-chain.js index 266f83d3..d70d892a 100644 --- a/wd/lib/deprecated-chain.js +++ b/wd/lib/deprecated-chain.js @@ -1,3 +1,5 @@ +'use strict'; + const async = require('async'); const _ = require('./lodash'); diff --git a/wd/lib/element-commands.js b/wd/lib/element-commands.js index b4049363..b4dd5124 100644 --- a/wd/lib/element-commands.js +++ b/wd/lib/element-commands.js @@ -1,3 +1,5 @@ +'use strict'; + // Element object // Wrapper around browser methods const _ = require('./lodash'); @@ -15,6 +17,8 @@ const elementCommands = {}; /** * element.type(keys, cb) -> cb(err) * + * @param keys + * @param cb * @jsonWire POST /session/:sessionId/element/:id/value */ elementCommands.type = function(keys, cb) { @@ -24,6 +28,8 @@ elementCommands.type = function(keys, cb) { /** * element.keys(keys, cb) -> cb(err) * + * @param keys + * @param cb * @jsonWire POST /session/:sessionId/element/:id/value */ elementCommands.keys = function(keys, cb) { @@ -45,6 +51,8 @@ function _isLocalFile(path, cb) { * Equivalent to the python sendKeys binding. Upload file if * a local file is detected, otherwise behaves like type. * element.sendKeys(keys, cb) -> cb(err) + * @param keys + * @param cb */ elementCommands.sendKeys = function(keys, cb) { const _this = this; @@ -75,6 +83,8 @@ elementCommands.sendKeys = function(keys, cb) { * Equivalent to the python sendKeys binding, but replaces texts instead of keeping original. Upload file if * a local file is detected, otherwise behaves like type. * element.setText(keys, cb) -> cb(err) + * @param keys + * @param cb */ elementCommands.setText = function(keys, cb) { const _this = this; @@ -109,6 +119,7 @@ elementCommands.click = function() { /** * element.takeElementScreenshot(cb) -> cb(err) * + * @param cb * @jsonWire POST /session/:sessionId/element/:id/screenshot */ elementCommands.screenshot = function(cb) { @@ -118,6 +129,7 @@ elementCommands.screenshot = function(cb) { /** * element.tap(cb) -> cb(err) * + * @param cb * @jsonWire POST /session/:sessionId/touch/click */ elementCommands.tap = function(cb) { @@ -127,6 +139,7 @@ elementCommands.tap = function(cb) { /** * element.doubleClick(cb) -> cb(err) * + * @param cb * @jsonWire POST /session/:sessionId/doubleclick */ elementCommands.doubleclick = function(cb) { @@ -155,6 +168,10 @@ elementCommands.moveTo = function() { /** * element.flick(xoffset, yoffset, speed, cb) -> cb(err) * + * @param xoffset + * @param yoffset + * @param speed + * @param cb * @jsonWire POST /session/:sessionId/touch/flick */ elementCommands.flick = function(xoffset, yoffset, speed, cb) { @@ -164,6 +181,7 @@ elementCommands.flick = function(xoffset, yoffset, speed, cb) { /** * element.text(cb) -> cb(err, text) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/text * @docOrder 2 */ @@ -174,6 +192,8 @@ elementCommands.text = function(cb) { /** * element.textPresent(searchText, cb) -> cb(err, boolean) * + * @param searchText + * @param cb * @jsonWire GET /session/:sessionId/element/:id/text * @docOrder 4 */ @@ -184,6 +204,8 @@ elementCommands.textPresent = function(searchText, cb) { /** * element.getAttribute(attrName, cb) -> cb(err, value) * + * @param name + * @param cb * @jsonWire GET /session/:sessionId/element/:id/attribute/:name * @docOrder 2 */ @@ -194,6 +216,8 @@ elementCommands.getAttribute = function(name, cb) { /** * element.getProperty(propertyName, cb) -> cb(err, value) * + * @param name + * @param cb * @jsonWire GET /session/:sessionId/element/:id/property/:name * @docOrder 2 */ @@ -204,6 +228,7 @@ elementCommands.getProperty = function(name, cb) { /** * element.getRect(cb) -> cb(err, value) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/rect * @docOrder 2 */ @@ -214,6 +239,7 @@ elementCommands.getRect = function(cb) { /** * element.getTagName(cb) -> cb(err, name) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/name */ elementCommands.getTagName = function(cb) { @@ -223,6 +249,7 @@ elementCommands.getTagName = function(cb) { /** * element.isDisplayed(cb) -> cb(err, displayed) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/displayed */ elementCommands.isDisplayed = function(cb) { @@ -234,6 +261,7 @@ elementCommands.displayed = elementCommands.isDisplayed; /** * element.isSelected(cb) -> cb(err, selected) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/selected */ elementCommands.isSelected = function(cb) { @@ -245,6 +273,7 @@ elementCommands.selected = elementCommands.isSelected; /** * element.isEnabled(cb) -> cb(err, enabled) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/enabled */ elementCommands.isEnabled = function(cb) { @@ -255,6 +284,7 @@ elementCommands.enabled = elementCommands.isEnabled; /** * isVisible(cb) -> cb(err, boolean) + * @param cb */ elementCommands.isVisible = function(cb) { deprecator.warn('element.isVisible', 'element.isVisible has been deprecated, use element.isDisplayed instead.'); @@ -264,6 +294,7 @@ elementCommands.isVisible = function(cb) { /** * element.getLocation(cb) -> cb(err, location) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/location */ elementCommands.getLocation = function(cb) { @@ -273,6 +304,7 @@ elementCommands.getLocation = function(cb) { /** * element.getLocationInView(cb) -> cb(err, location) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/location */ elementCommands.getLocationInView = function(cb) { @@ -282,6 +314,7 @@ elementCommands.getLocationInView = function(cb) { /** * element.getSize(cb) -> cb(err, size) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/size */ elementCommands.getSize = function(cb) { @@ -291,6 +324,7 @@ elementCommands.getSize = function(cb) { /** * element.getValue(cb) -> cb(err, value) * + * @param cb * @jsonWire GET /session/:sessionId/element/:id/attribute/:name * @docOrder 4 */ @@ -301,6 +335,8 @@ elementCommands.getValue = function(cb) { /** * element.getComputedCss(cssProperty , cb) -> cb(err, value) * + * @param styleName + * @param cb * @jsonWire GET /session/:sessionId/element/:id/css/:propertyName */ elementCommands.getComputedCss = function(styleName, cb) { @@ -312,6 +348,7 @@ elementCommands.getComputedCSS = elementCommands.getComputedCss; /** * element.clear(cb) -> cb(err) * + * @param cb * @jsonWire POST /session/:sessionId/element/:id/clear */ elementCommands.clear = function(cb) { @@ -321,6 +358,7 @@ elementCommands.clear = function(cb) { /** * element.submit(cb) -> cb(err) * + * @param cb * @jsonWire POST /session/:sessionId/element/:id/submit */ elementCommands.submit = function(cb) { @@ -342,6 +380,8 @@ _.each(utils.elementFuncTypes, function(type) { * element.elementByAndroidUIAutomator(value, cb) -> cb(err, element) * element.elementByAccessibilityId(value, cb) -> cb(err, element) * + * @param value + * @param cb * @jsonWire POST /session/:sessionId/element/:id/element * @docOrder 2 */ @@ -363,6 +403,8 @@ _.each(utils.elementFuncTypes, function(type) { * element.elementsByAndroidUIAutomator(value, cb) -> cb(err, elements) * element.elementsByAccessibilityId(value, cb) -> cb(err, elements) * + * @param value + * @param cb * @jsonWire POST /session/:sessionId/element/:id/elements * @docOrder 2 */ @@ -374,6 +416,9 @@ _.each(utils.elementFuncTypes, function(type) { /** * element.element(using, value, cb) -> cb(err, element) * + * @param using + * @param value + * @param cb * @jsonWire POST /session/:sessionId/element/:id/element * @docOrder 1 */ @@ -390,6 +435,9 @@ elementCommands.element = function(using, value, cb) { /** * element.elements(using, value, cb) -> cb(err, elements) * + * @param using + * @param value + * @param cb * @jsonWire POST /session/:sessionId/element/:id/elements * @docOrder 1 */ @@ -406,6 +454,8 @@ elementCommands.elements = function(using, value, cb) { /** * element.equals(other, cb) -> cb(err, value) * + * @param other + * @param cb * @jsonWire GET /session/:sessionId/element/:id/equals/:other * @docOrder 1 */ @@ -415,6 +465,8 @@ elementCommands.equals = function(other, cb) { /** * element.sleep(ms, cb) -> cb(err) + * @param ms + * @param cb */ elementCommands.sleep = function(ms, cb) { cb = cb || function() { @@ -425,6 +477,7 @@ elementCommands.sleep = function(ms, cb) { /** * element.noop(cb) -> cb(err) + * @param cb */ elementCommands.noop = function(cb) { if (cb) { cb(); } @@ -433,6 +486,8 @@ elementCommands.noop = function(cb) { /** * element.performMultiAction(actions) -> cb(err, touchStateObjects) * + * @param actions + * @param cb * @jsonWire POST /session/:sessionId/touch/multi/perform */ elementCommands.performMultiAction = function(actions, cb) { @@ -444,6 +499,8 @@ elementCommands.performMultiAction = function(actions, cb) { * opts is like the following: * {x: 114, y: 198, duration: 5, radius: 3, rotation: 220, touchCount: 2} * + * @param opts + * @param cb * @jsonWire POST /session/:sessionId/appium/device/rotate */ elementCommands.rotate = function(opts, cb) { @@ -481,6 +538,8 @@ elementCommands.touch = function() { /** * element.setImmediateValueInApp(value, cb) -> cb(err) * + * @param value + * @param cb * @jsonWire POST /session/:sessionId/appium/element/:elementId?/value */ elementCommands.setImmediateValueInApp = function(value, cb) { diff --git a/wd/lib/element.js b/wd/lib/element.js index 260fcb83..7841b3aa 100644 --- a/wd/lib/element.js +++ b/wd/lib/element.js @@ -1,3 +1,5 @@ +'use strict'; + // Element object // Wrapper around browser methods const __slice = Array.prototype.slice; diff --git a/wd/lib/http-utils.js b/wd/lib/http-utils.js index 1dc55861..da86e33c 100644 --- a/wd/lib/http-utils.js +++ b/wd/lib/http-utils.js @@ -1,3 +1,5 @@ +'use strict'; + const request = require('request'); const utils = require('./utils'); const urllib = require('url'); @@ -14,7 +16,7 @@ exports.emit = function(browser, method, url, data) { if (typeof url === 'string') { url = urllib.parse(url); } browser.emit('http', method, url.path.replace(browser.sessionID, ':sessionID') - .replace(browser.configUrl.pathname, ''), data, + .replace(browser.configUrl.pathname, ''), data ); }; diff --git a/wd/lib/jsonwire-errors.js b/wd/lib/jsonwire-errors.js index 455b34ef..f919184d 100644 --- a/wd/lib/jsonwire-errors.js +++ b/wd/lib/jsonwire-errors.js @@ -1,3 +1,5 @@ +'use strict'; + const JSONWIRE_ERRORS = [ { status: 0, diff --git a/wd/lib/lodash.js b/wd/lib/lodash.js index 6bef4f2e..3248d02f 100644 --- a/wd/lib/lodash.js +++ b/wd/lib/lodash.js @@ -1,3 +1,5 @@ +'use strict'; + const _ = require('lodash'); _.str = require('underscore.string'); _.mixin(_.str.exports()); diff --git a/wd/lib/main.js b/wd/lib/main.js index 20f4946a..9cb910c7 100644 --- a/wd/lib/main.js +++ b/wd/lib/main.js @@ -1,3 +1,5 @@ +'use strict'; + const __slice = Array.prototype.slice; const url = require('url'); const SPECIAL_KEYS = require('webdriver-keycode'); @@ -89,7 +91,10 @@ const parseRemoteWdConfig = function(args) { return config; }; -let PromiseWebdriver, PromiseElement, PromiseChainWebdriver, PromiseChainElement; +let PromiseWebdriver, + PromiseElement, + PromiseChainWebdriver, + PromiseChainElement; // Creates the Webdriver object // server parameters can be passed in 4 ways diff --git a/wd/lib/promise-webdriver.js b/wd/lib/promise-webdriver.js index 11ddeeef..cb767a7c 100644 --- a/wd/lib/promise-webdriver.js +++ b/wd/lib/promise-webdriver.js @@ -1,3 +1,5 @@ +'use strict'; + const __slice = Array.prototype.slice; const Q = require('q'); const _ = require('./lodash'); @@ -281,6 +283,7 @@ module.exports = function(WebDriver, Element, chainable) { * Resolves the promise (promised driver only) * browser.resolve(promise) * element.resolve(promise) + * @param promise */ PromiseWebdriver.prototype.resolve = function(promise) { const qPromise = new Q(promise); diff --git a/wd/lib/tmp.js b/wd/lib/tmp.js index adfe21ba..56e90a47 100644 --- a/wd/lib/tmp.js +++ b/wd/lib/tmp.js @@ -1,3 +1,5 @@ +'use strict'; + // inspired by https://github.com/raszi/node-tmp, but only // provides tmp paths. diff --git a/wd/lib/utils.js b/wd/lib/utils.js index d67b575b..01317fad 100644 --- a/wd/lib/utils.js +++ b/wd/lib/utils.js @@ -1,3 +1,5 @@ +'use strict'; + const Args = require('vargs').Constructor; const _ = require('./lodash'); const url = require('url'); diff --git a/wd/lib/webdriver.js b/wd/lib/webdriver.js index 99e4a48b..019f2616 100644 --- a/wd/lib/webdriver.js +++ b/wd/lib/webdriver.js @@ -1,3 +1,5 @@ +'use strict'; + const EventEmitter = require('events').EventEmitter; const _ = require('./lodash'); const util = require('util'); @@ -45,6 +47,7 @@ Webdriver.prototype.newElement = function(jsonWireElement) { /** * attach(sessionID, cb) -> cb(err) * Connect to an already-active session. + * @param sessionID */ Webdriver.prototype.attach = function(sessionID) { const cb = findCallback(arguments);