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

chore: updated eslint with applied fix #744

Merged
merged 5 commits into from
Dec 17, 2019
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
34 changes: 25 additions & 9 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

root: true
extends: semistandard
rules:
indent:
- error
- 4
camelcase: off
padded-blocks: off
operator-linebreak: off
no-throw-literal: off
extends: '@cordova/eslint-config/node'

overrides:
- files: [tests/spec/**/*.js]
extends: '@cordova/eslint-config/node-tests'

- files: [cordova-js-src/**/*.js]
extends: '@cordova/eslint-config/browser'
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ install:
script:
- node --version
- npm --version
- npm run eslint
- npm run lint
- npm run unit-tests
- npm run test:component
- npm run e2e-tests
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ build: off
test_script:
- node --version
- npm --version
- npm run lint
- npm run unit-tests
- npm run eslint
10 changes: 5 additions & 5 deletions bin/create
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ var ConfigParser = require('cordova-common').ConfigParser;
var Api = require('./templates/scripts/cordova/Api');

var argv = require('nopt')({
'help': Boolean,
'cli': Boolean,
'shared': Boolean, // alias for --link
'link': Boolean
}, { 'd': '--verbose' });
help: Boolean,
cli: Boolean,
shared: Boolean, // alias for --link
link: Boolean
}, { d: '--verbose' });

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

Expand Down
2 changes: 1 addition & 1 deletion bin/lib/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function copyScripts (projectPath, projectName) {
var binDir = path.join(ROOT, 'bin');
shell.cp('-r', srcScriptsDir, projectPath);

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

// Copy the check_reqs script
Expand Down
4 changes: 0 additions & 4 deletions bin/templates/scripts/cordova/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function Api (platform, platformRootDir, events) {
var xcodeCordovaProj;

try {

var xcodeProjDir_array = fs.readdirSync(this.root).filter(function (e) { return e.match(/\.xcodeproj$/i); });
if (xcodeProjDir_array.length > 1) {
for (var x = 0; x < xcodeProjDir_array.length; x++) {
Expand Down Expand Up @@ -230,7 +229,6 @@ Api.prototype.prepare = function (cordovaProject) {
* CordovaError instance.
*/
Api.prototype.addPlugin = function (plugin, installOptions) {

var xcodeproj = projectFile.parse(this.locations);
var self = this;

Expand Down Expand Up @@ -401,7 +399,6 @@ Api.prototype.addPodSpecs = function (plugin, podSpecs, frameworkPods) {
podfileFile.addSpec(podJson.name, podJson);
}
});

});
}

Expand Down Expand Up @@ -525,7 +522,6 @@ Api.prototype.removePodSpecs = function (plugin, podSpecs, frameworkPods) {
podfileFile.removeSpec(podJson.name);
}
});

});
}

Expand Down
34 changes: 17 additions & 17 deletions bin/templates/scripts/cordova/build
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >=

// Parse arguments
var buildOpts = nopt({
'verbose': Boolean,
'silent': Boolean,
'archs': String,
'debug': Boolean,
'release': Boolean,
'device': Boolean,
'emulator': Boolean,
'codeSignIdentity': String,
'codeSignResourceRules': String,
'provisioningProfile': String,
'automaticProvisioning': Boolean,
'developmentTeam': String,
'packageType': String,
'buildConfig': String,
'buildFlag': [String, Array],
'noSign': Boolean
}, { '-r': '--release', 'd': '--verbose' }, args);
verbose: Boolean,
silent: Boolean,
archs: String,
debug: Boolean,
release: Boolean,
device: Boolean,
emulator: Boolean,
codeSignIdentity: String,
codeSignResourceRules: String,
provisioningProfile: String,
automaticProvisioning: Boolean,
developmentTeam: String,
packageType: String,
buildConfig: String,
buildFlag: [String, Array],
noSign: Boolean
}, { '-r': '--release', d: '--verbose' }, args);

// Make buildOptions compatible with PlatformApi build method spec
buildOpts.argv = buildOpts.argv.remain;
Expand Down
6 changes: 3 additions & 3 deletions bin/templates/scripts/cordova/clean
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ if (['--help', '/?', '-h', 'help', '-help', '/help'].indexOf(process.argv[2]) >=

// Do some basic argument parsing
var opts = nopt({
'verbose': Boolean,
'silent': Boolean
}, { 'd': '--verbose' });
verbose: Boolean,
silent: Boolean
}, { d: '--verbose' });

// Make buildOptions compatible with PlatformApi clean method spec
opts.argv = opts.argv.original;
Expand Down
25 changes: 12 additions & 13 deletions bin/templates/scripts/cordova/lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ var events = require('cordova-common').events;
// These are regular expressions to detect if the user is changing any of the built-in xcodebuildArgs
/* eslint-disable no-useless-escape */
var buildFlagMatchers = {
'workspace': /^\-workspace\s*(.*)/,
'scheme': /^\-scheme\s*(.*)/,
'configuration': /^\-configuration\s*(.*)/,
'sdk': /^\-sdk\s*(.*)/,
'destination': /^\-destination\s*(.*)/,
'archivePath': /^\-archivePath\s*(.*)/,
'configuration_build_dir': /^(CONFIGURATION_BUILD_DIR=.*)/,
'shared_precomps_dir': /^(SHARED_PRECOMPS_DIR=.*)/
workspace: /^\-workspace\s*(.*)/,
scheme: /^\-scheme\s*(.*)/,
configuration: /^\-configuration\s*(.*)/,
sdk: /^\-sdk\s*(.*)/,
destination: /^\-destination\s*(.*)/,
archivePath: /^\-archivePath\s*(.*)/,
configuration_build_dir: /^(CONFIGURATION_BUILD_DIR=.*)/,
shared_precomps_dir: /^(SHARED_PRECOMPS_DIR=.*)/
};
/* eslint-enable no-useless-escape */

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

var xcodebuildArgs = getXcodeBuildArgs(projectName, projectPath, configuration, buildOpts.device, buildOpts.buildFlag, emulatorTarget, buildOpts.automaticProvisioning);
return superspawn.spawn('xcodebuild', xcodebuildArgs, { cwd: projectPath, printCommand: true, stdio: 'inherit' });

}).then(function () {
if (!buildOpts.device || buildOpts.noSign) {
return;
}

var project = createProjectObject(projectPath, projectName);
var bundleIdentifier = getBundleIdentifier(project);
var exportOptions = { 'compileBitcode': false, 'method': 'development' };
var exportOptions = { compileBitcode: false, method: 'development' };

if (buildOpts.packageType) {
exportOptions.method = buildOpts.packageType;
Expand All @@ -250,7 +249,7 @@ module.exports.run = function (buildOpts) {
}

if (buildOpts.provisioningProfile && bundleIdentifier) {
exportOptions.provisioningProfiles = { [ bundleIdentifier ]: String(buildOpts.provisioningProfile) };
exportOptions.provisioningProfiles = { [bundleIdentifier]: String(buildOpts.provisioningProfile) };
exportOptions.signingStyle = 'manual';
}

Expand Down Expand Up @@ -346,7 +345,7 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, b
'-destination', customArgs.destination || 'generic/platform=iOS',
'-archivePath', customArgs.archivePath || projectName + '.xcarchive'
];
buildActions = [ 'archive' ];
buildActions = ['archive'];
settings = [
customArgs.configuration_build_dir || 'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'device'),
customArgs.shared_precomps_dir || 'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')
Expand All @@ -368,7 +367,7 @@ function getXcodeBuildArgs (projectName, projectPath, configuration, isDevice, b
'-sdk', customArgs.sdk || 'iphonesimulator',
'-destination', customArgs.destination || 'platform=iOS Simulator,name=' + emulatorTarget
];
buildActions = [ 'build' ];
buildActions = ['build'];
settings = [
customArgs.configuration_build_dir || 'CONFIGURATION_BUILD_DIR=' + path.join(projectPath, 'build', 'emulator'),
customArgs.shared_precomps_dir || 'SHARED_PRECOMPS_DIR=' + path.join(projectPath, 'build', 'sharedpch')
Expand Down
39 changes: 19 additions & 20 deletions bin/templates/scripts/cordova/lib/check_reqs.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const shell = require('shelljs');
const util = require('util');
const versions = require('./versions');

const SUPPORTED_OS_PLATFORMS = [ 'darwin' ];
const SUPPORTED_OS_PLATFORMS = ['darwin'];

const XCODEBUILD_MIN_VERSION = '9.0.0';
const XCODEBUILD_NOT_FOUND_MESSAGE =
Expand Down Expand Up @@ -63,9 +63,9 @@ module.exports.check_ios_deploy = function () {

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

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

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

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

if (repoIsSynced) {
// return check_cocoapods_repo_size();
Expand All @@ -153,17 +153,17 @@ function checkTool (tool, minVersion, message, toolFriendlyName) {
toolFriendlyName = toolFriendlyName || tool;

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

// check if tool version is greater than specified one
return versions.get_tool_version(tool).then(function (version) {
version = version.trim();
return versions.compareVersions(version, minVersion) >= 0 ?
Q.resolve({ 'version': version }) :
Q.reject('Cordova needs ' + toolFriendlyName + ' version ' + minVersion +
return versions.compareVersions(version, minVersion) >= 0
? Q.resolve({ version: version })
: Q.reject('Cordova needs ' + toolFriendlyName + ' version ' + minVersion +
' or greater, you have version ' + version + '. ' + (message || ''));
});
}
Expand All @@ -175,7 +175,7 @@ function checkTool (tool, minVersion, message, toolFriendlyName) {
* @param {Boolean} isFatal Marks the requirement as fatal. If such requirement will fail
* next requirements' checks will be skipped.
*/
let Requirement = function (id, name, isFatal) {
const Requirement = function (id, name, isFatal) {
this.id = id;
this.name = name;
this.installed = false;
Expand All @@ -190,18 +190,17 @@ let Requirement = function (id, name, isFatal) {
* @return Promise<Requirement[]> Array of requirements. Due to implementation, promise is always fulfilled.
*/
module.exports.check_all = function () {

const requirements = [
new Requirement('os', 'Apple macOS', true),
new Requirement('xcode', 'Xcode'),
new Requirement('ios-deploy', 'ios-deploy'),
new Requirement('CocoaPods', 'CocoaPods')
];

let result = [];
const result = [];
let fatalIsHit = false;

let checkFns = [
const checkFns = [
module.exports.check_os,
module.exports.check_xcodebuild,
module.exports.check_ios_deploy,
Expand All @@ -215,7 +214,7 @@ module.exports.check_all = function () {
// we don't need to check others
if (fatalIsHit) return Q();

let requirement = requirements[idx];
const requirement = requirements[idx];
return checkFn()
.then(function (version) {
requirement.installed = true;
Expand Down
8 changes: 4 additions & 4 deletions bin/templates/scripts/cordova/lib/plugman/pluginHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var handlers = {
shell.rm('-rf', destFile);
}
},
'framework': { // CB-5238 custom frameworks only
framework: { // CB-5238 custom frameworks only
install: function (obj, plugin, project, options) {
var src = obj.src;
var custom = !!(obj.custom); // convert to boolean (if truthy/falsy)
Expand All @@ -96,7 +96,7 @@ var handlers = {
} else {
project.frameworks[src] = project.frameworks[src] || 0;
project.frameworks[src]++;
let opt = { customFramework: false, embed: false, link: true, weak: obj.weak };
const opt = { customFramework: false, embed: false, link: true, weak: obj.weak };
events.emit('verbose', util.format('Adding non-custom framework to project... %s -> %s', src, JSON.stringify(opt)));
project.xcode.addFramework(src, opt);
events.emit('verbose', util.format('Non-custom framework added to project. %s -> %s', src, JSON.stringify(opt)));
Expand All @@ -118,7 +118,7 @@ var handlers = {
events.emit('verbose', '"Embed Frameworks" Build Phase (Embedded Binaries) does not exist, creating it.');
project.xcode.addBuildPhase([], 'PBXCopyFilesBuildPhase', 'Embed Frameworks', null, 'frameworks');
}
let opt = { customFramework: true, embed: embed, link: link, sign: true };
const opt = { customFramework: true, embed: embed, link: link, sign: true };
events.emit('verbose', util.format('Adding custom framework to project... %s -> %s', src, JSON.stringify(opt)));
project.xcode.addFramework(project_relative, opt);
events.emit('verbose', util.format('Custom framework added to project. %s -> %s', src, JSON.stringify(opt)));
Expand Down Expand Up @@ -160,7 +160,7 @@ var handlers = {
events.emit('verbose', '<lib-file> uninstall is not supported for iOS plugins');
}
},
'asset': {
asset: {
install: function (obj, plugin, project, options) {
if (!obj.src) {
throw new CordovaError(generateAttributeError('src', 'asset', plugin.id));
Expand Down
Loading