Skip to content

Commit 893ba08

Browse files
authored
breaking: replace jshint with eslint (#277)
* breaking: remove jshint files and references * breaking: swap jshint with eslint * chore: apply eslint auto corrections * chore: remove jslint inline ignore rule
1 parent 369f8d1 commit 893ba08

File tree

7 files changed

+74
-73
lines changed

7 files changed

+74
-73
lines changed

.eslintrc.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
root: true
19+
extends: '@cordova/eslint-config/browser'
20+
21+
overrides:
22+
- files: [tests/**/*.js]
23+
extends: '@cordova/eslint-config/node-tests'

.jshintrc

Lines changed: 0 additions & 16 deletions
This file was deleted.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
"cordova-windows"
2222
],
2323
"scripts": {
24-
"test": "npm run jshint",
25-
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
24+
"test": "npm run lint",
25+
"lint": "eslint ."
2626
},
2727
"engines": {
2828
"cordovaDependencies": {
@@ -41,7 +41,7 @@
4141
"author": "Apache Software Foundation",
4242
"license": "Apache-2.0",
4343
"devDependencies": {
44-
"jshint": "^2.6.0"
44+
"@cordova/eslint-config": "^3.0.0"
4545
},
4646
"homepage": "https://github.com/apache/cordova-plugin-splashscreen#readme"
4747
}

src/browser/SplashScreenProxy.js

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,35 @@
2222
// Default parameter values including image size can be changed in `config.xml`
2323
var splashImageWidth = 170;
2424
var splashImageHeight = 200;
25-
var position = { x: 0, y: 0, width: splashImageWidth, height: splashImageHeight };
25+
var position = { x: 0, y: 0, width: splashImageWidth, height: splashImageHeight };
2626
var localSplash; // the image to display
2727
var localSplashImage;
28-
var bgColor = "#464646";
28+
var bgColor = '#464646';
2929
var imageSrc = '/img/logo.png';
3030
var splashScreenDelay = 3000; // in milliseconds
3131
var showSplashScreen = true; // show splashcreen by default
3232
var cordova = require('cordova');
3333
var configHelper = cordova.require('cordova/confighelper');
3434
var autoHideSplashScreen = true;
3535

36-
function updateImageLocation() {
36+
function updateImageLocation () {
3737
position.width = Math.min(splashImageWidth, window.innerWidth);
3838
position.height = position.width * (splashImageHeight / splashImageWidth);
3939

40-
localSplash.style.width = window.innerWidth + "px";
41-
localSplash.style.height = window.innerHeight + "px";
42-
localSplash.style.top = "0px";
43-
localSplash.style.left = "0px";
44-
45-
localSplashImage.style.top = "50%";
46-
localSplashImage.style.left = "50%";
47-
localSplashImage.style.height = position.height + "px";
48-
localSplashImage.style.width = position.width + "px";
49-
localSplashImage.style.marginTop = (-position.height / 2) + "px";
50-
localSplashImage.style.marginLeft = (-position.width / 2) + "px";
40+
localSplash.style.width = window.innerWidth + 'px';
41+
localSplash.style.height = window.innerHeight + 'px';
42+
localSplash.style.top = '0px';
43+
localSplash.style.left = '0px';
44+
45+
localSplashImage.style.top = '50%';
46+
localSplashImage.style.left = '50%';
47+
localSplashImage.style.height = position.height + 'px';
48+
localSplashImage.style.width = position.width + 'px';
49+
localSplashImage.style.marginTop = (-position.height / 2) + 'px';
50+
localSplashImage.style.marginLeft = (-position.width / 2) + 'px';
5151
}
5252

53-
function onResize() {
53+
function onResize () {
5454
updateImageLocation();
5555
}
5656

@@ -62,16 +62,16 @@ var SplashScreen = {
6262
}
6363
},
6464
show: function () {
65-
if(!localSplash) {
66-
window.addEventListener("resize", onResize, false);
67-
localSplash = document.createElement("div");
65+
if (!localSplash) {
66+
window.addEventListener('resize', onResize, false);
67+
localSplash = document.createElement('div');
6868
localSplash.style.backgroundColor = bgColor;
69-
localSplash.style.position = "absolute";
70-
localSplash.style["z-index"] = "99999";
69+
localSplash.style.position = 'absolute';
70+
localSplash.style['z-index'] = '99999';
7171

72-
localSplashImage = document.createElement("img");
72+
localSplashImage = document.createElement('img');
7373
localSplashImage.src = imageSrc;
74-
localSplashImage.style.position = "absolute";
74+
localSplashImage.style.position = 'absolute';
7575

7676
updateImageLocation();
7777

@@ -88,16 +88,16 @@ var SplashScreen = {
8888
}
8989
},
9090
hide: function () {
91-
if(localSplash) {
91+
if (localSplash) {
9292
var innerLocalSplash = localSplash;
9393
localSplash = null;
94-
window.removeEventListener("resize", onResize, false);
94+
window.removeEventListener('resize', onResize, false);
9595

9696
innerLocalSplash.style.opacity = '0';
97-
innerLocalSplash.style["-webkit-transition"] = "opacity 1s ease-in-out";
98-
innerLocalSplash.style["-moz-transition"] = "opacity 1s ease-in-out";
99-
innerLocalSplash.style["-ms-transition"] = "opacity 1s ease-in-out";
100-
innerLocalSplash.style["-o-transition"] = "opacity 1s ease-in-out";
97+
innerLocalSplash.style['-webkit-transition'] = 'opacity 1s ease-in-out';
98+
innerLocalSplash.style['-moz-transition'] = 'opacity 1s ease-in-out';
99+
innerLocalSplash.style['-ms-transition'] = 'opacity 1s ease-in-out';
100+
innerLocalSplash.style['-o-transition'] = 'opacity 1s ease-in-out';
101101

102102
window.setTimeout(function () {
103103
document.body.removeChild(innerLocalSplash);
@@ -112,10 +112,10 @@ var SplashScreen = {
112112
/**
113113
* Reads preferences via ConfigHelper and substitutes default parameters.
114114
*/
115-
function readPreferencesFromCfg(cfg) {
115+
function readPreferencesFromCfg (cfg) {
116116
try {
117117
var value = cfg.getPreferenceValue('ShowSplashScreen');
118-
if(typeof value != 'undefined') {
118+
if (typeof value !== 'undefined') {
119119
showSplashScreen = value === 'true';
120120
}
121121

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

144-
window.setTimeout(function() {
144+
window.setTimeout(function () {
145145
SplashScreen.hide();
146146
}, splashScreenDelay);
147147
}
@@ -150,21 +150,19 @@ function showAndHide() {
150150
/**
151151
* Tries to read config.xml and override default properties and then shows and hides splashscreen if it is enabled.
152152
*/
153-
(function initAndShow() {
154-
configHelper.readConfig(function(config) {
153+
(function initAndShow () {
154+
configHelper.readConfig(function (config) {
155155
readPreferencesFromCfg(config);
156156
if (autoHideSplashScreen) {
157157
showAndHide();
158158
} else {
159159
SplashScreen.show();
160160
}
161-
162-
}, function(err) {
161+
}, function (err) {
163162
console.error(err);
164163
});
165164
})();
166165

167166
module.exports = SplashScreen;
168167

169-
require("cordova/exec/proxy").add("SplashScreen", SplashScreen);
170-
168+
require('cordova/exec/proxy').add('SplashScreen', SplashScreen);

tests/tests.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,26 @@
1919
*
2020
*/
2121

22-
/* jshint jasmine: true */
23-
2422
exports.defineAutoTests = function () {
2523
describe('Splashscreen (cordova)', function () {
26-
it("splashscreen.spec.1 should exist", function () {
24+
it('splashscreen.spec.1 should exist', function () {
2725
expect(navigator.splashscreen).toBeDefined();
2826
});
2927

30-
it("splashscreen.spec.2 show method should exist", function () {
28+
it('splashscreen.spec.2 show method should exist', function () {
3129
expect(navigator.splashscreen.show).toBeDefined();
3230
expect(typeof navigator.splashscreen.show).toBe('function');
3331
});
3432

35-
it("splashscreen.spec.3 hide method should exist", function () {
33+
it('splashscreen.spec.3 hide method should exist', function () {
3634
expect(navigator.splashscreen.hide).toBeDefined();
3735
expect(typeof navigator.splashscreen.hide).toBe('function');
3836
});
3937
});
4038
};
4139

4240
exports.defineManualTests = function (contentEl, createActionButton) {
43-
function showFor(duration) {
41+
function showFor (duration) {
4442
navigator.splashscreen.show();
4543
window.setTimeout(function () {
4644
navigator.splashscreen.hide();

www/splashscreen.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
var exec = require('cordova/exec');
2323

2424
var splashscreen = {
25-
show:function() {
26-
exec(null, null, "SplashScreen", "show", []);
25+
show: function () {
26+
exec(null, null, 'SplashScreen', 'show', []);
2727
},
28-
hide:function() {
29-
exec(null, null, "SplashScreen", "hide", []);
28+
hide: function () {
29+
exec(null, null, 'SplashScreen', 'hide', []);
3030
}
3131
};
3232

www/windows/SplashScreenProxy.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
*
33
* Licensed to the Apache Software Foundation (ASF) under one
44
* or more contributor license agreements. See the NOTICE file
@@ -19,8 +19,6 @@
1919
*
2020
*/
2121

22-
/*jslint sloppy:true */
23-
2422
var splash = require('cordova/splashscreen');
2523

2624
var SplashScreen = {
@@ -34,4 +32,4 @@ var SplashScreen = {
3432

3533
module.exports = SplashScreen;
3634

37-
require("cordova/exec/proxy").add("SplashScreen", SplashScreen);
35+
require('cordova/exec/proxy').add('SplashScreen', SplashScreen);

0 commit comments

Comments
 (0)