Skip to content

Commit 2d3fb87

Browse files
authored
Lint everything (#710)
* Use JS comment for license in bin/autotest * Lint everything, including bins w/out extension * Apply eslint --fix to all linted files * Manually fix all remaining lint rule violations
1 parent 61a172c commit 2d3fb87

21 files changed

+329
-336
lines changed

.eslintignore

+6
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ bin/node_modules/*
22
bin/templates/project/*
33
tests/spec/unit/fixtures/*
44
CordovaLib/cordova.js
5+
6+
# Non-JS binaries
7+
bin/test
8+
bin/cordova_plist_to_config_xml
9+
bin/templates/scripts/cordova/log
10+
bin/templates/scripts/cordova/lib/start-emulator

bin/apple_ios_version

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
var versions = require('./templates/scripts/cordova/lib/versions.js');
2323

24-
versions.get_apple_ios_version().done(null, function(err) {
24+
versions.get_apple_ios_version().done(null, function (err) {
2525
console.log(err);
2626
process.exit(2);
2727
});

bin/apple_osx_version

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
var versions = require('./templates/scripts/cordova/lib/versions.js');
2323

24-
versions.get_apple_osx_version().done(null, function(err) {
24+
versions.get_apple_osx_version().done(null, function (err) {
2525
console.log(err);
2626
process.exit(2);
2727
});

bin/apple_xcode_version

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var versions = require('./templates/scripts/cordova/lib/versions.js');
2323

2424
versions.get_apple_xcode_version().done(function (version) {
2525
console.log(version);
26-
}, function(err) {
26+
}, function (err) {
2727
console.error(err);
2828
process.exit(2);
2929
});

bin/autotest

+19-21
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
#! /usr/bin/env node
22

3-
#
4-
# Licensed to the Apache Software Foundation (ASF) under one
5-
# or more contributor license agreements. See the NOTICE file
6-
# distributed with this work for additional information
7-
# regarding copyright ownership. The ASF licenses this file
8-
# to you under the Apache License, Version 2.0 (the
9-
# "License"); you may not use this file except in compliance
10-
# with the License. You may obtain a copy of the License at
11-
#
12-
# http://www.apache.org/licenses/LICENSE-2.0
13-
#
14-
# Unless required by applicable law or agreed to in writing,
15-
# software distributed under the License is distributed on an
16-
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17-
# KIND, either express or implied. See the License for the
18-
# specific language governing permissions and limitations
19-
# under the License.
20-
#
3+
/*!
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
2121

22-
23-
24-
require('nodeunit').reporters.default.run(['bin/tests'])
22+
require('nodeunit').reporters.default.run(['bin/tests']);

bin/check_reqs

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ var check_reqs = require('./templates/scripts/cordova/lib/check_reqs');
2525
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) > -1) {
2626
console.log('Usage: check_reqs or node check_reqs');
2727
} else {
28-
check_reqs.run().done(null, function (err) {
29-
console.error('Failed to check requirements due to ' + err);
30-
process.exit(2);
31-
});
28+
check_reqs.run().done(null, function (err) {
29+
console.error('Failed to check requirements due to ' + err);
30+
process.exit(2);
31+
});
3232
}

bin/create

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ var ConfigParser = require('cordova-common').ConfigParser;
3434
var Api = require('./templates/scripts/cordova/Api');
3535

3636
var argv = require('nopt')({
37-
'help' : Boolean,
38-
'cli' : Boolean,
39-
'shared' : Boolean, // alias for --link
40-
'link' : Boolean
41-
}, { 'd' : '--verbose' });
37+
'help': Boolean,
38+
'cli': Boolean,
39+
'shared': Boolean, // alias for --link
40+
'link': Boolean
41+
}, { 'd': '--verbose' });
4242

4343
var projectPath = argv.argv.remain[0];
4444

bin/templates/scripts/cordova/build

+15-16
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,20 @@
1919
under the License.
2020
*/
2121

22-
var args = process.argv;
22+
var args = process.argv;
2323
var Api = require('./Api');
2424
var nopt = require('nopt');
25-
var path = require('path');
2625

2726
// Support basic help commands
28-
if(['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
27+
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
2928
require('./lib/build').help();
3029
process.exit(0);
3130
}
3231

3332
// Parse arguments
3433
var buildOpts = nopt({
35-
'verbose' : Boolean,
36-
'silent' : Boolean,
34+
'verbose': Boolean,
35+
'silent': Boolean,
3736
'archs': String,
3837
'debug': Boolean,
3938
'release': Boolean,
@@ -45,20 +44,20 @@ var buildOpts = nopt({
4544
'automaticProvisioning': Boolean,
4645
'developmentTeam': String,
4746
'packageType': String,
48-
'buildConfig' : String,
49-
'buildFlag' : [String, Array],
50-
'noSign' : Boolean
51-
}, { '-r': '--release', 'd' : '--verbose' }, args);
47+
'buildConfig': String,
48+
'buildFlag': [String, Array],
49+
'noSign': Boolean
50+
}, { '-r': '--release', 'd': '--verbose' }, args);
5251

5352
// Make buildOptions compatible with PlatformApi build method spec
5453
buildOpts.argv = buildOpts.argv.remain;
5554

5655
require('./loggingHelper').adjustLoggerLevel(buildOpts);
5756

58-
new Api().build(buildOpts).done(function() {
59-
console.log('** BUILD SUCCEEDED **');
60-
}, function(err) {
61-
var errorMessage = (err && err.stack) ? err.stack : err;
62-
console.error(errorMessage);
63-
process.exit(2);
64-
});
57+
new Api().build(buildOpts).done(function () {
58+
console.log('** BUILD SUCCEEDED **');
59+
}, function (err) {
60+
var errorMessage = (err && err.stack) ? err.stack : err;
61+
console.error(errorMessage);
62+
process.exit(2);
63+
});

bin/templates/scripts/cordova/clean

+6-7
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,18 @@
2020
*/
2121

2222
var Api = require('./Api');
23-
var path = require('path');
2423
var nopt = require('nopt');
2524

26-
if(['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
25+
if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >= 0) {
2726
console.log('Cleans the project directory.');
2827
process.exit(0);
2928
}
3029

3130
// Do some basic argument parsing
3231
var opts = nopt({
33-
'verbose' : Boolean,
34-
'silent' : Boolean
35-
}, { 'd' : '--verbose' });
32+
'verbose': Boolean,
33+
'silent': Boolean
34+
}, { 'd': '--verbose' });
3635

3736
// Make buildOptions compatible with PlatformApi clean method spec
3837
opts.argv = opts.argv.original;
@@ -42,9 +41,9 @@ opts.noPrepare = true;
4241

4342
require('./loggingHelper').adjustLoggerLevel(opts);
4443

45-
new Api().clean(opts).done(function() {
44+
new Api().clean(opts).done(function () {
4645
console.log('** CLEAN SUCCEEDED **');
47-
}, function(err) {
46+
}, function (err) {
4847
console.error(err);
4948
process.exit(2);
5049
});

bin/templates/scripts/cordova/lib/list-devices

+16-17
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,35 @@
1919
under the License.
2020
*/
2121

22-
23-
var Q = require('q'),
24-
exec = require('child_process').exec;
22+
var Q = require('q');
23+
var exec = require('child_process').exec;
2524

2625
/**
2726
* Gets list of connected iOS devices
2827
* @return {Promise} Promise fulfilled with list of available iOS devices
2928
*/
30-
function listDevices() {
29+
function listDevices () {
3130
var commands = [
3231
Q.nfcall(exec, "ioreg -p IOUSB -l | sed -n -e '/iPad/,/USB Serial Number/p' | grep 'Serial Number' | awk -F\\\" '{print $4 \" iPad\"}'"),
3332
Q.nfcall(exec, "ioreg -p IOUSB -l | sed -n -e '/iPhone/,/USB Serial Number/p' | grep 'Serial Number' | awk -F\\\" '{print $4 \" iPhone\"}'"),
34-
Q.nfcall(exec, "ioreg -p IOUSB -l | sed -n -e '/iPod/,/USB Serial Number/p' | grep 'Serial Number' | awk -F\\\" '{print $4 \" iPod\"}'"),
33+
Q.nfcall(exec, "ioreg -p IOUSB -l | sed -n -e '/iPod/,/USB Serial Number/p' | grep 'Serial Number' | awk -F\\\" '{print $4 \" iPod\"}'")
3534
];
3635

3736
// wrap al lexec calls into promises and wait until they're fullfilled
3837
return Q.all(commands).then(function (results) {
3938
var accumulator = [];
4039
results.forEach(function (result) {
41-
var devicefound;
42-
// Each command promise resolves with array [stout, stderr], and we need stdout only
43-
// Append stdout lines to accumulator
44-
devicefound = result[0].trim().split('\n');
45-
if(devicefound && devicefound.length) {
46-
devicefound.forEach(function(device) {
47-
if (device) {
48-
accumulator.push(device);
49-
}
50-
});
51-
}
40+
var devicefound;
41+
// Each command promise resolves with array [stout, stderr], and we need stdout only
42+
// Append stdout lines to accumulator
43+
devicefound = result[0].trim().split('\n');
44+
if (devicefound && devicefound.length) {
45+
devicefound.forEach(function (device) {
46+
if (device) {
47+
accumulator.push(device);
48+
}
49+
});
50+
}
5251
});
5352
return accumulator;
5453
});
@@ -64,4 +63,4 @@ if (!module.parent) {
6463
console.log(device);
6564
});
6665
});
67-
}
66+
}

0 commit comments

Comments
 (0)