1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-25 07:51:12 +02:00

eslint fixes

This commit is contained in:
Kushagra Gour
2016-12-04 04:08:38 +05:30
parent 888a4c73bb
commit 9ca891f7d0
6 changed files with 43 additions and 31 deletions

View File

@@ -1,3 +1,5 @@
/* global ga */
// eslint-disable-next-line max-params
window.trackEvent = function (category, action, label, value) {
if (window.DEBUG) {
utils.log('trackevent', category, action, label, value)
@@ -10,6 +12,8 @@ window.trackEvent = function (category, action, label, value) {
// if online, load after 2 seconds
if (navigator.onLine && !window.DEBUG) {
/* eslint-disable */
setTimeout(function() {
(function(i,s,o,g,r,a,m){
i['GoogleAnalyticsObject']=r;
@@ -23,4 +27,6 @@ if (navigator.onLine && !window.DEBUG) {
ga('set', 'checkProtocolTask', function(){ /* nothing */ });
ga('send', 'pageview');
}, 0);
/* eslint-enable */
}

View File

@@ -12,5 +12,5 @@ window.cssLibs = [
{ url: 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', label: 'Bootstrap', type: 'css' },
{ url: 'https://cdnjs.cloudflare.com/ajax/libs/foundation/6.2.3/foundation.min.css', label: 'Foundation', type: 'css' },
{ url: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css', label: 'Animate.css', type: 'css' },
{ url: 'https://cdnjs.cloudflare.com/ajax/libs/hint.css/2.4.1/hint.min.css', label: 'Hint.css', type: 'css'}
{ url: 'https://cdnjs.cloudflare.com/ajax/libs/hint.css/2.4.1/hint.min.css', label: 'Hint.css', type: 'css' }
]

View File

@@ -1,3 +1,4 @@
/* global trackEvent */
/* eslint-disable no-extra-semi */
;(function (alertsService) {
@@ -107,7 +108,7 @@
}
}
function resetSplitting(dontRecreate) {
function resetSplitting() {
if (codeSplitInstance) {
codeSplitInstance.destroy();
}
@@ -170,8 +171,8 @@
function updateExternalLibUi() {
// Calculate no. of external libs
var noOfExternalLibs = 0;
noOfExternalLibs += externalJsTextarea.value.split('\n').filter(lib => !!lib).length;
noOfExternalLibs += externalCssTextarea.value.split('\n').filter(lib => !!lib).length;
noOfExternalLibs += externalJsTextarea.value.split('\n').filter((lib) => !!lib).length;
noOfExternalLibs += externalCssTextarea.value.split('\n').filter((lib) => !!lib).length;
if (noOfExternalLibs) {
$('#js-external-lib-count').textContent = noOfExternalLibs;
$('#js-external-lib-count').style.display = 'inline';
@@ -223,11 +224,11 @@
var sizes;
try {
sizes = [
+htmlCode.style[dimensionProperty].match(/([\d\.]+)%/)[1],
+cssCode.style[dimensionProperty].match(/([\d\.]+)%/)[1],
+jsCode.style[dimensionProperty].match(/([\d\.]+)%/)[1]
+htmlCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
+cssCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
+jsCode.style[dimensionProperty].match(/([\d.]+)%/)[1]
];
} catch(e) {
} catch (e) {
sizes = [ 33.33, 33.33, 33.33 ]
} finally {
@@ -279,17 +280,19 @@
}
savedItems = savedItems || [];
for (var i = 0; i < itemIds.length; i++) {
(function (index) {
chrome.storage.local.get(itemIds[index], function (itemResult) {
savedItems[itemIds[index]] = itemResult[itemIds[index]];
items.push(itemResult[itemIds[index]]);
// Check if we have all items now.
if (itemIds.length === items.length) {
populateItemsInSavedPane(items);
}
});
})(i);
for (let i = 0; i < itemIds.length; i++) {
/* eslint-disable no-loop-func */
chrome.storage.local.get(itemIds[i], function (itemResult) {
savedItems[itemIds[i]] = itemResult[itemIds[i]];
items.push(itemResult[itemIds[i]]);
// Check if we have all items now.
if (itemIds.length === items.length) {
populateItemsInSavedPane(items);
}
});
/* eslint-enable no-loop-func */
}
});
}
@@ -526,11 +529,11 @@
}
function getCompleteHtml(html, css, js) {
var externalJs = externalJsTextarea.value.split('\n').reduce(function (html, url) {
return html + (url ? '\n<script src="' + url + '"></script>' : '');
var externalJs = externalJsTextarea.value.split('\n').reduce(function (scripts, url) {
return scripts + (url ? '\n<script src="' + url + '"></script>' : '');
}, '');
var externalCss = externalCssTextarea.value.split('\n').reduce(function (html, url) {
return html + (url ? '\n<link rel="stylesheet" href="' + url + '"></link>' : '');
var externalCss = externalCssTextarea.value.split('\n').reduce(function (links, url) {
return links + (url ? '\n<link rel="stylesheet" href="' + url + '"></link>' : '');
}, '');
var contents = '<html>\n<head>\n'
+ externalCss + '\n'

View File

@@ -21,9 +21,9 @@
}
function generateRandomId(len) {
len = len || 10;
var length = len || 10;
var id = '';
for (var i = len; i--;) {
for (var i = length; i--;) {
id += alphaNum[~~(Math.random() * alphaNum.length)];
}
return id;
@@ -38,7 +38,7 @@
function log() {
if (window.DEBUG) {
console.log.apply(console, [].splice.call(arguments, 0));
console.log(...arguments);
}
}
@@ -58,7 +58,7 @@
* @param {ASTBody} Body of an AST generated by esprima or any ES compliant AST
*/
function addInfiniteLoopProtection(astBody) {
if (!astBody) return;
if (!astBody) { return; }
if (!Array.isArray(astBody)) {
addInfiniteLoopProtection(astBody.body);
return;
@@ -95,7 +95,7 @@
var retVal = d.getDate() + ' '
+ [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][d.getMonth()] + ' '
+ d.getFullYear();
return retVal;
return retVal;
}
window.utils = {