mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-12 01:26:23 +02:00
eslint fixes
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
"env": {
|
"env": {
|
||||||
"browser": true
|
"browser": true
|
||||||
},
|
},
|
||||||
|
"parser": "babel-eslint",
|
||||||
"extends": "eslint:recommended",
|
"extends": "eslint:recommended",
|
||||||
"rules": {
|
"rules": {
|
||||||
"accessor-pairs": "error",
|
"accessor-pairs": "error",
|
||||||
@ -96,7 +97,7 @@
|
|||||||
"no-extra-label": "error",
|
"no-extra-label": "error",
|
||||||
"no-extra-parens": "off",
|
"no-extra-parens": "off",
|
||||||
"no-floating-decimal": "error",
|
"no-floating-decimal": "error",
|
||||||
"no-implicit-coercion": "error",
|
"no-implicit-coercion": "off",
|
||||||
"no-implicit-globals": "off",
|
"no-implicit-globals": "off",
|
||||||
"no-implied-eval": "error",
|
"no-implied-eval": "error",
|
||||||
"no-inline-comments": "off",
|
"no-inline-comments": "off",
|
||||||
@ -262,6 +263,7 @@
|
|||||||
"esprima": true,
|
"esprima": true,
|
||||||
"escodegen": true,
|
"escodegen": true,
|
||||||
"utils": true,
|
"utils": true,
|
||||||
"Promise": true
|
"Promise": true,
|
||||||
|
"Inlet": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- '4.0'
|
- '6.0'
|
||||||
install:
|
install:
|
||||||
- npm install -g eslint
|
- npm install -g eslint
|
||||||
|
- npm install -g babel-eslint
|
||||||
script:
|
script:
|
||||||
- eslint src/*.js
|
- eslint src/*.js
|
@ -1,3 +1,5 @@
|
|||||||
|
/* global ga */
|
||||||
|
// eslint-disable-next-line max-params
|
||||||
window.trackEvent = function (category, action, label, value) {
|
window.trackEvent = function (category, action, label, value) {
|
||||||
if (window.DEBUG) {
|
if (window.DEBUG) {
|
||||||
utils.log('trackevent', category, action, label, value)
|
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 online, load after 2 seconds
|
||||||
if (navigator.onLine && !window.DEBUG) {
|
if (navigator.onLine && !window.DEBUG) {
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
(function(i,s,o,g,r,a,m){
|
(function(i,s,o,g,r,a,m){
|
||||||
i['GoogleAnalyticsObject']=r;
|
i['GoogleAnalyticsObject']=r;
|
||||||
@ -23,4 +27,6 @@ if (navigator.onLine && !window.DEBUG) {
|
|||||||
ga('set', 'checkProtocolTask', function(){ /* nothing */ });
|
ga('set', 'checkProtocolTask', function(){ /* nothing */ });
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
/* eslint-enable */
|
||||||
}
|
}
|
@ -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://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/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/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' }
|
||||||
]
|
]
|
@ -1,3 +1,4 @@
|
|||||||
|
/* global trackEvent */
|
||||||
/* eslint-disable no-extra-semi */
|
/* eslint-disable no-extra-semi */
|
||||||
;(function (alertsService) {
|
;(function (alertsService) {
|
||||||
|
|
||||||
@ -107,7 +108,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetSplitting(dontRecreate) {
|
function resetSplitting() {
|
||||||
if (codeSplitInstance) {
|
if (codeSplitInstance) {
|
||||||
codeSplitInstance.destroy();
|
codeSplitInstance.destroy();
|
||||||
}
|
}
|
||||||
@ -170,8 +171,8 @@
|
|||||||
function updateExternalLibUi() {
|
function updateExternalLibUi() {
|
||||||
// Calculate no. of external libs
|
// Calculate no. of external libs
|
||||||
var noOfExternalLibs = 0;
|
var noOfExternalLibs = 0;
|
||||||
noOfExternalLibs += externalJsTextarea.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;
|
noOfExternalLibs += externalCssTextarea.value.split('\n').filter((lib) => !!lib).length;
|
||||||
if (noOfExternalLibs) {
|
if (noOfExternalLibs) {
|
||||||
$('#js-external-lib-count').textContent = noOfExternalLibs;
|
$('#js-external-lib-count').textContent = noOfExternalLibs;
|
||||||
$('#js-external-lib-count').style.display = 'inline';
|
$('#js-external-lib-count').style.display = 'inline';
|
||||||
@ -223,11 +224,11 @@
|
|||||||
var sizes;
|
var sizes;
|
||||||
try {
|
try {
|
||||||
sizes = [
|
sizes = [
|
||||||
+htmlCode.style[dimensionProperty].match(/([\d\.]+)%/)[1],
|
+htmlCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
|
||||||
+cssCode.style[dimensionProperty].match(/([\d\.]+)%/)[1],
|
+cssCode.style[dimensionProperty].match(/([\d.]+)%/)[1],
|
||||||
+jsCode.style[dimensionProperty].match(/([\d\.]+)%/)[1]
|
+jsCode.style[dimensionProperty].match(/([\d.]+)%/)[1]
|
||||||
];
|
];
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
sizes = [ 33.33, 33.33, 33.33 ]
|
sizes = [ 33.33, 33.33, 33.33 ]
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
@ -279,17 +280,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
savedItems = savedItems || [];
|
savedItems = savedItems || [];
|
||||||
for (var i = 0; i < itemIds.length; i++) {
|
for (let i = 0; i < itemIds.length; i++) {
|
||||||
(function (index) {
|
|
||||||
chrome.storage.local.get(itemIds[index], function (itemResult) {
|
/* eslint-disable no-loop-func */
|
||||||
savedItems[itemIds[index]] = itemResult[itemIds[index]];
|
chrome.storage.local.get(itemIds[i], function (itemResult) {
|
||||||
items.push(itemResult[itemIds[index]]);
|
savedItems[itemIds[i]] = itemResult[itemIds[i]];
|
||||||
// Check if we have all items now.
|
items.push(itemResult[itemIds[i]]);
|
||||||
if (itemIds.length === items.length) {
|
// Check if we have all items now.
|
||||||
populateItemsInSavedPane(items);
|
if (itemIds.length === items.length) {
|
||||||
}
|
populateItemsInSavedPane(items);
|
||||||
});
|
}
|
||||||
})(i);
|
});
|
||||||
|
|
||||||
|
/* eslint-enable no-loop-func */
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -526,11 +529,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCompleteHtml(html, css, js) {
|
function getCompleteHtml(html, css, js) {
|
||||||
var externalJs = externalJsTextarea.value.split('\n').reduce(function (html, url) {
|
var externalJs = externalJsTextarea.value.split('\n').reduce(function (scripts, url) {
|
||||||
return html + (url ? '\n<script src="' + url + '"></script>' : '');
|
return scripts + (url ? '\n<script src="' + url + '"></script>' : '');
|
||||||
}, '');
|
}, '');
|
||||||
var externalCss = externalCssTextarea.value.split('\n').reduce(function (html, url) {
|
var externalCss = externalCssTextarea.value.split('\n').reduce(function (links, url) {
|
||||||
return html + (url ? '\n<link rel="stylesheet" href="' + url + '"></link>' : '');
|
return links + (url ? '\n<link rel="stylesheet" href="' + url + '"></link>' : '');
|
||||||
}, '');
|
}, '');
|
||||||
var contents = '<html>\n<head>\n'
|
var contents = '<html>\n<head>\n'
|
||||||
+ externalCss + '\n'
|
+ externalCss + '\n'
|
||||||
|
10
src/utils.js
10
src/utils.js
@ -21,9 +21,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function generateRandomId(len) {
|
function generateRandomId(len) {
|
||||||
len = len || 10;
|
var length = len || 10;
|
||||||
var id = '';
|
var id = '';
|
||||||
for (var i = len; i--;) {
|
for (var i = length; i--;) {
|
||||||
id += alphaNum[~~(Math.random() * alphaNum.length)];
|
id += alphaNum[~~(Math.random() * alphaNum.length)];
|
||||||
}
|
}
|
||||||
return id;
|
return id;
|
||||||
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
function log() {
|
function log() {
|
||||||
if (window.DEBUG) {
|
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
|
* @param {ASTBody} Body of an AST generated by esprima or any ES compliant AST
|
||||||
*/
|
*/
|
||||||
function addInfiniteLoopProtection(astBody) {
|
function addInfiniteLoopProtection(astBody) {
|
||||||
if (!astBody) return;
|
if (!astBody) { return; }
|
||||||
if (!Array.isArray(astBody)) {
|
if (!Array.isArray(astBody)) {
|
||||||
addInfiniteLoopProtection(astBody.body);
|
addInfiniteLoopProtection(astBody.body);
|
||||||
return;
|
return;
|
||||||
@ -95,7 +95,7 @@
|
|||||||
var retVal = d.getDate() + ' '
|
var retVal = d.getDate() + ' '
|
||||||
+ [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][d.getMonth()] + ' '
|
+ [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][d.getMonth()] + ' '
|
||||||
+ d.getFullYear();
|
+ d.getFullYear();
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.utils = {
|
window.utils = {
|
||||||
|
Reference in New Issue
Block a user