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

Update eslint #404

Merged
merged 1 commit into from
Mar 23, 2017
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
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";


var gulp = require('gulp'),
let gulp = require('gulp'),
boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp);

boilerplate({
Expand Down
12 changes: 9 additions & 3 deletions lib/commands/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,21 @@ commands.postDismissAlert = async function () {

helpers.getAlert = async function () {
let possibleAlert = await this.findNativeElementOrElements('class name', 'XCUIElementTypeScrollView', true);
if (possibleAlert.length !== 1) throw new errors.NoAlertOpenError();
if (possibleAlert.length !== 1) {
throw new errors.NoAlertOpenError();
}

let possibleAlertButtons = await this.findNativeElementOrElements('class name', 'XCUIElementTypeButton', true, possibleAlert[0].ELEMENT);
if (possibleAlertButtons.length < 1 || possibleAlertButtons.length > 2) throw new errors.NoAlertOpenError();
if (possibleAlertButtons.length < 1 || possibleAlertButtons.length > 2) {
throw new errors.NoAlertOpenError();
}

let assertButtonName = async (button, expectedName) => {
button = button.ELEMENT ? button.ELEMENT : button;
let name = await this.proxyCommand(`/element/${button}/attribute/name`, 'GET');
if (name.toLowerCase() !== expectedName) throw new errors.NoAlertOpenError();
if (name.toLowerCase() !== expectedName) {
throw new errors.NoAlertOpenError();
}
};

let alert = possibleAlert[0];
Expand Down
4 changes: 3 additions & 1 deletion lib/commands/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ extensions.closeAlertBeforeTest = async function () {
extensions._getLatestWebviewContextForTitle = extensions.getLatestWebviewContextForTitle;
extensions.getLatestWebviewContextForTitle = async function (regExp) {
let currentUrl = this.getCurrentUrl();
if (!currentUrl) return this._getLatestWebviewContextForTitle(regExp);
if (!currentUrl) {
return this._getLatestWebviewContextForTitle(regExp);
}

let contexts = await this.getContextsAndViews();
let matchingCtx;
Expand Down
8 changes: 5 additions & 3 deletions lib/commands/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,19 @@ commands.getSize = async function (el) {

function hasSpecialKeys (keys) {
for (let char of keys) {
if (isSpecialKey(char))
if (isSpecialKey(char)) {
return true;
}
}
return false;
}

function isSpecialKey (k) {
if (k === '\uE003' || k === '\ue017') // BACKSPACE or DELETE
if (k === '\uE003' || k === '\ue017') { // BACKSPACE or DELETE
return true;
else if (k === '\uE006' || k === '\uE007') // RETURN or ENTER
} else if (k === '\uE006' || k === '\uE007') { // RETURN or ENTER
return true;
}
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/commands/gesture.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ helpers.mobileDragFromToForDuration = async function (opts={}) {
return await this.proxyCommand('/wda/dragfromtoforduration', 'POST', params);
};

helpers.getCoordinates = async function(gesture) {
helpers.getCoordinates = async function (gesture) {
let el = gesture.options.element;

// defaults
Expand Down
4 changes: 3 additions & 1 deletion lib/commands/proxy-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ const GET_STATUS_COMMAND = 'getStatus';
let helpers = {}, extensions = {};

helpers.proxyCommand = async function (endpoint, method, body, isSessionCommand = true) {
if (this.shutdownUnexpectedly) return;
if (this.shutdownUnexpectedly) {
return;
}

if (!endpoint) {
log.errorAndThrow('Proxying requires an endpoint');
Expand Down
10 changes: 7 additions & 3 deletions lib/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ const NO_PROXY_WEB_LIST = [

function normalizeCommandTimeouts (value) {
// The value is normalized already
if (typeof value !== 'string') return value;
if (typeof value !== 'string') {
return value;
}

let result = {};
// Use as default timeout for all commands if a single integer value is provided
Expand Down Expand Up @@ -702,11 +704,13 @@ class XCUITestDriver extends BaseDriver {
validateDesiredCaps (caps) {
// check with the base class, and return if it fails
let res = super.validateDesiredCaps(caps);
if (!res) return res;
if (!res) {
return res;
}

// make sure that the capabilities have one of `app` or `bundleId`
if ((caps.browserName || '').toLowerCase() !== 'safari' &&
!caps.app && ! caps.bundleId) {
!caps.app && !caps.bundleId) {
let msg = 'The desired capabilities must include either an app or a bundleId for iOS';
log.errorAndThrow(msg);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/real-device-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ async function getConnectedDevices () {
}

async function resetRealDevice (device, opts) {
if (!opts.bundleId || !opts.fullReset) return;
if (!opts.bundleId || !opts.fullReset) {
return;
}

let bundleId = opts.bundleId;
log.debug(`Reset: fullReset requested. Will try to uninstall the app '${bundleId}'.`);
Expand Down
16 changes: 12 additions & 4 deletions lib/simulator-management.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ async function prepareSafariForCleanup (timeout = 5000) {
try {
await exec('pgrep', ['-x', 'MobileSafari']);
} catch (e) {
if (e.code === 1) return true;
if (e.code === 1) {
return true;
}
try {
await exec('pkill', ['-9', '-x', 'MobileSafari']);
} catch (e1) {
if (e1.code === 1) return true;
if (e1.code === 1) {
return true;
}
log.warn(e1.message);
}
}
Expand Down Expand Up @@ -106,13 +110,17 @@ async function runSimulatorReset (device, opts) {
}

async function fullResetSimulator (device) {
if (!device) return;
if (!device) {
return;
}

await device.clean();
}

async function endSimulator (device) {
if (!device) return;
if (!device) {
return;
}

log.debug('Reset: shutting down simulator');
await device.shutdown();
Expand Down
4 changes: 3 additions & 1 deletion lib/webdriveragent-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ async function checkForDependencies (bootstrapPath) {
// print out the stdout and stderr reports
for (let std of ['stdout', 'stderr']) {
for (let line of err[std].split('\n')) {
if (!line.length) continue;
if (!line.length) {
continue;
}
log.error(line);
}
}
Expand Down
8 changes: 6 additions & 2 deletions lib/webdriveragent.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,15 @@ class WebDriverAgent {
});
this.iproxy.on('output', (stdout, stderr) => {
// do nothing if we expect errors
if (this.expectIProxyErrors) return;
if (this.expectIProxyErrors) {
return;
}

let out = stdout || stderr;
for (let line of out.split('\n')) {
if (!line.length) continue;
if (!line.length) {
continue;
}

if (line.indexOf('Resource temporarily unavailable') !== -1) {
// this generally happens when WDA does not respond,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@
"devDependencies": {
"appium-gulp-plugins": "^1.2.12",
"appium-test-support": "0.0.5",
"babel-eslint": "^6.1.0",
"babel-eslint": "^7.1.1",
"chai": "^3.0.0",
"chai-as-promised": "^5.1.0",
"eslint": "^2.13.1",
"eslint-config-appium": "^0.1.0",
"eslint": "^3.18.0",
"eslint-config-appium": "^2.0.1",
"eslint-plugin-babel": "^3.3.0",
"eslint-plugin-import": "^1.9.2",
"eslint-plugin-mocha": "^3.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-mocha": "^4.7.0",
"eslint-plugin-promise": "^3.3.1",
"glob": "^7.1.0",
"gulp": "^3.8.11",
Expand Down
4 changes: 3 additions & 1 deletion test/functional/basic/basic-e2e-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ describe('XCUITestDriver - basics', function () {

describe('contexts', () => {
before(async function () {
if (process.env.TRAVIS) return this.skip();
if (process.env.TRAVIS) {
return this.skip();
}
let el = await driver.elementByAccessibilityId('Web View');
await driver.execute('mobile: scroll', {element: el, toVisible: true});
await el.click();
Expand Down
8 changes: 6 additions & 2 deletions test/functional/web/safari-alerts-e2e-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ describe('safari - alerts', function () {
let driver;
before(async function () {
// TODO: why does this not work for 9.3? Argh.
if (PLATFORM_VERSION === '9.3') this.skip();
if (PLATFORM_VERSION === '9.3') {
return this.skip();
}
// TODO: why does this fail on Travis? popup happens but button is "send"
if (process.env.TRAVIS) this.skip();
if (process.env.TRAVIS) {
return this.skip();
}

let caps = _.defaults({
safariInitialUrl: GUINEA_PIG_PAGE,
Expand Down