Skip to content
Permalink
Browse files
Merge pull request #82 from brodybits/general-cleanup-with-eslint-update
General cleanup with eslint updates
  • Loading branch information
Chris Brody committed Jul 19, 2019
2 parents 83954d6 + 112b5cd commit d73d7fab70d2a5110bae174e48065065373732c9
Showing 20 changed files with 49 additions and 69 deletions.
@@ -5,7 +5,6 @@ rules:
- error
- 4
camelcase: off
padded-blocks: off
no-unused-vars:
- error
- args: after-used
@@ -39,8 +39,8 @@
},
"devDependencies": {
"eslint": "^5.0.0",
"eslint-config-semistandard": "^13.0.0",
"eslint-config-standard": "^12.0.0",
"eslint-config-semistandard": "^14.0.0",
"eslint-config-standard": "^13.0.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^4.0.0",
@@ -87,10 +87,10 @@ describe('config-changes module', function () {
});
it('Test 002 : should append specified plugin with any variables to platform.json', function () {
var platformJson = new PlatformJson(null, 'android', null);
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', { 'dude': 'man' });
platformJson.addInstalledPluginToPrepareQueue('org.test.plugins.dummyplugin', { dude: 'man' });
var json = platformJson.root;
expect(json.prepare_queue.installed[0].plugin).toEqual('org.test.plugins.dummyplugin');
expect(json.prepare_queue.installed[0].vars).toEqual({ 'dude': 'man' });
expect(json.prepare_queue.installed[0].vars).toEqual({ dude: 'man' });
});
});

@@ -116,7 +116,7 @@ describe('config-changes module', function () {
var filepath = path.join(plugins_dir, 'android.json');
var json = {
prepare_queue: { installed: [], uninstalled: [] },
config_munge: { files: { 'some_file': { parents: { 'some_parent': [{ 'xml': 'some_change', 'count': 1 }] } } } },
config_munge: { files: { some_file: { parents: { some_parent: [{ xml: 'some_change', count: 1 }] } } } },
installed_plugins: {},
dependent_plugins: {}
};
@@ -208,7 +208,7 @@ describe('config-changes module', function () {
it('Test 014 : should generate config munges for queued plugins', function () {
fs.copySync(android_two_project, temp);
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.root.prepare_queue.installed = [{ 'plugin': 'org.test.plugins.dummyplugin', 'vars': {} }];
platformJson.root.prepare_queue.installed = [{ plugin: 'org.test.plugins.dummyplugin', vars: {} }];
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
var spy = spyOn(munger, 'generate_plugin_config_munge').and.returnValue({});
munger.process(plugins_dir);
@@ -221,7 +221,7 @@ describe('config-changes module', function () {
});
it('Test 015 : should call graftXML for every new config munge it introduces (every leaf in config munge that does not exist)', function () {
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.root.prepare_queue.installed = [{ 'plugin': 'org.test.plugins.dummyplugin', 'vars': {} }];
platformJson.root.prepare_queue.installed = [{ plugin: 'org.test.plugins.dummyplugin', vars: {} }];

var spy = spyOn(xml_helpers, 'graftXML').and.returnValue(true);

@@ -413,7 +413,6 @@ describe('config-changes module', function () {
expect(sdk.attrib['android:targetSdkVersion']).toEqual('24');
expect(sdk.attrib['android:minSdkVersion']).toEqual('14');
expect(sdk.attrib['android:maxSdkVersion']).toBeUndefined();

});
it('should append new children to XML document tree', function () {
var configfile_cfg = new ConfigParser(configfile_xml);
@@ -484,7 +483,6 @@ describe('config-changes module', function () {
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.add_config_changes(cfg, true);
expect(function () { munger.process(plugins_dir); }).toThrow(new Error('org.test.editconfigtest_two cannot be added. <edit-config> changes in this plugin conflicts with <edit-config> changes in config.xml. Conflicts must be resolved before plugin can be added.'));

});
});
describe('of plist config files', function () {
@@ -558,7 +556,7 @@ describe('config-changes module', function () {
install_plugin(varplugin);

var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', { 'API_KEY': 'hi' }, true);
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', { API_KEY: 'hi' }, true);

var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);
@@ -595,7 +593,7 @@ describe('config-changes module', function () {

// Run through an "install"
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', { 'API_KEY': 'canucks' });
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', { API_KEY: 'canucks' });
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);

@@ -651,7 +649,7 @@ describe('config-changes module', function () {

// install the var plugin
var platformJson = PlatformJson.load(plugins_dir, 'android');
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', { 'API_KEY': 'eat my shorts' });
platformJson.addInstalledPluginToPrepareQueue('com.adobe.vars', { API_KEY: 'eat my shorts' });
var munger = new configChanges.PlatformMunger('android', temp, platformJson, pluginInfoProvider);
munger.process(plugins_dir);

@@ -22,7 +22,6 @@ var path = require('path');
var projectDir = path.join('project_dir', 'app', 'src', 'main');

describe('ConfigFile tests', function () {

beforeEach(function () {
spyOn(configFile, 'isBinaryPlist').and.callThrough();
});
@@ -43,7 +43,6 @@ describe('CordovaLogger class', function () {
});

describe('instance', function () {

var logger;

beforeEach(function () {
@@ -92,7 +91,6 @@ describe('CordovaLogger class', function () {
});

it('Test 009 : should attach corresponding listeners to supplied emitter', function () {

var eventNamesExclusions = {
log: 'normal',
warning: 'warn'
@@ -110,7 +108,6 @@ describe('CordovaLogger class', function () {
});

describe('log method', function () {

function CursorSpy (name) {
var cursorMethods = ['reset', 'write'];
var spy = jasmine.createSpyObj(name, cursorMethods);
@@ -120,7 +120,6 @@ var testFileStats3 = mockFileStats(now);
var nullLogger = function () {};

describe('FileUpdater class', function () {

beforeEach(function () {
FileUpdater.updatePathWithStatsCalls = [];
FileUpdater.updatePathWithStatsResult = true;
@@ -759,6 +758,5 @@ describe('FileUpdater class', function () {
testTargetDir,
null);
});

});
});
@@ -84,7 +84,6 @@ describe('PlatformJson class', function () {
});

it('Test 007 : should remove plugin modules from "root.modules" array based on file path', function () {

var pluginPaths = [
'plugins/fakeId/www/fakeModule.js',
'plugins/otherPlugin/www/module1.js',
@@ -37,7 +37,6 @@ var FAKE_LOCATIONS = {
};

describe('PluginManager class', function () {

beforeEach(function () {
spyOn(ConfigChanges, 'PlatformMunger');
spyOn(fs, 'outputJsonSync');
@@ -58,19 +58,19 @@ describe('prunePLIST', function () {
});

describe('plistGraft', function () {
let doc = {
const doc = {
'keychain-access-groups': [
'$(AppIdentifierPrefix)io.cordova.hellocordova',
'$(AppIdentifierPrefix)com.example.mylib'
]
};

let xml = '<array>' +
const xml = '<array>' +
'<string>$(AppIdentifierPrefix)io.cordova.hellocordova</string>' +
'<string>$(AppIdentifierPrefix)com.example.mylib</string>' +
'</array>';

let selector = 'keychain-access-groups';
const selector = 'keychain-access-groups';

it('Test 01: should not mangle existing plist entries', () => {
var graftStatus = plistHelpers.graftPLIST(doc, xml, selector);
@@ -41,7 +41,7 @@ describe('spawn method', function () {
return superspawn.spawn(LS, [], { stdio: 'pipe' })
.progress(progressSpy)
.then(function () {
expect(progressSpy).toHaveBeenCalledWith({ 'stdout': jasmine.any(String) });
expect(progressSpy).toHaveBeenCalledWith({ stdout: jasmine.any(String) });
});
});

@@ -51,7 +51,7 @@ describe('spawn method', function () {
.then(() => {
fail('Expected promise to be rejected');
}, () => {
expect(progressSpy).toHaveBeenCalledWith({ 'stderr': jasmine.any(String) });
expect(progressSpy).toHaveBeenCalledWith({ stderr: jasmine.any(String) });
});
});

@@ -112,7 +112,7 @@ describe('spawn method', function () {

describe('operation on windows', () => {
const TEST_SCRIPT = path.join(__dirname, 'fixtures/echo-args.cmd');
const TEST_ARGS = [ 'install', 'foo@^1.2.3', 'c o r d o v a' ];
const TEST_ARGS = ['install', 'foo@^1.2.3', 'c o r d o v a'];

it('should escape arguments if `cmd` is not an *.exe', () => {
if (process.platform !== 'win32') {
@@ -124,5 +124,4 @@ describe('spawn method', function () {
});
});
});

});
@@ -434,7 +434,6 @@ describe('xml-helpers', function () {
xml_helpers.mergeXml(testXml, dstXml, '', true);
testElements = dstXml.findall('access');
expect(testElements.length).toEqual(2);

});

it('Test 042 : should remove duplicate preferences (by name attribute value)', function () {
@@ -220,7 +220,6 @@ function add_config_changes (config, should_increment) {
// skip no chnages
return changes.filter(function (x) { return isConflictingInfo.noChanges.indexOf(x) === -1; });
}

}
return changes;
})(changes);
@@ -443,11 +442,9 @@ function is_conflicting (editchanges, config_munge, self, force) {
mungeutil.deep_add(conflictingMunge, change_file, conflictingParent, target_elem);
});
}

} else {
// plugin cannot overwrite other plugin changes without --force
conflictingPlugin = target[0].plugin;

}
}
}
@@ -74,8 +74,7 @@ function getCordovaNamespacePrefix (doc) {
* @return {String}
*/
function findElementAttributeValue (attributeName, elems) {

elems = Array.isArray(elems) ? elems : [ elems ];
elems = Array.isArray(elems) ? elems : [elems];

var value = elems.filter(function (elem) {
return elem.attrib.name.toLowerCase() === attributeName.toLowerCase();
@@ -186,15 +185,13 @@ ConfigParser.prototype = {
pref.attrib.value = value;
},
getPreference: function (name, platform) {

var platformPreference = '';

if (platform) {
platformPreference = this.getPlatformPreference(name, platform);
}

return platformPreference || this.getGlobalPreference(name);

},
setPreference: function (name, platform, value) {
if (!value) {
@@ -505,8 +502,8 @@ ConfigParser.prototype = {
return engines.map(function (engine) {
var spec = engine.attrib.spec || engine.attrib.version;
return {
'name': engine.attrib.name,
'spec': spec || null
name: engine.attrib.name,
spec: spec || null
};
});
},
@@ -523,14 +520,14 @@ ConfigParser.prototype = {
var allows_local_networking = access.attrib['allows-local-networking']; /* Boolean */

return {
'origin': access.attrib.origin,
'minimum_tls_version': minimum_tls_version,
'requires_forward_secrecy': requires_forward_secrecy,
'requires_certificate_transparency': requires_certificate_transparency,
'allows_arbitrary_loads_in_web_content': allows_arbitrary_loads_in_web_content,
'allows_arbitrary_loads_in_media': allows_arbitrary_loads_in_media,
'allows_arbitrary_loads_for_media': allows_arbitrary_loads_for_media,
'allows_local_networking': allows_local_networking
origin: access.attrib.origin,
minimum_tls_version: minimum_tls_version,
requires_forward_secrecy: requires_forward_secrecy,
requires_certificate_transparency: requires_certificate_transparency,
allows_arbitrary_loads_in_web_content: allows_arbitrary_loads_in_web_content,
allows_arbitrary_loads_in_media: allows_arbitrary_loads_in_media,
allows_arbitrary_loads_for_media: allows_arbitrary_loads_for_media,
allows_local_networking: allows_local_networking
};
});
},
@@ -543,10 +540,10 @@ ConfigParser.prototype = {
var requires_certificate_transparency = allow_navigation.attrib['requires-certificate-transparency']; /* Boolean */

return {
'href': allow_navigation.attrib.href,
'minimum_tls_version': minimum_tls_version,
'requires_forward_secrecy': requires_forward_secrecy,
'requires_certificate_transparency': requires_certificate_transparency
href: allow_navigation.attrib.href,
minimum_tls_version: minimum_tls_version,
requires_forward_secrecy: requires_forward_secrecy,
requires_certificate_transparency: requires_certificate_transparency
};
});
},
@@ -555,7 +552,7 @@ ConfigParser.prototype = {
var allow_intents = this.doc.findall('./allow-intent');
return allow_intents.map(function (allow_intent) {
return {
'href': allow_intent.attrib.href
href: allow_intent.attrib.href
};
});
},
@@ -49,11 +49,9 @@ CordovaError.EXTERNAL_TOOL_ERROR = 1;
* @returns {string} Error code string name
*/
CordovaError.prototype.getErrorCodeName = function () {
for (var key in CordovaError) {
if (CordovaError.hasOwnProperty(key)) {
if (CordovaError[key] === this.code) {
return key;
}
for (const key of Object.keys(CordovaError)) {
if (CordovaError[key] === this.code) {
return key;
}
}
};
@@ -37,10 +37,15 @@ const INSTANCE_KEY = Symbol.for('org.apache.cordova.common.CordovaLogger');
class CordovaLogger {
// Encapsulate the default logging level values with constants:
static get VERBOSE () { return 'verbose'; }

static get NORMAL () { return 'normal'; }

static get WARN () { return 'warn'; }

static get INFO () { return 'info'; }

static get ERROR () { return 'error'; }

static get RESULTS () { return 'results'; }

/**
@@ -244,7 +244,7 @@ function updatePaths (pathMap, options, log) {
*/
function mergeAndUpdateDir (sourceDirs, targetDir, options, log) {
if (sourceDirs && typeof sourceDirs === 'string') {
sourceDirs = [ sourceDirs ];
sourceDirs = [sourceDirs];
} else if (!Array.isArray(sourceDirs)) {
throw new Error('A source directory path or array of paths is required.');
}
@@ -257,16 +257,16 @@ function mergeAndUpdateDir (sourceDirs, targetDir, options, log) {

var rootDir = (options && options.rootDir) || '';

var include = (options && options.include) || [ '**' ];
var include = (options && options.include) || ['**'];
if (typeof include === 'string') {
include = [ include ];
include = [include];
} else if (!Array.isArray(include)) {
throw new Error('Include parameter must be a glob string or array of glob strings.');
}

var exclude = (options && options.exclude) || [];
if (typeof exclude === 'string') {
exclude = [ exclude ];
exclude = [exclude];
} else if (!Array.isArray(exclude)) {
throw new Error('Exclude parameter must be a glob string or array of glob strings.');
}

0 comments on commit d73d7fa

Please sign in to comment.