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

refactor(eslint): use cordova-eslint /w fix #141

Merged
merged 1 commit into from
Jul 2, 2020
Merged
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
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 @@ -29,8 +29,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 @@ -42,12 +42,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