Skip to content

Commit 0b532b6

Browse files
committed
CB-12895 : setup eslint and removed jshint
1 parent 8225941 commit 0b532b6

File tree

11 files changed

+208
-219
lines changed

11 files changed

+208
-219
lines changed

.eslintrc.yml

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root: true
2+
extends: semistandard
3+
rules:
4+
indent:
5+
- error
6+
- 4
7+
camelcase: off
8+
padded-blocks: off
9+
operator-linebreak: off
10+
no-throw-literal: off

.jshintrc

-17
This file was deleted.

package.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"cordova-windows"
4444
],
4545
"scripts": {
46-
"test": "npm run jshint",
47-
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
46+
"test": "npm run eslint",
47+
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests"
4848
},
4949
"author": "Apache Software Foundation",
5050
"license": "Apache-2.0",
@@ -56,6 +56,12 @@
5656
}
5757
},
5858
"devDependencies": {
59-
"jshint": "^2.6.0"
59+
"eslint": "^3.19.0",
60+
"eslint-config-semistandard": "^11.0.0",
61+
"eslint-config-standard": "^10.2.1",
62+
"eslint-plugin-import": "^2.3.0",
63+
"eslint-plugin-node": "^5.0.0",
64+
"eslint-plugin-promise": "^3.5.0",
65+
"eslint-plugin-standard": "^3.0.1"
6066
}
6167
}

src/blackberry10/index.js

+25-25
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,41 @@
1616

1717
/* global qnx, PluginResult */
1818

19-
function showDialog(args, dialogType, result) {
20-
//Unpack and map the args
21-
var msg = JSON.parse(decodeURIComponent(args[0])),
22-
title = JSON.parse(decodeURIComponent(args[1])),
23-
btnLabel = JSON.parse(decodeURIComponent(args[2]));
19+
function showDialog (args, dialogType, result) {
20+
// Unpack and map the args
21+
var msg = JSON.parse(decodeURIComponent(args[0]));
22+
var title = JSON.parse(decodeURIComponent(args[1]));
23+
var btnLabel = JSON.parse(decodeURIComponent(args[2]));
2424

2525
if (!Array.isArray(btnLabel)) {
26-
//Converts to array for (string) and (string,string, ...) cases
27-
btnLabel = btnLabel.split(",");
26+
// Converts to array for (string) and (string,string, ...) cases
27+
btnLabel = btnLabel.split(',');
2828
}
2929

30-
if (msg && typeof msg === "string") {
31-
msg = msg.replace(/^"|"$/g, "").replace(/\\"/g, '"');
30+
if (msg && typeof msg === 'string') {
31+
msg = msg.replace(/^"|"$/g, '').replace(/\\"/g, '"');
3232
} else {
33-
result.error("message is undefined");
33+
result.error('message is undefined');
3434
return;
3535
}
3636

3737
var messageObj = {
38-
title : title,
39-
htmlmessage : msg,
40-
dialogType : dialogType,
41-
optionalButtons : btnLabel
38+
title: title,
39+
htmlmessage: msg,
40+
dialogType: dialogType,
41+
optionalButtons: btnLabel
4242
};
4343

44-
//TODO replace with getOverlayWebview() when available in webplatform
44+
// TODO replace with getOverlayWebview() when available in webplatform
4545
qnx.webplatform.getWebViews()[2].dialog.show(messageObj, function (data) {
46-
if (typeof data === "number") {
47-
//Confirm dialog call back needs to be called with one-based indexing [1,2,3 etc]
46+
if (typeof data === 'number') {
47+
// Confirm dialog call back needs to be called with one-based indexing [1,2,3 etc]
4848
result.callbackOk(++data, false);
4949
} else {
50-
//Prompt dialog callback expects object
50+
// Prompt dialog callback expects object
5151
result.callbackOk({
5252
buttonIndex: data.ok ? 1 : 0,
53-
input1: (data.oktext) ? decodeURIComponent(data.oktext) : ""
53+
input1: (data.oktext) ? decodeURIComponent(data.oktext) : ''
5454
}, false);
5555
}
5656
});
@@ -63,27 +63,27 @@ module.exports = {
6363
var result = new PluginResult(args, env);
6464

6565
if (Object.keys(args).length < 3) {
66-
result.error("Notification action - alert arguments not found.");
66+
result.error('Notification action - alert arguments not found.');
6767
} else {
68-
showDialog(args, "CustomAsk", result);
68+
showDialog(args, 'CustomAsk', result);
6969
}
7070
},
7171
confirm: function (success, fail, args, env) {
7272
var result = new PluginResult(args, env);
7373

7474
if (Object.keys(args).length < 3) {
75-
result.error("Notification action - confirm arguments not found.");
75+
result.error('Notification action - confirm arguments not found.');
7676
} else {
77-
showDialog(args, "CustomAsk", result);
77+
showDialog(args, 'CustomAsk', result);
7878
}
7979
},
8080
prompt: function (success, fail, args, env) {
8181
var result = new PluginResult(args, env);
8282

8383
if (Object.keys(args).length < 3) {
84-
result.error("Notification action - prompt arguments not found.");
84+
result.error('Notification action - prompt arguments not found.');
8585
} else {
86-
showDialog(args, "JavaScriptPrompt", result);
86+
showDialog(args, 'JavaScriptPrompt', result);
8787
}
8888
}
8989
};

src/firefoxos/notification.js

+27-31
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@
2121

2222
var modulemapper = require('cordova/modulemapper');
2323

24-
2524
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'window.open');
2625

26+
function _empty () {}
2727

28-
function _empty() {}
29-
30-
31-
function modal(message, callback, title, buttonLabels, domObjects) {
28+
function modal (message, callback, title, buttonLabels, domObjects) {
3229
var mainWindow = window;
3330
var modalWindow = origOpenFunc();
3431
var modalDocument = modalWindow.document;
@@ -61,78 +58,78 @@ function modal(message, callback, title, buttonLabels, domObjects) {
6158
box.appendChild(menu);
6259
for (var index = 0; index < buttonLabels.length; index++) {
6360
// TODO: last button listens to the cancel key
64-
addButton(buttonLabels[index], (index+1), (index === 0));
61+
addButton(buttonLabels[index], (index + 1), (index === 0));
6562
}
6663
modalDocument.body.appendChild(box);
6764

68-
function addButton(label, index, recommended) {
65+
function addButton (label, index, recommended) {
6966
var thisButtonCallback = makeCallbackButton(index + 1);
7067
var button = modalDocument.createElement('button');
7168
button.appendChild(modalDocument.createTextNode(label));
7269
button.addEventListener('click', thisButtonCallback, false);
7370
if (recommended) {
7471
// TODO: default one listens to Enter key
75-
button.classList.add('recommend');
72+
button.classList.add('recommend');
7673
}
7774
menu.appendChild(button);
7875
}
7976

8077
// TODO: onUnload listens to the cancel key
81-
function onUnload() {
78+
function onUnload () {
8279
var result = 0;
8380
if (modalDocument.getElementById('prompt-input')) {
8481
result = {
8582
input1: '',
8683
buttonIndex: 0
8784
};
8885
}
89-
mainWindow.setTimeout(function() {
86+
mainWindow.setTimeout(function () {
9087
callback(result);
9188
}, 10);
9289
}
9390
modalWindow.addEventListener('unload', onUnload, false);
9491

9592
// call callback and destroy modal
96-
function makeCallbackButton(labelIndex) {
97-
return function() {
98-
if (modalWindow) {
99-
modalWindow.removeEventListener('unload', onUnload, false);
100-
modalWindow.close();
101-
}
93+
function makeCallbackButton (labelIndex) {
94+
return function () {
95+
if (modalWindow) {
96+
modalWindow.removeEventListener('unload', onUnload, false);
97+
modalWindow.close();
98+
}
10299
// checking if prompt
103-
var promptInput = modalDocument.getElementById('prompt-input');
104-
var response;
105-
if (promptInput) {
106-
response = {
107-
input1: promptInput.value,
108-
buttonIndex: labelIndex
109-
};
110-
}
111-
response = response || labelIndex;
112-
callback(response);
100+
var promptInput = modalDocument.getElementById('prompt-input');
101+
var response;
102+
if (promptInput) {
103+
response = {
104+
input1: promptInput.value,
105+
buttonIndex: labelIndex
106+
};
107+
}
108+
response = response || labelIndex;
109+
callback(response);
113110
};
114111
}
115112
}
116113

117114
var Notification = {
118-
vibrate: function(milliseconds) {
115+
vibrate: function (milliseconds) {
119116
navigator.vibrate(milliseconds);
120117
},
121-
alert: function(successCallback, errorCallback, args) {
118+
alert: function (successCallback, errorCallback, args) {
122119
var message = args[0];
123120
var title = args[1];
124121
var _buttonLabels = [args[2]];
125122
var _callback = (successCallback || _empty);
126123
modal(message, _callback, title, _buttonLabels);
127124
},
128-
confirm: function(successCallback, errorCallback, args) {
125+
confirm: function (successCallback, errorCallback, args) {
129126
var message = args[0];
130127
var title = args[1];
131128
var buttonLabels = args[2];
132129
var _callback = (successCallback || _empty);
133130
modal(message, _callback, title, buttonLabels);
134131
},
135-
prompt: function(successCallback, errorCallback, args) {
132+
prompt: function (successCallback, errorCallback, args) {
136133
var message = args[0];
137134
var title = args[1];
138135
var buttonLabels = args[2];
@@ -150,6 +147,5 @@ var Notification = {
150147
}
151148
};
152149

153-
154150
module.exports = Notification;
155151
require('cordova/exec/proxy').add('Notification', Notification);

0 commit comments

Comments
 (0)