Skip to content

Commit 68fe464

Browse files
authored
chore(eslint): config upgrade to 5.0.0 (#260)
* chore: upgrade eslint config to version 5.0.0 * fix(eslint): Refactored eslint warnings/errors
1 parent 9187204 commit 68fe464

File tree

9 files changed

+986
-2842
lines changed

9 files changed

+986
-2842
lines changed

package-lock.json

Lines changed: 896 additions & 2752 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@
3737
}
3838
},
3939
"devDependencies": {
40-
"@cordova/eslint-config": "^3.0.0"
40+
"@cordova/eslint-config": "^5.0.0"
4141
}
4242
}

src/windows/GeolocationProxy.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616

1717
/* global cordova, Windows, WinJS */
1818

19-
var PositionError = require('./PositionError');
20-
var callbacks = {};
21-
var locs = {};
19+
const PositionError = require('./PositionError');
20+
const callbacks = {};
21+
const locs = {};
2222

2323
// constants
24-
var FALLBACK_EPSILON = 0.001;
24+
const FALLBACK_EPSILON = 0.001;
2525

2626
function ensureAndCreateLocator () {
27-
var deferral;
27+
let deferral;
2828

29-
var loc = new Windows.Devices.Geolocation.Geolocator();
29+
const loc = new Windows.Devices.Geolocation.Geolocator();
3030

3131
if (typeof Windows.Devices.Geolocation.Geolocator.requestAccessAsync === 'function') {
3232
deferral = Windows.Devices.Geolocation.Geolocator.requestAccessAsync().then(function (result) {
@@ -72,7 +72,7 @@ function createErrorCode (loc) {
7272
}
7373
/* eslint-enable no-fallthrough */
7474
function createResult (pos) {
75-
var res = {
75+
const res = {
7676
accuracy: pos.coordinate.accuracy,
7777
heading: pos.coordinate.heading,
7878
velocity: pos.coordinate.speed,
@@ -98,8 +98,8 @@ module.exports = {
9898
getLocation: function (success, fail, args, env) {
9999
ensureAndCreateLocator().done(function (loc) {
100100
if (loc) {
101-
var highAccuracy = args[0];
102-
var maxAge = args[1];
101+
const highAccuracy = args[0];
102+
const maxAge = args[1];
103103

104104
loc.desiredAccuracy = highAccuracy
105105
? Windows.Devices.Geolocation.PositionAccuracy.high
@@ -129,14 +129,14 @@ module.exports = {
129129

130130
addWatch: function (success, fail, args, env) {
131131
ensureAndCreateLocator().done(function (loc) {
132-
var clientId = args[0];
133-
var highAccuracy = args[1];
132+
const clientId = args[0];
133+
const highAccuracy = args[1];
134134

135-
var onPositionChanged = function (e) {
135+
const onPositionChanged = function (e) {
136136
success(createResult(e.position), { keepCallback: true });
137137
};
138138

139-
var onStatusChanged = function (e) {
139+
const onStatusChanged = function (e) {
140140
switch (e.status) {
141141
case Windows.Devices.Geolocation.PositionStatus.noData:
142142
case Windows.Devices.Geolocation.PositionStatus.notAvailable:
@@ -187,9 +187,9 @@ module.exports = {
187187
},
188188

189189
clearWatch: function (success, fail, args, env) {
190-
var clientId = args[0];
191-
var callback = callbacks[clientId];
192-
var loc = locs[clientId];
190+
const clientId = args[0];
191+
const callback = callbacks[clientId];
192+
const loc = locs[clientId];
193193

194194
if (callback && loc) {
195195
loc.removeEventListener('positionchanged', callback.pos);

tests/tests.js

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/* global WinJS, device */
2323

2424
exports.defineAutoTests = function () {
25-
var fail = function (done, context, message) {
25+
const fail = function (done, context, message) {
2626
// prevents done() to be called several times
2727
if (context) {
2828
if (context.done) return;
@@ -42,7 +42,7 @@ exports.defineAutoTests = function () {
4242
});
4343
};
4444

45-
var succeed = function (done, context) {
45+
const succeed = function (done, context) {
4646
// prevents done() to be called several times
4747
if (context) {
4848
if (context.done) return;
@@ -59,16 +59,16 @@ exports.defineAutoTests = function () {
5959
};
6060

6161
// On Windows, some tests prompt user for permission to use geolocation and interrupt autotests run
62-
var isWindowsStore = cordova.platformId === 'windows8' || (cordova.platformId === 'windows' && !WinJS.Utilities.isPhone); // eslint-disable-line no-undef
63-
var majorDeviceVersion = null;
64-
var versionRegex = /(\d)\..+/.exec(device.version);
62+
const isWindowsStore = cordova.platformId === 'windows8' || (cordova.platformId === 'windows' && !WinJS.Utilities.isPhone); // eslint-disable-line no-undef
63+
let majorDeviceVersion = null;
64+
const versionRegex = /(\d)\..+/.exec(device.version);
6565
if (versionRegex !== null) {
6666
majorDeviceVersion = Number(versionRegex[1]);
6767
}
6868
// Starting from Android 6.0 there are confirmation dialog which prevents us from running auto tests in silent mode (user interaction needed)
6969
// Also, Android emulator doesn't provide geo fix without manual interactions or mocks
70-
var skipAndroid = cordova.platformId === 'android' && (device.isVirtual || majorDeviceVersion >= 6); // eslint-disable-line no-undef
71-
var isIOSSim = false; // if iOS simulator does not have a location set, it will fail.
70+
const skipAndroid = cordova.platformId === 'android' && (device.isVirtual || majorDeviceVersion >= 6); // eslint-disable-line no-undef
71+
let isIOSSim = false; // if iOS simulator does not have a location set, it will fail.
7272

7373
describe('Geolocation (navigator.geolocation)', function () {
7474
it('geolocation.spec.1 should exist', function () {
@@ -166,7 +166,7 @@ exports.defineAutoTests = function () {
166166
});
167167

168168
describe('error callback', function () {
169-
var errorWatch = null;
169+
let errorWatch = null;
170170
afterEach(function () {
171171
navigator.geolocation.clearWatch(errorWatch);
172172
});
@@ -176,7 +176,7 @@ exports.defineAutoTests = function () {
176176
pending();
177177
}
178178

179-
var context = this;
179+
const context = this;
180180
errorWatch = navigator.geolocation.watchPosition(
181181
fail.bind(null, done, context, 'Unexpected win'),
182182
succeed.bind(null, done, context),
@@ -192,7 +192,7 @@ exports.defineAutoTests = function () {
192192
pending();
193193
}
194194

195-
var context = this;
195+
const context = this;
196196
errorWatch = navigator.geolocation.watchPosition(
197197
fail.bind(this, done, context, 'Unexpected win'),
198198
function (gpsError) {
@@ -215,7 +215,7 @@ exports.defineAutoTests = function () {
215215
});
216216

217217
describe('success callback', function () {
218-
var successWatch = null;
218+
let successWatch = null;
219219
afterEach(function () {
220220
navigator.geolocation.clearWatch(successWatch);
221221
});
@@ -225,7 +225,7 @@ exports.defineAutoTests = function () {
225225
pending();
226226
}
227227

228-
var context = this;
228+
const context = this;
229229
successWatch = navigator.geolocation.watchPosition(
230230
function (p) {
231231
// prevents done() to be called several times
@@ -255,7 +255,7 @@ exports.defineAutoTests = function () {
255255
/******************************************************************************/
256256

257257
exports.defineManualTests = function (contentEl, createActionButton) {
258-
var watchLocationId = null;
258+
let watchLocationId = null;
259259

260260
/**
261261
* Set location status
@@ -264,7 +264,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
264264
document.getElementById('location_status').innerHTML = status;
265265
}
266266
function setLocationDetails (p) {
267-
var date = new Date(p.timestamp);
267+
const date = new Date(p.timestamp);
268268
document.getElementById('latitude').innerHTML = p.coords.latitude;
269269
document.getElementById('longitude').innerHTML = p.coords.longitude;
270270
document.getElementById('altitude').innerHTML = p.coords.altitude;
@@ -279,7 +279,7 @@ exports.defineManualTests = function (contentEl, createActionButton) {
279279
* Stop watching the location
280280
*/
281281
function stopLocation () {
282-
var geo = navigator.geolocation;
282+
const geo = navigator.geolocation;
283283
if (!geo) {
284284
alert('navigator.geolocation object is missing.'); // eslint-disable-line no-undef
285285
return;
@@ -294,20 +294,20 @@ exports.defineManualTests = function (contentEl, createActionButton) {
294294
/**
295295
* Start watching location
296296
*/
297-
var watchLocation = function () {
298-
var geo = navigator.geolocation;
297+
const watchLocation = function () {
298+
const geo = navigator.geolocation;
299299
if (!geo) {
300300
alert('navigator.geolocation object is missing.'); // eslint-disable-line no-undef
301301
return;
302302
}
303303

304304
// Success callback
305-
var success = function (p) {
305+
const success = function (p) {
306306
setLocationDetails(p);
307307
};
308308

309309
// Fail callback
310-
var fail = function (e) {
310+
const fail = function (e) {
311311
console.log('watchLocation fail callback with error code ' + e);
312312
stopLocation(geo);
313313
};
@@ -320,8 +320,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
320320
/**
321321
* Get current location
322322
*/
323-
var getLocation = function (opts) {
324-
var geo = navigator.geolocation;
323+
const getLocation = function (opts) {
324+
const geo = navigator.geolocation;
325325
if (!geo) {
326326
alert('navigator.geolocation object is missing.'); // eslint-disable-line no-undef
327327
return;
@@ -331,13 +331,13 @@ exports.defineManualTests = function (contentEl, createActionButton) {
331331
stopLocation(geo);
332332

333333
// Success callback
334-
var success = function (p) {
334+
const success = function (p) {
335335
setLocationDetails(p);
336336
setLocationStatus('Done');
337337
};
338338

339339
// Fail callback
340-
var fail = function (e) {
340+
const fail = function (e) {
341341
console.log('getLocation fail callback with error code ' + e.code);
342342
setLocationStatus('Error: ' + e.code);
343343
};
@@ -350,62 +350,62 @@ exports.defineManualTests = function (contentEl, createActionButton) {
350350

351351
/******************************************************************************/
352352

353-
var location_div = '<div id="info">' + '<b>Status:</b> <span id="location_status">Stopped</span>' + '<table width="100%">';
354-
var latitude =
353+
const location_div = '<div id="info">' + '<b>Status:</b> <span id="location_status">Stopped</span>' + '<table width="100%">';
354+
const latitude =
355355
'<tr>' +
356356
'<td><b>Latitude:</b></td>' +
357357
'<td id="latitude">&nbsp;</td>' +
358358
'<td>(decimal degrees) geographic coordinate [<a href="http://dev.w3.org/geo/api/spec-source.html#lat">#ref]</a></td>' +
359359
'</tr>';
360-
var longitude =
360+
const longitude =
361361
'<tr>' +
362362
'<td><b>Longitude:</b></td>' +
363363
'<td id="longitude">&nbsp;</td>' +
364364
'<td>(decimal degrees) geographic coordinate [<a href="http://dev.w3.org/geo/api/spec-source.html#lat">#ref]</a></td>' +
365365
'</tr>';
366-
var altitude =
366+
const altitude =
367367
'<tr>' +
368368
'<td><b>Altitude:</b></td>' +
369369
'<td id="altitude">&nbsp;</td>' +
370370
'<td>null if not supported;<br>' +
371371
'(meters) height above the [<a href="http://dev.w3.org/geo/api/spec-source.html#ref-wgs">WGS84</a>] ellipsoid. [<a href="http://dev.w3.org/geo/api/spec-source.html#altitude">#ref]</a></td>' +
372372
'</tr>';
373-
var accuracy =
373+
const accuracy =
374374
'<tr>' +
375375
'<td><b>Accuracy:</b></td>' +
376376
'<td id="accuracy">&nbsp;</td>' +
377377
'<td>(meters; non-negative; 95% confidence level) the accuracy level of the latitude and longitude coordinates. [<a href="http://dev.w3.org/geo/api/spec-source.html#accuracy">#ref]</a></td>' +
378378
'</tr>';
379-
var heading =
379+
const heading =
380380
'<tr>' +
381381
'<td><b>Heading:</b></td>' +
382382
'<td id="heading">&nbsp;</td>' +
383383
'<td>null if not supported;<br>' +
384384
'NaN if speed == 0;<br>' +
385385
'(degrees; 0° ≤ heading < 360°) direction of travel of the hosting device- counting clockwise relative to the true north. [<a href="http://dev.w3.org/geo/api/spec-source.html#heading">#ref]</a></td>' +
386386
'</tr>';
387-
var speed =
387+
const speed =
388388
'<tr>' +
389389
'<td><b>Speed:</b></td>' +
390390
'<td id="speed">&nbsp;</td>' +
391391
'<td>null if not supported;<br>' +
392392
'(meters per second; non-negative) magnitude of the horizontal component of the hosting device current velocity. [<a href="http://dev.w3.org/geo/api/spec-source.html#speed">#ref]</a></td>' +
393393
'</tr>';
394-
var altitude_accuracy =
394+
const altitude_accuracy =
395395
'<tr>' +
396396
'<td><b>Altitude Accuracy:</b></td>' +
397397
'<td id="altitude_accuracy">&nbsp;</td>' +
398398
'<td>null if not supported;<br>(meters; non-negative; 95% confidence level) the accuracy level of the altitude. [<a href="http://dev.w3.org/geo/api/spec-source.html#altitude-accuracy">#ref]</a></td>' +
399399
'</tr>';
400-
var time =
400+
const time =
401401
'<tr>' +
402402
'<td><b>Time:</b></td>' +
403403
'<td id="timestamp">&nbsp;</td>' +
404404
'<td>(DOMTimeStamp) when the position was acquired [<a href="http://dev.w3.org/geo/api/spec-source.html#timestamp">#ref]</a></td>' +
405405
'</tr>' +
406406
'</table>' +
407407
'</div>';
408-
var actions =
408+
const actions =
409409
'<div id="cordova-getLocation"></div>' +
410410
'Expected result: Will update all applicable values in status box for current location. Status will read Retrieving Location (may not see this if location is retrieved immediately) then Done.' +
411411
'<p/> <div id="cordova-watchLocation"></div>' +
@@ -414,8 +414,8 @@ exports.defineManualTests = function (contentEl, createActionButton) {
414414
'Expected result: Will stop watching the location so values will not be updated. Status will read Stopped.' +
415415
'<p/> <div id="cordova-getOld"></div>' +
416416
'Expected result: Will update location values with a cached position that is up to 30 seconds old. Verify with time value. Status will read Done.';
417-
var values_info = '<h3>Details about each value are listed below in the status box</h3>';
418-
var note = '<h3>Allow use of current location, if prompted</h3>';
417+
const values_info = '<h3>Details about each value are listed below in the status box</h3>';
418+
const note = '<h3>Allow use of current location, if prompted</h3>';
419419

420420
contentEl.innerHTML =
421421
values_info +

www/Coordinates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @param {Object} altacc
3131
* @constructor
3232
*/
33-
var Coordinates = function (lat, lng, alt, acc, head, vel, altacc) {
33+
const Coordinates = function (lat, lng, alt, acc, head, vel, altacc) {
3434
/**
3535
* The latitude of the position.
3636
*/

www/Position.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
*
2020
*/
2121

22-
var Coordinates = require('./Coordinates');
22+
const Coordinates = require('./Coordinates');
2323

24-
var Position = function (coords, timestamp) {
24+
const Position = function (coords, timestamp) {
2525
if (coords) {
2626
this.coords = new Coordinates(
2727
coords.latitude,

www/PositionError.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* @param code
2727
* @param message
2828
*/
29-
var PositionError = function (code, message) {
29+
const PositionError = function (code, message) {
3030
this.code = code || null;
3131
this.message = message || '';
3232
};

0 commit comments

Comments
 (0)