Skip to content

Commit

Permalink
Update linting (appium#9123)
Browse files Browse the repository at this point in the history
* Update linting

* Move minimum node version to 5

* Remove coverage for now

* Fix docs for node version

* Fail for node 4 and below
  • Loading branch information
imurchie authored Aug 31, 2017
1 parent bf3eeb5 commit 94635ed
Show file tree
Hide file tree
Showing 17 changed files with 1,520 additions and 1,581 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
sample-code
coverage
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ build/
__pycache__
old
.tern-project
coverage
11 changes: 0 additions & 11 deletions .jscsrc

This file was deleted.

5 changes: 0 additions & 5 deletions .jshintignore

This file was deleted.

11 changes: 0 additions & 11 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ _vimrc_local.vim
*.trace
*.sublime-
*.prefs
.jshintrc
./.npmignore
coverage
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ sudo: false
node_js:
- "7"
- "6"
- "4"
env:
- CXX=g++-4.8
addons:
Expand All @@ -13,7 +12,4 @@ addons:
packages:
- g++-4.8
script:
- npm run lint
- npm run test
after_success:
- gulp coveralls
18 changes: 9 additions & 9 deletions bin/ios-webkit-debug-proxy-launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,25 @@

"use strict";

var spawn = require('child_process').spawn,
_ = require('lodash');
const spawn = require('child_process').spawn;
const _ = require('lodash');

var args = process.argv.slice(2);
const args = process.argv.slice(2);

var RESTART_ON_MESSAGES = [
const RESTART_ON_MESSAGES = [
'Invalid message _rpc_applicationUpdated',
'Invalid message _rpc_applicationSentListing'];

var PROXY_CMD = 'ios_webkit_debug_proxy';
var proxy;
const PROXY_CMD = 'ios_webkit_debug_proxy';
let proxy;

var handleKillProcess = function (exitCode) {
const handleKillProcess = function (exitCode) {
console.log('\nKilling proxy process!');
proxy.kill('SIGTERM');
process.exit((exitCode || 0));
};

var startProxy = function () {
const startProxy = function () {
console.log('RUNNING:', PROXY_CMD, args.join(' '));

proxy = spawn(PROXY_CMD, args);
Expand All @@ -49,7 +49,7 @@ var startProxy = function () {

proxy.stderr.on('data', function (data) {
console.log('stderr: ' + data);
var restartMessage = _(RESTART_ON_MESSAGES).find(function (message) {
const restartMessage = _(RESTART_ON_MESSAGES).find(function (message) {
return ('' + data).indexOf(message) >= 0;
});
if (restartMessage) {
Expand Down
4 changes: 2 additions & 2 deletions docs/en/contributing-to-appium/appium-packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## appium
- runs basic checks
- node version (>= 4)
- node version (>= 5)
- CLI arguments checks
- contains all available and supported CLI arguments
- check for deprecation and mutual exclusion
Expand Down Expand Up @@ -228,7 +228,7 @@
- contains task for
- e2e and unit tests (with coverage reporting)
- transpiling ES2016 into ES5
- static code analysis (jshint)
- static code analysis (eslint)
- watch task for dev

## appium-remote-debugger
Expand Down
30 changes: 14 additions & 16 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
// getting sent to the handler
process.env._FORCE_LOGS="1";

var gulp = require('gulp'),
boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp),
path = require('path'),
fs = require('fs');
const gulp = require('gulp');
const boilerplate = require('appium-gulp-plugins').boilerplate.use(gulp);
const path = require('path');
const fs = require('fs');

// remove 'fsevents' from shrinkwrap, since it causes errors on non-Mac hosts
// see https://github.com/npm/npm/issues/2679
gulp.task('fixShrinkwrap', function (done) {
var shrinkwrap;
let shrinkwrap;
try {
shrinkwrap = require('./npm-shrinkwrap.json');
} catch (err) {
Expand All @@ -23,7 +23,7 @@ gulp.task('fixShrinkwrap', function (done) {
return;
}
delete shrinkwrap.dependencies.fsevents;
var shrinkwrapString = JSON.stringify(shrinkwrap, null, ' ') + '\n';
const shrinkwrapString = JSON.stringify(shrinkwrap, null, ' ') + '\n';
fs.writeFile('./npm-shrinkwrap.json', shrinkwrapString, done);
});

Expand All @@ -32,8 +32,6 @@ gulp.task('fixShrinkwrap', function (done) {

boilerplate({
build: 'appium',
jscs: false,
jshint: false,
test: {
files: ['${testDir}/**/*-specs.js']
},
Expand All @@ -43,10 +41,10 @@ boilerplate({

// generates server arguments readme
gulp.task('docs', ['transpile'], function () {
var parser = require('./build/lib/parser.js');
var appiumArguments = parser.getParser().rawArgs;
var docFile = path.resolve(__dirname, "docs/en/writing-running-appium/server-args.md");
var md = "# Appium server arguments\n\n";
const parser = require('./build/lib/parser.js');
const appiumArguments = parser.getParser().rawArgs;
const docFile = path.resolve(__dirname, "docs/en/writing-running-appium/server-args.md");
let md = "# Appium server arguments\n\n";
md += "Many Appium 1.5 server arguments have been deprecated in favor of the ";
md += "[--default-capabilities flag](/docs/en/writing-running-appium/default-capabilities-arg.md).";
md += "\n\nUsage: `node . [flags]`\n\n";
Expand All @@ -57,14 +55,14 @@ gulp.task('docs', ['transpile'], function () {
md += "|Flag|Default|Description|Example|\n";
md += "|----|-------|-----------|-------|\n";
appiumArguments.forEach(function (arg) {
var argNames = arg[0];
var exampleArg = typeof arg[0][1] === "undefined" ? arg[0][0] : arg[0][1];
var argOpts = arg[1];
const argNames = arg[0];
const exampleArg = typeof arg[0][1] === "undefined" ? arg[0][0] : arg[0][1];
const argOpts = arg[1];

// --keystore-path defaultValue contains a user-specific path,
// let's replace it with <user>/...
if (arg[0][0] === '--keystore-path') {
var userPath = process.env.HOME || process.env.USERPROFILE;
const userPath = process.env.HOME || process.env.USERPROFILE;
argOpts.defaultValue = argOpts.defaultValue.replace(userPath, '&lt;user&gt;');
}

Expand Down
6 changes: 3 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ async function getAppiumConfig () {

function checkNodeOk () {
let [major, minor] = getNodeVersion();
if (major < 4) {
let msg = `Node version must be >= 4. Currently ${major}.${minor}`;
if (major < 5) {
let msg = `Node version must be >= 5. Currently ${major}.${minor}`;
logger.errorAndThrow(msg);
}
}
Expand Down Expand Up @@ -85,7 +85,7 @@ function getDeprecatedArgs (parser, args) {
}

function checkValidPort (port, portName) {
if (port > 0 && port < 65536) return true;
if (port > 0 && port < 65536) return true; // eslint-disable-line curly
logger.error(`Port '${portName}' must be greater than 0 and less than 65536. Currently ${port}`);
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/grid-register.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async function postRequest (data, addr, port) {
// Move Selenium 3 configuration properties to configuration object
if (!jsonObject.hasOwnProperty('configuration')) {
let configuration = {};
for (var property in jsonObject) {
for (let property in jsonObject) {
if (jsonObject.hasOwnProperty(property) && property !== 'capabilities') {
configuration[property] = jsonObject[property];
delete jsonObject[property];
Expand Down
Loading

0 comments on commit 94635ed

Please sign in to comment.