refactor: eslint setup (#105)
* replace dependencies with @cordova/eslint-config
* update eslint config
* eslint corrections
* chore: fix newline
* chore: re-add no-unused-vars after-used error
* chore: corrected no-unused-vars settings
diff --git a/.eslintignore b/.eslintignore
index d606f61..8ade0d6 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1 +1,2 @@
-spec/fixtures/*
+coverage/
+spec/fixtures/
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 92aaf67..f540d52 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -1,10 +1,9 @@
root: true
-extends: semistandard
+extends: '@cordova/eslint-config/node'
+
rules:
- indent:
- - error
- - 4
- camelcase: off
no-unused-vars:
- error
- args: after-used
+ vars: all
+ ignoreRestSiblings: true
diff --git a/package.json b/package.json
index 69ea020..a95736d 100644
--- a/package.json
+++ b/package.json
@@ -17,9 +17,9 @@
"node": ">=10.0.0"
},
"scripts": {
- "test": "npm run eslint && npm run cover",
+ "test": "npm run lint && npm run cover",
"test:unit": "jasmine \"spec/**/*.spec.js\"",
- "eslint": "eslint src spec",
+ "lint": "eslint .",
"cover": "nyc npm run test:unit"
},
"dependencies": {
@@ -37,13 +37,7 @@
"underscore": "^1.9.1"
},
"devDependencies": {
- "eslint": "^5.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",
- "eslint-plugin-standard": "^4.0.0",
+ "@cordova/eslint-config": "^2.0.0",
"jasmine": "^3.5.0",
"jasmine-spec-reporter": "^4.2.1",
"nyc": "^14.1.1",
diff --git a/spec/.eslintrc.yml b/spec/.eslintrc.yml
index 0b295ed..61b6492 100644
--- a/spec/.eslintrc.yml
+++ b/spec/.eslintrc.yml
@@ -1,6 +1,5 @@
-env:
- jasmine: true
+root: true
+extends: '@cordova/eslint-config/node-tests'
-# Not covered by jasmine env as of writing
globals:
- expectAsync: false
+ expectAsync: false
diff --git a/spec/ConfigChanges/ConfigChanges.spec.js b/spec/ConfigChanges/ConfigChanges.spec.js
index 021535a..d700bae 100644
--- a/spec/ConfigChanges/ConfigChanges.spec.js
+++ b/spec/ConfigChanges/ConfigChanges.spec.js
@@ -476,7 +476,7 @@
expect(platformJson.root.prepare_queue.installed.length).toEqual(0);
expect(platformJson.root.installed_plugins['com.adobe.vars']).toBeDefined();
- expect(platformJson.root.installed_plugins['com.adobe.vars']['API_KEY']).toEqual('hi');
+ expect(platformJson.root.installed_plugins['com.adobe.vars'].API_KEY).toEqual('hi');
});
});
@@ -517,7 +517,7 @@
var munge_params = spy.calls.argsFor(0);
expect(munge_params[0]).toEqual(jasmine.any(PluginInfo));
expect(munge_params[0].dir).toEqual(path.join(plugins_dir, 'com.adobe.vars'));
- expect(munge_params[1]['API_KEY']).toEqual('canucks');
+ expect(munge_params[1].API_KEY).toEqual('canucks');
});
it('Test 029 : should not call pruneXML for a config munge that another plugin depends on', function () {
fs.copySync(android_two_no_perms_project, temp);
diff --git a/spec/PluginInfo/PluginInfo.spec.js b/spec/PluginInfo/PluginInfo.spec.js
index aa2a7c8..e508f86 100644
--- a/spec/PluginInfo/PluginInfo.spec.js
+++ b/spec/PluginInfo/PluginInfo.spec.js
@@ -69,7 +69,7 @@
expect(Object.keys(podSpec.libraries).length).toBe(4);
expect(podSpec.declarations['use-frameworks']).toBe('true');
expect(podSpec.sources['https://github.com/CocoaPods/Specs.git'].source).toBe('https://github.com/CocoaPods/Specs.git');
- expect(podSpec.libraries['AFNetworking'].spec).toBe('~> 3.2');
- expect(podSpec.libraries['Eureka']['swift-version']).toBe('4.1');
+ expect(podSpec.libraries.AFNetworking.spec).toBe('~> 3.2');
+ expect(podSpec.libraries.Eureka['swift-version']).toBe('4.1');
});
});
diff --git a/src/ConfigChanges/ConfigChanges.js b/src/ConfigChanges/ConfigChanges.js
index 27c2d9e..4feeeb2 100644
--- a/src/ConfigChanges/ConfigChanges.js
+++ b/src/ConfigChanges/ConfigChanges.js
@@ -392,7 +392,8 @@
}
});
- return { conflictFound: conflictFound,
+ return {
+ conflictFound: conflictFound,
conflictingPlugin: conflictingPlugin,
conflictingMunge: conflictingMunge,
configxmlMunge: configxmlMunge,
diff --git a/src/ConfigParser/ConfigParser.js b/src/ConfigParser/ConfigParser.js
index dc1b66d..99ed78e 100644
--- a/src/ConfigParser/ConfigParser.js
+++ b/src/ConfigParser/ConfigParser.js
@@ -99,7 +99,7 @@
return this.getAttribute('id');
},
setPackageName: function (id) {
- this.doc.getroot().attrib['id'] = id;
+ this.doc.getroot().attrib.id = id;
},
android_packageName: function () {
return this.getAttribute('android-packageName');
@@ -118,14 +118,14 @@
el.text = name;
},
shortName: function () {
- return this.doc.find('name').attrib['short'] || this.name();
+ return this.doc.find('name').attrib.short || this.name();
},
setShortName: function (shortname) {
var el = findOrCreate(this.doc, 'name');
if (!el.text) {
el.text = shortname;
}
- el.attrib['short'] = shortname;
+ el.attrib.short = shortname;
},
description: function () {
return getNodeTextSafe(this.doc.find('description'));
@@ -147,7 +147,7 @@
return this.getAttribute('ios-CFBundleVersion');
},
setVersion: function (value) {
- this.doc.getroot().attrib['version'] = value;
+ this.doc.getroot().attrib.version = value;
},
author: function () {
return getNodeTextSafe(this.doc.find('author'));
@@ -229,7 +229,7 @@
var res = {};
res.src = elt.attrib.src;
res.target = elt.attrib.target || undefined;
- res.density = elt.attrib['density'] || elt.attrib[that.cdvNamespacePrefix + ':density'] || elt.attrib['gap:density'];
+ res.density = elt.attrib.density || elt.attrib[that.cdvNamespacePrefix + ':density'] || elt.attrib['gap:density'];
res.platform = elt.platform || null; // null means icon represents default icon (shared between platforms)
res.width = +elt.attrib.width || undefined;
res.height = +elt.attrib.height || undefined;
@@ -562,14 +562,13 @@
var edit_configs = this.doc.findall('edit-config').concat(platform_edit_configs);
return edit_configs.map(function (tag) {
- var editConfig =
- {
- file: tag.attrib['file'],
- target: tag.attrib['target'],
- mode: tag.attrib['mode'],
- id: 'config.xml',
- xmls: tag.getchildren()
- };
+ var editConfig = {
+ file: tag.attrib.file,
+ target: tag.attrib.target,
+ mode: tag.attrib.mode,
+ id: 'config.xml',
+ xmls: tag.getchildren()
+ };
return editConfig;
});
},
@@ -580,16 +579,15 @@
var config_files = this.doc.findall('config-file').concat(platform_config_files);
return config_files.map(function (tag) {
- var configFile =
- {
- target: tag.attrib['target'],
- parent: tag.attrib['parent'],
- after: tag.attrib['after'],
- xmls: tag.getchildren(),
- // To support demuxing via versions
- versions: tag.attrib['versions'],
- deviceTarget: tag.attrib['device-target']
- };
+ var configFile = {
+ target: tag.attrib.target,
+ parent: tag.attrib.parent,
+ after: tag.attrib.after,
+ xmls: tag.getchildren(),
+ // To support demuxing via versions
+ versions: tag.attrib.versions,
+ deviceTarget: tag.attrib['device-target']
+ };
return configFile;
});
},
diff --git a/src/PluginInfo/PluginInfo.js b/src/PluginInfo/PluginInfo.js
index 0130741..bcc3e41 100644
--- a/src/PluginInfo/PluginInfo.js
+++ b/src/PluginInfo/PluginInfo.js
@@ -101,13 +101,13 @@
}
function _parseDependency (tag) {
- var dep =
- { id: tag.attrib.id,
- version: tag.attrib.version || '',
- url: tag.attrib.url || '',
- subdir: tag.attrib.subdir || '',
- commit: tag.attrib.commit
- };
+ var dep = {
+ id: tag.attrib.id,
+ version: tag.attrib.version || '',
+ url: tag.attrib.url || '',
+ subdir: tag.attrib.subdir || '',
+ commit: tag.attrib.commit
+ };
dep.git_ref = dep.commit;
@@ -129,15 +129,15 @@
}
function _parseConfigFile (tag) {
- var configFile =
- { target: tag.attrib['target'],
- parent: tag.attrib['parent'],
- after: tag.attrib['after'],
- xmls: tag.getchildren(),
- // To support demuxing via versions
- versions: tag.attrib['versions'],
- deviceTarget: tag.attrib['device-target']
- };
+ var configFile = {
+ target: tag.attrib.target,
+ parent: tag.attrib.parent,
+ after: tag.attrib.after,
+ xmls: tag.getchildren(),
+ // To support demuxing via versions
+ versions: tag.attrib.versions,
+ deviceTarget: tag.attrib['device-target']
+ };
return configFile;
}
@@ -148,12 +148,12 @@
}
function _parseEditConfigs (tag) {
- var editConfig =
- { file: tag.attrib['file'],
- target: tag.attrib['target'],
- mode: tag.attrib['mode'],
- xmls: tag.getchildren()
- };
+ var editConfig = {
+ file: tag.attrib.file,
+ target: tag.attrib.target,
+ mode: tag.attrib.mode,
+ xmls: tag.getchildren()
+ };
return editConfig;
}
@@ -203,7 +203,7 @@
itemType: 'header-file',
src: tag.attrib.src,
targetDir: tag.attrib['target-dir'],
- type: tag.attrib['type']
+ type: tag.attrib.type
};
});
return headerFiles;