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

Convert jshint to eslint #220

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 10 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
root: true
extends: semistandard
rules:
indent:
- error
- 4
camelcase: off
padded-blocks: off
operator-linebreak: off
no-throw-literal: off
1 change: 0 additions & 1 deletion .jshintignore

This file was deleted.

16 changes: 0 additions & 16 deletions .jshintrc

This file was deleted.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"cordova-windows"
],
"scripts": {
"test": "npm run jshint",
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
"test": "npm run eslint",
"eslint": "eslint --ignore-path .gitignore ."
},
"engines": {
"cordovaDependencies": {
Expand All @@ -45,7 +45,13 @@
"author": "Apache Software Foundation",
"license": "Apache-2.0",
"devDependencies": {
"jshint": "^2.6.0"
"eslint": "^5.15.2",
"eslint-config-semistandard": "^13.0.0",
"eslint-config-standard": "^12.0.0",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^4.0.0"
},
"homepage": "https://cordova.apache.org/"
}
77 changes: 38 additions & 39 deletions src/browser/SplashScreenProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,35 +22,35 @@
// Default parameter values including image size can be changed in `config.xml`
var splashImageWidth = 170;
var splashImageHeight = 200;
var position = { x: 0, y: 0, width: splashImageWidth, height: splashImageHeight };
var position = { x: 0, y: 0, width: splashImageWidth, height: splashImageHeight };
var localSplash; // the image to display
var localSplashImage;
var bgColor = "#464646";
var bgColor = '#464646';
var imageSrc = '/img/logo.png';
var splashScreenDelay = 3000; // in milliseconds
var showSplashScreen = true; // show splashcreen by default
var cordova = require('cordova');
var configHelper = cordova.require('cordova/confighelper');
var autoHideSplashScreen = true;

function updateImageLocation() {
function updateImageLocation () {
position.width = Math.min(splashImageWidth, window.innerWidth);
position.height = position.width * (splashImageHeight / splashImageWidth);

localSplash.style.width = window.innerWidth + "px";
localSplash.style.height = window.innerHeight + "px";
localSplash.style.top = "0px";
localSplash.style.left = "0px";

localSplashImage.style.top = "50%";
localSplashImage.style.left = "50%";
localSplashImage.style.height = position.height + "px";
localSplashImage.style.width = position.width + "px";
localSplashImage.style.marginTop = (-position.height / 2) + "px";
localSplashImage.style.marginLeft = (-position.width / 2) + "px";
localSplash.style.width = window.innerWidth + 'px';
localSplash.style.height = window.innerHeight + 'px';
localSplash.style.top = '0px';
localSplash.style.left = '0px';

localSplashImage.style.top = '50%';
localSplashImage.style.left = '50%';
localSplashImage.style.height = position.height + 'px';
localSplashImage.style.width = position.width + 'px';
localSplashImage.style.marginTop = (-position.height / 2) + 'px';
localSplashImage.style.marginLeft = (-position.width / 2) + 'px';
}

function onResize() {
function onResize () {
updateImageLocation();
}

Expand All @@ -62,16 +62,16 @@ var SplashScreen = {
}
},
show: function () {
if(!localSplash) {
window.addEventListener("resize", onResize, false);
localSplash = document.createElement("div");
if (!localSplash) {
window.addEventListener('resize', onResize, false);
localSplash = document.createElement('div');
localSplash.style.backgroundColor = bgColor;
localSplash.style.position = "absolute";
localSplash.style["z-index"] = "99999";
localSplash.style.position = 'absolute';
localSplash.style['z-index'] = '99999';

localSplashImage = document.createElement("img");
localSplashImage = document.createElement('img');
localSplashImage.src = imageSrc;
localSplashImage.style.position = "absolute";
localSplashImage.style.position = 'absolute';

updateImageLocation();

Expand All @@ -88,16 +88,16 @@ var SplashScreen = {
}
},
hide: function () {
if(localSplash) {
if (localSplash) {
var innerLocalSplash = localSplash;
localSplash = null;
window.removeEventListener("resize", onResize, false);
window.removeEventListener('resize', onResize, false);

innerLocalSplash.style.opacity = '0';
innerLocalSplash.style["-webkit-transition"] = "opacity 1s ease-in-out";
innerLocalSplash.style["-moz-transition"] = "opacity 1s ease-in-out";
innerLocalSplash.style["-ms-transition"] = "opacity 1s ease-in-out";
innerLocalSplash.style["-o-transition"] = "opacity 1s ease-in-out";
innerLocalSplash.style['-webkit-transition'] = 'opacity 1s ease-in-out';
innerLocalSplash.style['-moz-transition'] = 'opacity 1s ease-in-out';
innerLocalSplash.style['-ms-transition'] = 'opacity 1s ease-in-out';
innerLocalSplash.style['-o-transition'] = 'opacity 1s ease-in-out';

window.setTimeout(function () {
document.body.removeChild(innerLocalSplash);
Expand All @@ -112,10 +112,10 @@ var SplashScreen = {
/**
* Reads preferences via ConfigHelper and substitutes default parameters.
*/
function readPreferencesFromCfg(cfg) {
function readPreferencesFromCfg (cfg) {
try {
var value = cfg.getPreferenceValue('ShowSplashScreen');
if(typeof value != 'undefined') {
if (typeof value !== 'undefined') {
showSplashScreen = value === 'true';
}

Expand All @@ -128,7 +128,7 @@ function readPreferencesFromCfg(cfg) {
splashImageHeight = cfg.getPreferenceValue('SplashScreenHeight') || splashImageHeight;
autoHideSplashScreen = cfg.getPreferenceValue('AutoHideSplashScreen') || autoHideSplashScreen;
autoHideSplashScreen = (autoHideSplashScreen === true || autoHideSplashScreen.toLowerCase() === 'true');
} catch(e) {
} catch (e) {
var msg = '[Browser][SplashScreen] Error occurred on loading preferences from config.xml: ' + JSON.stringify(e);
console.error(msg);
}
Expand All @@ -137,11 +137,11 @@ function readPreferencesFromCfg(cfg) {
/**
* Shows and hides splashscreen if it is enabled, with a delay according the current preferences.
*/
function showAndHide() {
if(showSplashScreen) {
function showAndHide () {
if (showSplashScreen) {
SplashScreen.show();

window.setTimeout(function() {
window.setTimeout(function () {
SplashScreen.hide();
}, splashScreenDelay);
}
Expand All @@ -150,21 +150,20 @@ function showAndHide() {
/**
* Tries to read config.xml and override default properties and then shows and hides splashscreen if it is enabled.
*/
(function initAndShow() {
configHelper.readConfig(function(config) {
(function initAndShow () {
configHelper.readConfig(function (config) {
readPreferencesFromCfg(config);
if (autoHideSplashScreen) {
showAndHide();
} else {
SplashScreen.show();
}

}, function(err) {
}, function (err) {
console.error(err);
});
})();

module.exports = SplashScreen;

require("cordova/exec/proxy").add("SplashScreen", SplashScreen);

require('cordova/exec/proxy').add('SplashScreen', SplashScreen);
19 changes: 19 additions & 0 deletions tests/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.

env:
jasmine: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

10 changes: 4 additions & 6 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,26 @@
*
*/

/* jshint jasmine: true */

exports.defineAutoTests = function () {
describe('Splashscreen (cordova)', function () {
it("splashscreen.spec.1 should exist", function () {
it('splashscreen.spec.1 should exist', function () {
expect(navigator.splashscreen).toBeDefined();
});

it("splashscreen.spec.2 show method should exist", function () {
it('splashscreen.spec.2 show method should exist', function () {
expect(navigator.splashscreen.show).toBeDefined();
expect(typeof navigator.splashscreen.show).toBe('function');
});

it("splashscreen.spec.3 hide method should exist", function () {
it('splashscreen.spec.3 hide method should exist', function () {
expect(navigator.splashscreen.hide).toBeDefined();
expect(typeof navigator.splashscreen.hide).toBe('function');
});
});
};

exports.defineManualTests = function (contentEl, createActionButton) {
function showFor(duration) {
function showFor (duration) {
navigator.splashscreen.show();
window.setTimeout(function () {
navigator.splashscreen.hide();
Expand Down
8 changes: 4 additions & 4 deletions www/splashscreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
var exec = require('cordova/exec');

var splashscreen = {
show:function() {
exec(null, null, "SplashScreen", "show", []);
show: function () {
exec(null, null, 'SplashScreen', 'show', []);
},
hide:function() {
exec(null, null, "SplashScreen", "hide", []);
hide: function () {
exec(null, null, 'SplashScreen', 'hide', []);
}
};

Expand Down
6 changes: 2 additions & 4 deletions www/windows/SplashScreenProxy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -19,8 +19,6 @@
*
*/

/*jslint sloppy:true */

var splash = require('cordova/splashscreen');

var SplashScreen = {
Expand All @@ -34,4 +32,4 @@ var SplashScreen = {

module.exports = SplashScreen;

require("cordova/exec/proxy").add("SplashScreen", SplashScreen);
require('cordova/exec/proxy').add('SplashScreen', SplashScreen);