Skip to content

Commit

Permalink
refactor(eslint): use cordova-eslint /w fix (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
timbru31 authored Jul 2, 2020
1 parent 6ae7a7a commit d6d5a34
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 182 deletions.
31 changes: 22 additions & 9 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# 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'

overrides:
- files: [tests/**/*.js]
extends: '@cordova/eslint-config/node-tests'
12 changes: 3 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"cordova-windows"
],
"scripts": {
"test": "npm run eslint",
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests"
"test": "npm run lint",
"lint": "eslint ."
},
"author": "Apache Software Foundation",
"license": "Apache-2.0",
Expand All @@ -37,12 +37,6 @@
}
},
"devDependencies": {
"eslint": "^4.0.0",
"eslint-config-semistandard": "^11.0.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-node": "^5.0.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1"
"@cordova/eslint-config": "^3.0.0"
}
}
33 changes: 18 additions & 15 deletions src/windows/GeolocationProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

/* global Windows, WinJS */
/* global cordova, Windows, WinJS */

var PositionError = require('./PositionError');
var callbacks = {};
Expand Down Expand Up @@ -50,13 +50,13 @@ function createErrorCode (loc) {
/* eslint-disable no-fallthrough */
switch (loc.locationStatus) {
case Windows.Devices.Geolocation.PositionStatus.initializing:
// This status indicates that a location device is still initializing
// This status indicates that a location device is still initializing
case Windows.Devices.Geolocation.PositionStatus.noData:
// No location data is currently available
// No location data is currently available
case Windows.Devices.Geolocation.PositionStatus.notInitialized:
// This status indicates that the app has not yet requested
// location data by calling GetGeolocationAsync() or
// registering an event handler for the positionChanged event.
// This status indicates that the app has not yet requested
// location data by calling GetGeolocationAsync() or
// registering an event handler for the positionChanged event.
case Windows.Devices.Geolocation.PositionStatus.notAvailable:
// Location is not available on this version of Windows
return PositionError.POSITION_UNAVAILABLE;
Expand Down Expand Up @@ -84,7 +84,8 @@ function createResult (pos) {
res.latitude = pos.coordinate.point.position.latitude;
res.longitude = pos.coordinate.point.position.longitude;
res.altitude = pos.coordinate.point.position.altitude;
} else { // compatibility with old windows8.0 api
} else {
// compatibility with old windows8.0 api
res.latitude = pos.coordinate.latitude;
res.longitude = pos.coordinate.longitude;
res.altitude = pos.coordinate.altitude;
Expand All @@ -100,9 +101,9 @@ module.exports = {
var highAccuracy = args[0];
var maxAge = args[1];

loc.desiredAccuracy = highAccuracy ?
Windows.Devices.Geolocation.PositionAccuracy.high :
Windows.Devices.Geolocation.PositionAccuracy.default;
loc.desiredAccuracy = highAccuracy
? Windows.Devices.Geolocation.PositionAccuracy.high
: Windows.Devices.Geolocation.PositionAccuracy.default;

loc.reportInterval = maxAge || 0;

Expand Down Expand Up @@ -141,7 +142,8 @@ module.exports = {
case Windows.Devices.Geolocation.PositionStatus.notAvailable:
fail({
code: PositionError.POSITION_UNAVAILABLE,
message: 'Data from location services is currently unavailable or you do not have the required location services present on your system.'
message:
'Data from location services is currently unavailable or you do not have the required location services present on your system.'
});
break;

Expand All @@ -159,11 +161,12 @@ module.exports = {
}
};

loc.desiredAccuracy = highAccuracy ?
Windows.Devices.Geolocation.PositionAccuracy.high :
Windows.Devices.Geolocation.PositionAccuracy.default;
loc.desiredAccuracy = highAccuracy
? Windows.Devices.Geolocation.PositionAccuracy.high
: Windows.Devices.Geolocation.PositionAccuracy.default;

if (cordova.platformId === 'windows') { // eslint-disable-line no-undef
if (cordova.platformId === 'windows') {
// eslint-disable-line no-undef
// 'positionchanged' event fails with error below if movementThreshold is not set
// JavaScript runtime error: Operation aborted
// You must set the MovementThreshold property or the ReportInterval property before adding event handlers.
Expand Down
Loading

0 comments on commit d6d5a34

Please sign in to comment.