breaking: upgrade eslint w/ fix & cleanup (#49)
diff --git a/.eslintrc.yml b/.eslintrc.yml
index 0cccb8c..b25ad7e 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -1,10 +1,25 @@
+# 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
\ No newline at end of file
+extends: '@cordova/eslint-config/browser'
+globals:
+ cordova: true
+ WinJS: true
+ describe: true
+ jasmineRequire: true
+ device: true
diff --git a/.jshintignore b/.jshintignore
deleted file mode 100644
index 326cf95..0000000
--- a/.jshintignore
+++ /dev/null
@@ -1,2 +0,0 @@
-www/assets/jasmine-2.4.1
-www/assets/topcoat-0.7.5
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index a09a8f1..0000000
--- a/.jshintrc
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "browser": true
- , "devel": true
- , "bitwise": true
- , "undef": true
- , "trailing": true
- , "quotmark": false
- , "indent": 4
- , "unused": "vars"
- , "latedef": "nofunc"
- , "globals": {
- "module": false,
- "exports": false,
- "require": false,
- "cordova": true,
- "jasmineRequire": false
- }
-}
diff --git a/package.json b/package.json
index 4deddf0..0abb008 100644
--- a/package.json
+++ b/package.json
@@ -14,18 +14,12 @@
"ecosystem:cordova"
],
"scripts": {
- "test": "npm run eslint",
- "eslint": "eslint www"
+ "test": "npm run lint",
+ "lint": "eslint ."
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",
"devDependencies": {
- "eslint": "^4.2.0",
- "eslint-config-semistandard": "^11.0.0",
- "eslint-config-standard": "^10.2.1",
- "eslint-plugin-import": "^2.7.0",
- "eslint-plugin-node": "^5.1.1",
- "eslint-plugin-promise": "^3.5.0",
- "eslint-plugin-standard": "^3.0.1"
+ "@cordova/eslint-config": "^3.0.0"
}
}
diff --git a/www/assets/jasmine-medic.js b/www/assets/jasmine-medic.js
index 8cd69ce..6bc22b6 100644
--- a/www/assets/jasmine-medic.js
+++ b/www/assets/jasmine-medic.js
@@ -19,9 +19,6 @@
*
*/
-/* global device */
-/* eslint no-undef : 0 */
-
jasmineRequire.medic = function (j$) {
j$.MedicReporter = jasmineRequire.MedicReporter(j$);
};
@@ -34,7 +31,7 @@
var platformMap = {
'ipod touch': 'ios',
- 'iphone': 'ios'
+ iphone: 'ios'
};
function MedicReporter (options) {
@@ -42,15 +39,15 @@
var timer = options.timer || noopTimer;
var results = [];
var specsExecuted = 0;
- var failureCount = 0; // eslint-disable-line no-unused-vars
- var pendingSpecCount = 0; // eslint-disable-line no-unused-vars
+ var failureCount = 0;
+ var pendingSpecCount = 0; // eslint-disable-line
var serverurl = logoptions.logurl;
this.initialize = function () {
};
- var totalSpecsDefined; // eslint-disable-line no-unused-vars
+ var totalSpecsDefined; // eslint-disable-line
this.jasmineStarted = function (options) {
totalSpecsDefined = options.totalSpecsDefined || 0;
timer.start();
@@ -82,7 +79,7 @@
};
var buildResults = function () {
- var json = {specs: specsExecuted, failures: failureCount, results: results};
+ var json = { specs: specsExecuted, failures: failureCount, results: results };
return json;
};
@@ -98,13 +95,12 @@
this.postTests({
mobilespec: buildResults(),
- platform: (platformMap.hasOwnProperty(p) ? platformMap[p] : p),
+ platform: (Object.prototype.hasOwnProperty.call(platformMap, p) ? platformMap[p] : p),
version: version,
sha: options.sha,
timestamp: Math.round(Math.floor((new Date()).getTime() / 1000)),
model: devmodel
});
-
};
this.postTests = function (json) {
diff --git a/www/assets/main-bootstrap.js b/www/assets/main-bootstrap.js
index 90b0d88..8b5c7f1 100644
--- a/www/assets/main-bootstrap.js
+++ b/www/assets/main-bootstrap.js
@@ -22,5 +22,5 @@
document.addEventListener('deviceready', function () {
'use strict';
- cordova.require('cordova-plugin-test-framework.main').init(); // eslint-disable-line no-undef
+ cordova.require('cordova-plugin-test-framework.main').init();
});
diff --git a/www/jasmine_helpers.js b/www/jasmine_helpers.js
index 53f7bbe..6de0288 100644
--- a/www/jasmine_helpers.js
+++ b/www/jasmine_helpers.js
@@ -19,7 +19,6 @@
*
*/
-/* eslint no-undef : 0 */
'use strict';
exports.setUpJasmine = function () {
@@ -80,5 +79,4 @@
jasmineInterface.MedicReporter.initialize();
jasmineEnv.addReporter(jasmineInterface.MedicReporter);
}
-
}
diff --git a/www/main.js b/www/main.js
index 56d0897..c664e1e 100644
--- a/www/main.js
+++ b/www/main.js
@@ -19,8 +19,6 @@
*
*/
-/* global WinJS */
-/* eslint no-undef : 0 */
'use strict';
var LOG_HEADER_HEIGHT = 20;
@@ -38,11 +36,11 @@
function setMode (mode) {
var handlers = {
- 'main': runMain,
- 'auto': runAutoTests,
- 'manual': runManualTests
+ main: runMain,
+ auto: runAutoTests,
+ manual: runManualTests
};
- if (!handlers.hasOwnProperty(mode)) {
+ if (!Object.prototype.hasOwnProperty.call(handlers, mode)) {
console.error('Unsupported mode: ' + mode);
console.error("Defaulting to 'main'");
mode = 'main';
@@ -350,7 +348,7 @@
function iterateAutoTests (cdvtests, callback) {
Object.keys(cdvtests.tests).forEach(function (api) {
var testModule = cdvtests.tests[api];
- if (!testModule.hasOwnProperty('defineAutoTests')) {
+ if (!Object.prototype.hasOwnProperty.call(testModule, 'defineAutoTests')) {
return;
}
callback(api, testModule);
@@ -413,7 +411,7 @@
if (isWin && typeof WinJS !== 'undefined') {
var app = WinJS.Application;
- app.addEventListener('error', function (err) { // eslint-disable-line handle-callback-err
+ app.addEventListener('error', function () {
// We do not want an unhandled exception to crash the test app
// Returning true marks it as being handled
return true;
diff --git a/www/medic.js b/www/medic.js
index 89141e6..0e8b4b2 100644
--- a/www/medic.js
+++ b/www/medic.js
@@ -30,7 +30,7 @@
try {
// attempt to synchronously load medic config
- var xhr = new XMLHttpRequest(); // eslint-disable-line no-undef
+ var xhr = new XMLHttpRequest();
xhr.open('GET', '../medic.json', false);
xhr.send(null);
cfg = JSON.parse(xhr.responseText);
diff --git a/www/tests.js b/www/tests.js
index 655c108..bf2aaea 100644
--- a/www/tests.js
+++ b/www/tests.js
@@ -27,7 +27,7 @@
var name = api;
var enabled = true;
- var enabledPref = localStorage.getItem('cordova-tests-enabled-' + name); // eslint-disable-line no-undef
+ var enabledPref = localStorage.getItem('cordova-tests-enabled-' + name);
if (enabledPref) {
enabled = (enabledPref === true.toString());
}
@@ -38,7 +38,7 @@
this.setEnabled = function (isEnabled) {
enabled = isEnabled;
- localStorage.setItem('cordova-tests-enabled-' + name, enabled); // eslint-disable-line no-undef
+ localStorage.setItem('cordova-tests-enabled-' + name, enabled);
};
}
@@ -49,7 +49,7 @@
function requireAllTestModules () {
// This finds all js-modules named "tests" (regardless of plugins they came from)
- var test_modules = cordova.require('cordova/plugin_list') // eslint-disable-line no-undef
+ var test_modules = cordova.require('cordova/plugin_list')
.map(function (jsmodule) {
return jsmodule.id;
})
@@ -60,20 +60,19 @@
// Map auto / manual test definitions for each, but without actually running the handlers
test_modules.forEach(function (id) {
try {
- var plugintests = cordova.require(id); // eslint-disable-line no-undef
+ var plugintests = cordova.require(id);
- if (plugintests.hasOwnProperty('defineAutoTests')) {
+ if (Object.prototype.hasOwnProperty.call(plugintests, 'defineAutoTests')) {
getTestsObject(id).defineAutoTests = function () {
- describe(id + ' >>', plugintests.defineAutoTests.bind(plugintests)); // eslint-disable-line no-undef
+ describe(id + ' >>', plugintests.defineAutoTests.bind(plugintests));
};
}
- if (plugintests.hasOwnProperty('defineManualTests')) {
+ if (Object.prototype.hasOwnProperty.call(plugintests, 'defineManualTests')) {
getTestsObject(id).defineManualTests = plugintests.defineManualTests.bind(plugintests);
}
} catch (ex) {
console.warn('Failed to load tests: ', id);
-
}
});
}
@@ -104,7 +103,7 @@
Object.keys(exports.tests).forEach(function (key) {
if (!exports.tests[key].getEnabled()) { return; }
- if (!exports.tests[key].hasOwnProperty('defineAutoTests')) { return; }
+ if (!Object.prototype.hasOwnProperty.call(exports.tests[key], 'defineAutoTests')) { return; }
exports.tests[key].defineAutoTests();
});
};
@@ -115,7 +114,7 @@
Object.keys(exports.tests).forEach(function (key) {
if (!exports.tests[key].getEnabled()) { return; }
- if (!exports.tests[key].hasOwnProperty('defineManualTests')) { return; }
+ if (!Object.prototype.hasOwnProperty.call(exports.tests[key], 'defineManualTests')) { return; }
createActionButton(key, function () {
beforeEach(key);
exports.tests[key].defineManualTests(contentEl, createActionButton);