Skip to content

Commit 9024275

Browse files
committed
CB-12895 : added eslint and removed jshint
1 parent 7611645 commit 9024275

File tree

12 files changed

+351
-363
lines changed

12 files changed

+351
-363
lines changed

.eslintrc.yml

Lines changed: 10 additions & 0 deletions
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

Lines changed: 0 additions & 16 deletions
This file was deleted.

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
"cordova-firefoxos"
4545
],
4646
"scripts": {
47-
"test": "npm run jshint",
48-
"jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests"
47+
"test": "npm run eslint",
48+
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests"
4949
},
5050
"engines": {
5151
"cordovaDependencies": {
@@ -60,6 +60,12 @@
6060
"author": "Apache Software Foundation",
6161
"license": "Apache-2.0",
6262
"devDependencies": {
63-
"jshint": "^2.6.0"
63+
"eslint": "^4.0.0",
64+
"eslint-config-semistandard": "^11.0.0",
65+
"eslint-config-standard": "^10.2.1",
66+
"eslint-plugin-import": "^2.3.0",
67+
"eslint-plugin-node": "^5.0.0",
68+
"eslint-plugin-promise": "^3.5.0",
69+
"eslint-plugin-standard": "^3.0.1"
6470
}
6571
}

src/browser/InAppBrowserProxy.js

Lines changed: 76 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,43 @@ var browserWrap,
2929
forwardButton,
3030
closeButton;
3131

32-
function attachNavigationEvents(element, callback) {
32+
function attachNavigationEvents (element, callback) {
3333
var onError = function () {
3434
try {
35-
callback({ type: "loaderror", url: this.contentWindow.location.href}, {keepCallback: true});
35+
callback({ type: 'loaderror', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
3636
} catch (err) {
3737
// blocked by CORS :\
38-
callback({ type: "loaderror", url: null}, {keepCallback: true});
38+
callback({ type: 'loaderror', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
3939
}
4040
};
4141

42-
element.addEventListener("pageshow", function () {
42+
element.addEventListener('pageshow', function () {
4343
try {
44-
callback({ type: "loadstart", url: this.contentWindow.location.href}, {keepCallback: true});
44+
callback({ type: 'loadstart', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
4545
} catch (err) {
4646
// blocked by CORS :\
47-
callback({ type: "loadstart", url: null}, {keepCallback: true});
47+
callback({ type: 'loadstart', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
4848
}
4949
});
5050

51-
element.addEventListener("load", function () {
51+
element.addEventListener('load', function () {
5252
try {
53-
callback({ type: "loadstop", url: this.contentWindow.location.href}, {keepCallback: true});
53+
callback({ type: 'loadstop', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
5454
} catch (err) {
5555
// blocked by CORS :\
56-
callback({ type: "loadstop", url: null}, {keepCallback: true});
56+
callback({ type: 'loadstop', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
5757
}
5858
});
5959

60-
element.addEventListener("error", onError);
61-
element.addEventListener("abort", onError);
60+
element.addEventListener('error', onError);
61+
element.addEventListener('abort', onError);
6262
}
6363

6464
var IAB = {
6565
close: function (win, lose) {
6666
if (browserWrap) {
6767
// use the "open" function callback so that the exit event is fired properly
68-
if (IAB._win) IAB._win({ type: "exit" });
68+
if (IAB._win) IAB._win({ type: 'exit' });
6969

7070
browserWrap.parentNode.removeChild(browserWrap);
7171
browserWrap = null;
@@ -75,34 +75,34 @@ var IAB = {
7575

7676
show: function (win, lose) {
7777
if (browserWrap) {
78-
browserWrap.style.display = "block";
78+
browserWrap.style.display = 'block';
7979
}
8080
},
8181

8282
open: function (win, lose, args) {
83-
var strUrl = args[0],
84-
target = args[1],
85-
features = args[2];
83+
var strUrl = args[0];
84+
var target = args[1];
85+
var features = args[2];
8686

8787
IAB._win = win;
8888

89-
if (target === "_self" || !target) {
89+
if (target === '_self' || !target) {
9090
window.location = strUrl;
91-
} else if (target === "_system") {
92-
modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, "_blank");
91+
} else if (target === '_system') {
92+
modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, '_blank');
9393
} else {
9494
// "_blank" or anything else
9595
if (!browserWrap) {
96-
browserWrap = document.createElement("div");
97-
browserWrap.style.position = "absolute";
98-
browserWrap.style.top = "0";
99-
browserWrap.style.left = "0";
100-
browserWrap.style.boxSizing = "border-box";
101-
browserWrap.style.borderWidth = "40px";
102-
browserWrap.style.width = "100vw";
103-
browserWrap.style.height = "100vh";
104-
browserWrap.style.borderStyle = "solid";
105-
browserWrap.style.borderColor = "rgba(0,0,0,0.25)";
96+
browserWrap = document.createElement('div');
97+
browserWrap.style.position = 'absolute';
98+
browserWrap.style.top = '0';
99+
browserWrap.style.left = '0';
100+
browserWrap.style.boxSizing = 'border-box';
101+
browserWrap.style.borderWidth = '40px';
102+
browserWrap.style.width = '100vw';
103+
browserWrap.style.height = '100vh';
104+
browserWrap.style.borderStyle = 'solid';
105+
browserWrap.style.borderColor = 'rgba(0,0,0,0.25)';
106106

107107
browserWrap.onclick = function () {
108108
setTimeout(function () {
@@ -113,71 +113,68 @@ var IAB = {
113113
document.body.appendChild(browserWrap);
114114
}
115115

116-
if (features.indexOf("hidden=yes") !== -1) {
117-
browserWrap.style.display = "none";
116+
if (features.indexOf('hidden=yes') !== -1) {
117+
browserWrap.style.display = 'none';
118118
}
119119

120-
popup = document.createElement("iframe");
121-
popup.style.borderWidth = "0px";
122-
popup.style.width = "100%";
120+
popup = document.createElement('iframe');
121+
popup.style.borderWidth = '0px';
122+
popup.style.width = '100%';
123123

124124
browserWrap.appendChild(popup);
125125

126-
if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) {
127-
popup.style.height = "calc(100% - 60px)";
128-
popup.style.marginBottom = "-4px";
126+
if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) {
127+
popup.style.height = 'calc(100% - 60px)';
128+
popup.style.marginBottom = '-4px';
129129

130-
navigationButtonsDiv = document.createElement("div");
131-
navigationButtonsDiv.style.height = "60px";
132-
navigationButtonsDiv.style.backgroundColor = "#404040";
133-
navigationButtonsDiv.style.zIndex = "999";
130+
navigationButtonsDiv = document.createElement('div');
131+
navigationButtonsDiv.style.height = '60px';
132+
navigationButtonsDiv.style.backgroundColor = '#404040';
133+
navigationButtonsDiv.style.zIndex = '999';
134134
navigationButtonsDiv.onclick = function (e) {
135135
e.cancelBubble = true;
136136
};
137137

138-
navigationButtonsDivInner = document.createElement("div");
139-
navigationButtonsDivInner.style.paddingTop = "10px";
140-
navigationButtonsDivInner.style.height = "50px";
141-
navigationButtonsDivInner.style.width = "160px";
142-
navigationButtonsDivInner.style.margin = "0 auto";
143-
navigationButtonsDivInner.style.backgroundColor = "#404040";
144-
navigationButtonsDivInner.style.zIndex = "999";
138+
navigationButtonsDivInner = document.createElement('div');
139+
navigationButtonsDivInner.style.paddingTop = '10px';
140+
navigationButtonsDivInner.style.height = '50px';
141+
navigationButtonsDivInner.style.width = '160px';
142+
navigationButtonsDivInner.style.margin = '0 auto';
143+
navigationButtonsDivInner.style.backgroundColor = '#404040';
144+
navigationButtonsDivInner.style.zIndex = '999';
145145
navigationButtonsDivInner.onclick = function (e) {
146146
e.cancelBubble = true;
147147
};
148148

149+
backButton = document.createElement('button');
150+
backButton.style.width = '40px';
151+
backButton.style.height = '40px';
152+
backButton.style.borderRadius = '40px';
149153

150-
backButton = document.createElement("button");
151-
backButton.style.width = "40px";
152-
backButton.style.height = "40px";
153-
backButton.style.borderRadius = "40px";
154-
155-
backButton.innerHTML = "←";
156-
backButton.addEventListener("click", function (e) {
157-
if (popup.canGoBack)
158-
popup.goBack();
154+
backButton.innerHTML = '←';
155+
backButton.addEventListener('click', function (e) {
156+
if (popup.canGoBack) { popup.goBack(); }
159157
});
160158

161-
forwardButton = document.createElement("button");
162-
forwardButton.style.marginLeft = "20px";
163-
forwardButton.style.width = "40px";
164-
forwardButton.style.height = "40px";
165-
forwardButton.style.borderRadius = "40px";
159+
forwardButton = document.createElement('button');
160+
forwardButton.style.marginLeft = '20px';
161+
forwardButton.style.width = '40px';
162+
forwardButton.style.height = '40px';
163+
forwardButton.style.borderRadius = '40px';
166164

167-
forwardButton.innerHTML = "→";
168-
forwardButton.addEventListener("click", function (e) {
169-
if (popup.canGoForward)
170-
popup.goForward();
165+
forwardButton.innerHTML = '→';
166+
forwardButton.addEventListener('click', function (e) {
167+
if (popup.canGoForward) { popup.goForward(); }
171168
});
172169

173-
closeButton = document.createElement("button");
174-
closeButton.style.marginLeft = "20px";
175-
closeButton.style.width = "40px";
176-
closeButton.style.height = "40px";
177-
closeButton.style.borderRadius = "40px";
170+
closeButton = document.createElement('button');
171+
closeButton.style.marginLeft = '20px';
172+
closeButton.style.width = '40px';
173+
closeButton.style.height = '40px';
174+
closeButton.style.borderRadius = '40px';
178175

179-
closeButton.innerHTML = "✖";
180-
closeButton.addEventListener("click", function (e) {
176+
closeButton.innerHTML = '✖';
177+
closeButton.addEventListener('click', function (e) {
181178
setTimeout(function () {
182179
IAB.close();
183180
}, 0);
@@ -194,7 +191,7 @@ var IAB = {
194191

195192
browserWrap.appendChild(navigationButtonsDiv);
196193
} else {
197-
popup.style.height = "100%";
194+
popup.style.height = '100%';
198195
}
199196

200197
// start listening for navigation events
@@ -205,16 +202,16 @@ var IAB = {
205202
},
206203

207204
injectScriptCode: function (win, fail, args) {
208-
var code = args[0],
209-
hasCallback = args[1];
205+
var code = args[0];
206+
var hasCallback = args[1];
210207

211208
if (browserWrap && popup) {
212209
try {
213210
popup.contentWindow.eval(code);
214211
if (hasCallback) {
215212
win([]);
216213
}
217-
} catch(e) {
214+
} catch (e) {
218215
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
219216
}
220217
}
@@ -226,7 +223,7 @@ var IAB = {
226223
if (fail) {
227224
fail(msg);
228225
}
229-
},
226+
},
230227

231228
injectStyleCode: function (win, fail, args) {
232229
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
@@ -247,4 +244,4 @@ var IAB = {
247244

248245
module.exports = IAB;
249246

250-
require("cordova/exec/proxy").add("InAppBrowser", module.exports);
247+
require('cordova/exec/proxy').add('InAppBrowser', module.exports);

0 commit comments

Comments
 (0)