Skip to content

Commit 9ca891f

Browse files
committed
eslint fixes
1 parent 888a4c7 commit 9ca891f

File tree

6 files changed

+43
-31
lines changed

6 files changed

+43
-31
lines changed

.eslintrc.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"env": {
33
"browser": true
44
},
5+
"parser": "babel-eslint",
56
"extends": "eslint:recommended",
67
"rules": {
78
"accessor-pairs": "error",
@@ -96,7 +97,7 @@
9697
"no-extra-label": "error",
9798
"no-extra-parens": "off",
9899
"no-floating-decimal": "error",
99-
"no-implicit-coercion": "error",
100+
"no-implicit-coercion": "off",
100101
"no-implicit-globals": "off",
101102
"no-implied-eval": "error",
102103
"no-inline-comments": "off",
@@ -262,6 +263,7 @@
262263
"esprima": true,
263264
"escodegen": true,
264265
"utils": true,
265-
"Promise": true
266+
"Promise": true,
267+
"Inlet": true
266268
}
267269
}

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
language: node_js
22
node_js:
3-
- '4.0'
3+
- '6.0'
44
install:
55
- npm install -g eslint
6+
- npm install -g babel-eslint
67
script:
78
- eslint src/*.js

src/analytics.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global ga */
2+
// eslint-disable-next-line max-params
13
window.trackEvent = function (category, action, label, value) {
24
if (window.DEBUG) {
35
utils.log('trackevent', category, action, label, value)
@@ -10,6 +12,8 @@ window.trackEvent = function (category, action, label, value) {
1012

1113
// if online, load after 2 seconds
1214
if (navigator.onLine && !window.DEBUG) {
15+
/* eslint-disable */
16+
1317
setTimeout(function() {
1418
(function(i,s,o,g,r,a,m){
1519
i['GoogleAnalyticsObject']=r;
@@ -23,4 +27,6 @@ if (navigator.onLine && !window.DEBUG) {
2327
ga('set', 'checkProtocolTask', function(){ /* nothing */ });
2428
ga('send', 'pageview');
2529
}, 0);
30+
31+
/* eslint-enable */
2632
}

src/library-list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ window.cssLibs = [
1212
{ url: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', label: 'Bootstrap', type: 'css' },
1313
{ url: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/6.2.3/foundation.min.css', label: 'Foundation', type: 'css' },
1414
{ url: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css', label: 'Animate.css', type: 'css' },
15-
{ url: 'https://cdnjs.cloudflare.com/ajax/libs/hint.css/2.4.1/hint.min.css', label: 'Hint.css', type: 'css'}
15+
{ url: 'https://cdnjs.cloudflare.com/ajax/libs/hint.css/2.4.1/hint.min.css', label: 'Hint.css', type: 'css' }
1616
]

src/script.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* global trackEvent */
12
/* eslint-disable no-extra-semi */
23
;(function (alertsService) {
34

@@ -107,7 +108,7 @@
107108
}
108109
}
109110

110-
function resetSplitting(dontRecreate) {
111+
function resetSplitting() {
111112
if (codeSplitInstance) {
112113
codeSplitInstance.destroy();
113114
}
@@ -170,8 +171,8 @@
170171
function updateExternalLibUi() {
171172
// Calculate no. of external libs
172173
var noOfExternalLibs = 0;
173-
noOfExternalLibs += externalJsTextarea.value.split('\n').filter(lib => !!lib).length;
174-
noOfExternalLibs += externalCssTextarea.value.split('\n').filter(lib => !!lib).length;
174+
noOfExternalLibs += externalJsTextarea.value.split('\n').filter((lib) => !!lib).length;
175+
noOfExternalLibs += externalCssTextarea.value.split('\n').filter((lib) => !!lib).length;
175176
if (noOfExternalLibs) {
176177
$('#js-external-lib-count').textContent = noOfExternalLibs;
177178
$('#js-external-lib-count').style.display = 'inline';
@@ -223,11 +224,11 @@
223224
var sizes;
224225
try {
225226
sizes = [
226-
+htmlCode.style[dimensionProperty].match(/([\d\.]+)%/)[1],
227-
+cssCode.style[dimensionProperty].match(/([\d\.]+)%/)[1],
228-
+jsCode.style[dimensionProperty].match(/([\d\.]+)%/)[1]
227+
+htmlCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
228+
+cssCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
229+
+jsCode.style[dimensionProperty].match(/([\d.]+)%/)[1]
229230
];
230-
} catch(e) {
231+
} catch (e) {
231232
sizes = [ 33.33, 33.33, 33.33 ]
232233
} finally {
233234

@@ -279,17 +280,19 @@
279280
}
280281

281282
savedItems = savedItems || [];
282-
for (var i = 0; i < itemIds.length; i++) {
283-
(function (index) {
284-
chrome.storage.local.get(itemIds[index], function (itemResult) {
285-
savedItems[itemIds[index]] = itemResult[itemIds[index]];
286-
items.push(itemResult[itemIds[index]]);
287-
// Check if we have all items now.
288-
if (itemIds.length === items.length) {
289-
populateItemsInSavedPane(items);
290-
}
291-
});
292-
})(i);
283+
for (let i = 0; i < itemIds.length; i++) {
284+
285+
/* eslint-disable no-loop-func */
286+
chrome.storage.local.get(itemIds[i], function (itemResult) {
287+
savedItems[itemIds[i]] = itemResult[itemIds[i]];
288+
items.push(itemResult[itemIds[i]]);
289+
// Check if we have all items now.
290+
if (itemIds.length === items.length) {
291+
populateItemsInSavedPane(items);
292+
}
293+
});
294+
295+
/* eslint-enable no-loop-func */
293296
}
294297
});
295298
}
@@ -526,11 +529,11 @@
526529
}
527530

528531
function getCompleteHtml(html, css, js) {
529-
var externalJs = externalJsTextarea.value.split('\n').reduce(function (html, url) {
530-
return html + (url ? '\n<script src="' + url + '"></script>' : '');
532+
var externalJs = externalJsTextarea.value.split('\n').reduce(function (scripts, url) {
533+
return scripts + (url ? '\n<script src="' + url + '"></script>' : '');
531534
}, '');
532-
var externalCss = externalCssTextarea.value.split('\n').reduce(function (html, url) {
533-
return html + (url ? '\n<link rel="stylesheet" href="' + url + '"></link>' : '');
535+
var externalCss = externalCssTextarea.value.split('\n').reduce(function (links, url) {
536+
return links + (url ? '\n<link rel="stylesheet" href="' + url + '"></link>' : '');
534537
}, '');
535538
var contents = '<html>\n<head>\n'
536539
+ externalCss + '\n'

src/utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
}
2222

2323
function generateRandomId(len) {
24-
len = len || 10;
24+
var length = len || 10;
2525
var id = '';
26-
for (var i = len; i--;) {
26+
for (var i = length; i--;) {
2727
id += alphaNum[~~(Math.random() * alphaNum.length)];
2828
}
2929
return id;
@@ -38,7 +38,7 @@
3838

3939
function log() {
4040
if (window.DEBUG) {
41-
console.log.apply(console, [].splice.call(arguments, 0));
41+
console.log(...arguments);
4242
}
4343
}
4444

@@ -58,7 +58,7 @@
5858
* @param {ASTBody} Body of an AST generated by esprima or any ES compliant AST
5959
*/
6060
function addInfiniteLoopProtection(astBody) {
61-
if (!astBody) return;
61+
if (!astBody) { return; }
6262
if (!Array.isArray(astBody)) {
6363
addInfiniteLoopProtection(astBody.body);
6464
return;
@@ -95,7 +95,7 @@
9595
var retVal = d.getDate() + ' '
9696
+ [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][d.getMonth()] + ' '
9797
+ d.getFullYear();
98-
return retVal;
98+
return retVal;
9999
}
100100

101101
window.utils = {

0 commit comments

Comments
 (0)