Skip to content

Commit

Permalink
refactor(eslint): use cordova-eslint /w fix (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
timbru31 authored Jul 2, 2020
1 parent cdc7488 commit 26e6764
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 138 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 @@ -24,8 +24,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": "^3.19.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"
}
}
28 changes: 13 additions & 15 deletions src/windows/NotificationProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
*/

/* global Windows:true, WinJS, toStaticHTML */
/* global Windows, WinJS, toStaticHTML */

var cordova = require('cordova');
var urlutil = require('cordova/urlutil');
Expand All @@ -46,15 +46,16 @@ function createCSSElem (fileName) {
}

// CB-8928: When toStaticHTML is undefined, prompt fails to run
var _cleanHtml = function (html) { return html; };
var _cleanHtml = function (html) {
return html;
};
if (typeof toStaticHTML !== 'undefined') {
_cleanHtml = toStaticHTML;
}

// Windows does not provide native UI for promp dialog so we use some
// simple html-based implementation until it is available
function createPromptDialog (title, message, buttons, defaultText, callback) {

var isPhone = cordova.platformId === 'windows' && WinJS.Utilities.isPhone;
var isWindows = !!cordova.platformId.match(/windows/);

Expand All @@ -73,9 +74,11 @@ function createPromptDialog (title, message, buttons, defaultText, callback) {
}

// dialog layout template
dlg.innerHTML = _cleanHtml("<span id='lbl-title'></span><br/>" + // title
dlg.innerHTML = _cleanHtml(
"<span id='lbl-title'></span><br/>" + // title
"<span id='lbl-message'></span><br/>" + // message
"<input id='prompt-input'/><br/>"); // input fields
"<input id='prompt-input'/><br/>"
); // input fields

dlg.querySelector('#lbl-title').appendChild(document.createTextNode(title));
dlg.querySelector('#lbl-message').appendChild(document.createTextNode(message));
Expand All @@ -88,7 +91,8 @@ function createPromptDialog (title, message, buttons, defaultText, callback) {
dlgWrap.parentNode.removeChild(dlgWrap);

if (callback) {
callback({ input1: value, buttonIndex: idx }); // eslint-disable-line standard/no-callback-literal
// eslint-disable-next-line standard/no-callback-literal
callback({ input1: value, buttonIndex: idx });
}
};
}
Expand Down Expand Up @@ -118,7 +122,8 @@ function createPromptDialog (title, message, buttons, defaultText, callback) {
// add Enter/Return key handling
var defaultButton = dlg.querySelector('.dlgButtonFirst');
dlg.addEventListener('keypress', function (e) {
if (e.keyCode === 13) { // enter key
if (e.keyCode === 13) {
// enter key
if (defaultButton) {
defaultButton.click();
}
Expand All @@ -130,7 +135,6 @@ function createPromptDialog (title, message, buttons, defaultText, callback) {

module.exports = {
alert: function (win, loseX, args) {

if (isAlertShowing) {
var later = function () {
module.exports.alert(win, loseX, args);
Expand All @@ -155,7 +159,6 @@ module.exports = {
if (alertStack.length) {
setTimeout(alertStack.shift(), 0);
}

});
},

Expand All @@ -182,7 +185,6 @@ module.exports = {
win(evt);
}
});

} catch (e) {
// set isAlertShowing flag back to false in case of exception
isAlertShowing = false;
Expand All @@ -195,7 +197,6 @@ module.exports = {
},

confirm: function (win, loseX, args) {

if (isAlertShowing) {
var later = function () {
module.exports.confirm(win, loseX, args);
Expand Down Expand Up @@ -226,7 +227,6 @@ module.exports = {
if (alertStack.length) {
setTimeout(alertStack.shift(), 0);
}

});
} catch (e) {
// set isAlertShowing flag back to false in case of exception
Expand All @@ -240,11 +240,10 @@ module.exports = {
},

beep: function (winX, loseX, args) {

// set a default args if it is not set
args = args && args.length ? args : ['1'];

var snd = new Audio('ms-winsoundevent:Notification.Default'); // eslint-disable-line no-undef
var snd = new Audio('ms-winsoundevent:Notification.Default');
var count = parseInt(args[0]) || 1;
snd.msAudioCategory = 'Alerts';

Expand All @@ -262,7 +261,6 @@ module.exports = {
};
snd.addEventListener('ended', onEvent);
onEvent();

}
};

Expand Down
Loading

0 comments on commit 26e6764

Please sign in to comment.