Skip to content

Commit 5ff2c6c

Browse files
authored
chore: updated eslint with applied fix (#744)
* chore: eslint update w/ automated applied fixes * chore: eslint manual applied fixes * chore: applied lint to bin Co-Authored-By: Raphael von der Grün <raphinesse@gmail.com> * Update package.json * Update .eslintrc.yml
1 parent 076edd0 commit 5ff2c6c

30 files changed

+191
-237
lines changed

.eslintrc.yml

+25-9
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
118
root: true
2-
extends: semistandard
3-
rules:
4-
indent:
5-
- error
6-
- 4
7-
camelcase: off
8-
padded-blocks: off
9-
operator-linebreak: off
10-
no-throw-literal: off
19+
extends: '@cordova/eslint-config/node'
20+
21+
overrides:
22+
- files: [tests/spec/**/*.js]
23+
extends: '@cordova/eslint-config/node-tests'
24+
25+
- files: [cordova-js-src/**/*.js]
26+
extends: '@cordova/eslint-config/browser'

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ install:
2222
script:
2323
- node --version
2424
- npm --version
25-
- npm run eslint
25+
- npm run lint
2626
- npm run unit-tests
2727
- npm run test:component
2828
- npm run e2e-tests

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ build: off
1212
test_script:
1313
- node --version
1414
- npm --version
15+
- npm run lint
1516
- npm run unit-tests
16-
- npm run eslint

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/lib/create.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function copyScripts (projectPath, projectName) {
7575
var binDir = path.join(ROOT, 'bin');
7676
shell.cp('-r', srcScriptsDir, projectPath);
7777

78-
let nodeModulesDir = path.join(ROOT, 'node_modules');
78+
const nodeModulesDir = path.join(ROOT, 'node_modules');
7979
if (fs.existsSync(nodeModulesDir)) shell.cp('-r', nodeModulesDir, destScriptsDir);
8080

8181
// Copy the check_reqs script

bin/templates/scripts/cordova/Api.js

-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ function Api (platform, platformRootDir, events) {
6666
var xcodeCordovaProj;
6767

6868
try {
69-
7069
var xcodeProjDir_array = fs.readdirSync(this.root).filter(function (e) { return e.match(/\.xcodeproj$/i); });
7170
if (xcodeProjDir_array.length > 1) {
7271
for (var x = 0; x < xcodeProjDir_array.length; x++) {
@@ -230,7 +229,6 @@ Api.prototype.prepare = function (cordovaProject) {
230229
* CordovaError instance.
231230
*/
232231
Api.prototype.addPlugin = function (plugin, installOptions) {
233-
234232
var xcodeproj = projectFile.parse(this.locations);
235233
var self = this;
236234

@@ -401,7 +399,6 @@ Api.prototype.addPodSpecs = function (plugin, podSpecs, frameworkPods) {
401399
podfileFile.addSpec(podJson.name, podJson);
402400
}
403401
});
404-
405402
});
406403
}
407404

@@ -525,7 +522,6 @@ Api.prototype.removePodSpecs = function (plugin, podSpecs, frameworkPods) {
525522
podfileFile.removeSpec(podJson.name);
526523
}
527524
});
528-
529525
});
530526
}
531527

bin/templates/scripts/cordova/build

+17-17
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,23 @@ if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >=
3131

3232
// Parse arguments
3333
var buildOpts = nopt({
34-
'verbose': Boolean,
35-
'silent': Boolean,
36-
'archs': String,
37-
'debug': Boolean,
38-
'release': Boolean,
39-
'device': Boolean,
40-
'emulator': Boolean,
41-
'codeSignIdentity': String,
42-
'codeSignResourceRules': String,
43-
'provisioningProfile': String,
44-
'automaticProvisioning': Boolean,
45-
'developmentTeam': String,
46-
'packageType': String,
47-
'buildConfig': String,
48-
'buildFlag': [String, Array],
49-
'noSign': Boolean
50-
}, { '-r': '--release', 'd': '--verbose' }, args);
34+
verbose: Boolean,
35+
silent: Boolean,
36+
archs: String,
37+
debug: Boolean,
38+
release: Boolean,
39+
device: Boolean,
40+
emulator: Boolean,
41+
codeSignIdentity: String,
42+
codeSignResourceRules: String,
43+
provisioningProfile: String,
44+
automaticProvisioning: Boolean,
45+
developmentTeam: String,
46+
packageType: String,
47+
buildConfig: String,
48+
buildFlag: [String, Array],
49+
noSign: Boolean
50+
}, { '-r': '--release', d: '--verbose' }, args);
5151

5252
// Make buildOptions compatible with PlatformApi build method spec
5353
buildOpts.argv = buildOpts.argv.remain;

bin/templates/scripts/cordova/clean

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >=
2929

3030
// Do some basic argument parsing
3131
var opts = nopt({
32-
'verbose': Boolean,
33-
'silent': Boolean
34-
}, { 'd': '--verbose' });
32+
verbose: Boolean,
33+
silent: Boolean
34+
}, { d: '--verbose' });
3535

3636
// Make buildOptions compatible with PlatformApi clean method spec
3737
opts.argv = opts.argv.original;

bin/templates/scripts/cordova/lib/build.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ var events = require('cordova-common').events;
3333
// These are regular expressions to detect if the user is changing any of the built-in xcodebuildArgs
3434
/* eslint-disable no-useless-escape */
3535
var buildFlagMatchers = {
36-
'workspace': /^\-workspace\s*(.*)/,
37-
'scheme': /^\-scheme\s*(.*)/,
38-
'configuration': /^\-configuration\s*(.*)/,
39-
'sdk': /^\-sdk\s*(.*)/,
40-
'destination': /^\-destination\s*(.*)/,
41-
'archivePath': /^\-archivePath\s*(.*)/,
42-
'configuration_build_dir': /^(CONFIGURATION_BUILD_DIR=.*)/,
43-
'shared_precomps_dir': /^(SHARED_PRECOMPS_DIR=.*)/
36+
workspace: /^\-workspace\s*(.*)/,
37+
scheme: /^\-scheme\s*(.*)/,
38+
configuration: /^\-configuration\s*(.*)/,
39+
sdk: /^\-sdk\s*(.*)/,
40+
destination: /^\-destination\s*(.*)/,
41+
archivePath: /^\-archivePath\s*(.*)/,
42+
configuration_build_dir: /^(CONFIGURATION_BUILD_DIR=.*)/,
43+
shared_precomps_dir: /^(SHARED_PRECOMPS_DIR=.*)/
4444
};
4545
/* eslint-enable no-useless-escape */
4646

@@ -227,15 +227,14 @@ module.exports.run = function (buildOpts) {
227227

228228
var xcodebuildArgs = getXcodeBuildArgs(projectName, projectPath, configuration, buildOpts.device, buildOpts.buildFlag, emulatorTarget, buildOpts.automaticProvisioning);
229229
return superspawn.spawn('xcodebuild', xcodebuildArgs, { cwd: projectPath, printCommand: true, stdio: 'inherit' });
230-
231230
}).then(function () {
232231
if (!buildOpts.device || buildOpts.noSign) {
233232
return;
234233
}
235234

236235
var project = createProjectObject(projectPath, projectName);
237236
var bundleIdentifier = getBundleIdentifier(project);
238-
var exportOptions = { 'compileBitcode': false, 'method': 'development' };
237+
var exportOptions = { compileBitcode: false, method: 'development' };
239238

240239
if (buildOpts.packageType) {
241240
exportOptions.method = buildOpts.packageType;
@@ -250,7 +249,7 @@ module.exports.run = function (buildOpts) {
250249
}
251250

252251
if (buildOpts.provisioningProfile && bundleIdentifier) {
253-
exportOptions.provisioningProfiles = { [ bundleIdentifier ]: String(buildOpts.provisioningProfile) };
252+
exportOptions.provisioningProfiles = { [bundleIdentifier]: String(buildOpts.provisioningProfile) };
254253
exportOptions.signingStyle = 'manual';
255254
}
256255

@@ -346,7 +345,7 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, b
346345
'-destination', customArgs.destination || 'generic/platform=iOS',
347346
'-archivePath', customArgs.archivePath || projectName + '.xcarchive'
348347
];
349-
buildActions = [ 'archive' ];
348+
buildActions = ['archive'];
350349
settings = [
351350
customArgs.configuration_build_dir || 'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'device'),
352351
customArgs.shared_precomps_dir || 'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')
@@ -368,7 +367,7 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, b
368367
'-sdk', customArgs.sdk || 'iphonesimulator',
369368
'-destination', customArgs.destination || 'platform=iOS Simulator,name=' + emulatorTarget
370369
];
371-
buildActions = [ 'build' ];
370+
buildActions = ['build'];
372371
settings = [
373372
customArgs.configuration_build_dir || 'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'emulator'),
374373
customArgs.shared_precomps_dir || 'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')

bin/templates/scripts/cordova/lib/check_reqs.js

+19-20
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const shell = require('shelljs');
2424
const util = require('util');
2525
const versions = require('./versions');
2626

27-
const SUPPORTED_OS_PLATFORMS = [ 'darwin' ];
27+
const SUPPORTED_OS_PLATFORMS = ['darwin'];
2828

2929
const XCODEBUILD_MIN_VERSION = '9.0.0';
3030
const XCODEBUILD_NOT_FOUND_MESSAGE =
@@ -63,9 +63,9 @@ module.exports.check_ios_deploy = function () {
6363

6464
module.exports.check_os = function () {
6565
// Build iOS apps available for OSX platform only, so we reject on others platforms
66-
return os_platform_is_supported() ?
67-
Q.resolve(process.platform) :
68-
Q.reject('Cordova tooling for iOS requires Apple macOS');
66+
return os_platform_is_supported()
67+
? Q.resolve(process.platform)
68+
: Q.reject('Cordova tooling for iOS requires Apple macOS');
6969
};
7070

7171
function os_platform_is_supported () {
@@ -78,8 +78,8 @@ function check_cocoapod_tool (toolChecker) {
7878
return toolChecker('pod', COCOAPODS_MIN_VERSION, COCOAPODS_NOT_FOUND_MESSAGE, 'CocoaPods');
7979
} else {
8080
return Q.resolve({
81-
'ignore': true,
82-
'ignoreMessage': `CocoaPods check and installation ignored on ${process.platform}`
81+
ignore: true,
82+
ignoreMessage: `CocoaPods check and installation ignored on ${process.platform}`
8383
});
8484
}
8585
}
@@ -92,10 +92,10 @@ module.exports.check_cocoapods_repo_size = function () {
9292
return check_cocoapod_tool()
9393
.then(function (toolOptions) {
9494
// check size of ~/.cocoapods repo
95-
let commandString = util.format('du -sh %s/.cocoapods', process.env.HOME);
96-
let command = shell.exec(commandString, { silent: true });
95+
const commandString = util.format('du -sh %s/.cocoapods', process.env.HOME);
96+
const command = shell.exec(commandString, { silent: true });
9797
// command.output is e.g "750M path/to/.cocoapods", we just scan the number
98-
let size = toolOptions.ignore ? 0 : parseFloat(command.output);
98+
const size = toolOptions.ignore ? 0 : parseFloat(command.output);
9999

100100
if (toolOptions.ignore || command.code === 0) { // success, parse output
101101
return Q.resolve(size, toolOptions);
@@ -128,8 +128,8 @@ module.exports.check_cocoapods = function (toolChecker) {
128128
return toolOptions;
129129
}
130130

131-
let code = shell.exec('pod repo | grep -e "^0 repos"', { silent: true }).code;
132-
let repoIsSynced = (code !== 0);
131+
const code = shell.exec('pod repo | grep -e "^0 repos"', { silent: true }).code;
132+
const repoIsSynced = (code !== 0);
133133

134134
if (repoIsSynced) {
135135
// return check_cocoapods_repo_size();
@@ -153,17 +153,17 @@ function checkTool (tool, minVersion, message, toolFriendlyName) {
153153
toolFriendlyName = toolFriendlyName || tool;
154154

155155
// Check whether tool command is available at all
156-
let tool_command = shell.which(tool);
156+
const tool_command = shell.which(tool);
157157
if (!tool_command) {
158158
return Q.reject(toolFriendlyName + ' was not found. ' + (message || ''));
159159
}
160160

161161
// check if tool version is greater than specified one
162162
return versions.get_tool_version(tool).then(function (version) {
163163
version = version.trim();
164-
return versions.compareVersions(version, minVersion) >= 0 ?
165-
Q.resolve({ 'version': version }) :
166-
Q.reject('Cordova needs ' + toolFriendlyName + ' version ' + minVersion +
164+
return versions.compareVersions(version, minVersion) >= 0
165+
? Q.resolve({ version: version })
166+
: Q.reject('Cordova needs ' + toolFriendlyName + ' version ' + minVersion +
167167
' or greater, you have version ' + version + '. ' + (message || ''));
168168
});
169169
}
@@ -175,7 +175,7 @@ function checkTool (tool, minVersion, message, toolFriendlyName) {
175175
* @param {Boolean} isFatal Marks the requirement as fatal. If such requirement will fail
176176
* next requirements' checks will be skipped.
177177
*/
178-
let Requirement = function (id, name, isFatal) {
178+
const Requirement = function (id, name, isFatal) {
179179
this.id = id;
180180
this.name = name;
181181
this.installed = false;
@@ -190,18 +190,17 @@ let Requirement = function (id, name, isFatal) {
190190
* @return Promise<Requirement[]> Array of requirements. Due to implementation, promise is always fulfilled.
191191
*/
192192
module.exports.check_all = function () {
193-
194193
const requirements = [
195194
new Requirement('os', 'Apple macOS', true),
196195
new Requirement('xcode', 'Xcode'),
197196
new Requirement('ios-deploy', 'ios-deploy'),
198197
new Requirement('CocoaPods', 'CocoaPods')
199198
];
200199

201-
let result = [];
200+
const result = [];
202201
let fatalIsHit = false;
203202

204-
let checkFns = [
203+
const checkFns = [
205204
module.exports.check_os,
206205
module.exports.check_xcodebuild,
207206
module.exports.check_ios_deploy,
@@ -215,7 +214,7 @@ module.exports.check_all = function () {
215214
// we don't need to check others
216215
if (fatalIsHit) return Q();
217216

218-
let requirement = requirements[idx];
217+
const requirement = requirements[idx];
219218
return checkFn()
220219
.then(function (version) {
221220
requirement.installed = true;

bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var handlers = {
8080
shell.rm('-rf', destFile);
8181
}
8282
},
83-
'framework': { // CB-5238 custom frameworks only
83+
framework: { // CB-5238 custom frameworks only
8484
install: function (obj, plugin, project, options) {
8585
var src = obj.src;
8686
var custom = !!(obj.custom); // convert to boolean (if truthy/falsy)
@@ -96,7 +96,7 @@ var handlers = {
9696
} else {
9797
project.frameworks[src] = project.frameworks[src] || 0;
9898
project.frameworks[src]++;
99-
let opt = { customFramework: false, embed: false, link: true, weak: obj.weak };
99+
const opt = { customFramework: false, embed: false, link: true, weak: obj.weak };
100100
events.emit('verbose', util.format('Adding non-custom framework to project... %s -> %s', src, JSON.stringify(opt)));
101101
project.xcode.addFramework(src, opt);
102102
events.emit('verbose', util.format('Non-custom framework added to project. %s -> %s', src, JSON.stringify(opt)));
@@ -118,7 +118,7 @@ var handlers = {
118118
events.emit('verbose', '"Embed Frameworks" Build Phase (Embedded Binaries) does not exist, creating it.');
119119
project.xcode.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Embed Frameworks', null, 'frameworks');
120120
}
121-
let opt = { customFramework: true, embed: embed, link: link, sign: true };
121+
const opt = { customFramework: true, embed: embed, link: link, sign: true };
122122
events.emit('verbose', util.format('Adding custom framework to project... %s -> %s', src, JSON.stringify(opt)));
123123
project.xcode.addFramework(project_relative, opt);
124124
events.emit('verbose', util.format('Custom framework added to project. %s -> %s', src, JSON.stringify(opt)));
@@ -160,7 +160,7 @@ var handlers = {
160160
events.emit('verbose', '<lib-file> uninstall is not supported for iOS plugins');
161161
}
162162
},
163-
'asset': {
163+
asset: {
164164
install: function (obj, plugin, project, options) {
165165
if (!obj.src) {
166166
throw new CordovaError(generateAttributeError('src', 'asset', plugin.id));

0 commit comments

Comments
 (0)