Skip to content
Permalink
Browse files
breaking: upgrade eslint w/ fix & cleanup (#49)
  • Loading branch information
erisu committed Jul 6, 2020
1 parent c3e10dc commit 5285562989b2f0761c2fd5b49161e9589445da92
Showing 10 changed files with 50 additions and 70 deletions.
@@ -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
extends: '@cordova/eslint-config/browser'
globals:
cordova: true
WinJS: true
describe: true
jasmineRequire: true
device: true

This file was deleted.

This file was deleted.

@@ -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"
}
}
@@ -19,9 +19,6 @@
*
*/

/* global device */
/* eslint no-undef : 0 */

jasmineRequire.medic = function (j$) {
j$.MedicReporter = jasmineRequire.MedicReporter(j$);
};
@@ -34,23 +31,23 @@ jasmineRequire.MedicReporter = function (j$) {

var platformMap = {
'ipod touch': 'ios',
'iphone': 'ios'
iphone: 'ios'
};

function MedicReporter (options) {
var logoptions = options.log || { logurl: 'http://127.0.0.1:5984/' }; // TODO: http://localhost:6800
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 @@ jasmineRequire.MedicReporter = function (j$) {
};

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 @@ jasmineRequire.MedicReporter = function (j$) {

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) {
@@ -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();
});
@@ -19,7 +19,6 @@
*
*/

/* eslint no-undef : 0 */
'use strict';

exports.setUpJasmine = function () {
@@ -80,5 +79,4 @@ function addJasmineReporters (jasmineInterface, jasmineEnv) {
jasmineInterface.MedicReporter.initialize();
jasmineEnv.addReporter(jasmineInterface.MedicReporter);
}

}
@@ -19,8 +19,6 @@
*
*/

/* global WinJS */
/* eslint no-undef : 0 */
'use strict';

var LOG_HEADER_HEIGHT = 20;
@@ -38,11 +36,11 @@ function getMode (callback) {

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 toggleTestEnabled (checkbox) {
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 @@ function runMain () {

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;
@@ -30,7 +30,7 @@ exports.load = function (callback) {

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);
@@ -27,7 +27,7 @@ function TestModule (api) {
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 @@ function TestModule (api) {

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 getTestsObject (api) {

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 @@ function requireAllTestModules () {
// 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 @@ exports.defineAutoTests = function () {

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 @@ exports.defineManualTests = function (contentEl, beforeEach, createActionButton)

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);

0 comments on commit 5285562

Please sign in to comment.