added eslint

This commit is contained in:
Robert Clarke 2019-05-08 12:04:57 +01:00
parent 6a19102b82
commit 16c1eb212a
6 changed files with 783 additions and 34 deletions

17
javascript/.eslintrc.js Normal file
View file

@ -0,0 +1,17 @@
module.exports = {
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
}
};

View file

@ -3,6 +3,13 @@
"@babel/core": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"babel-loader": "^8.0.5",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-node": "^9.0.1",
"eslint-plugin-promise": "^4.1.1",
"eslint-plugin-standard": "^4.0.0",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.2"
}

View file

@ -1,3 +1,5 @@
/* eslint-disable */
function debounce(func, wait) {
var timeout;

View file

@ -35,7 +35,7 @@
}
saveTheme(themeName);
};
}
/* Removes all current stylesheets on the page */
function removeStylesheets() {
@ -57,7 +57,7 @@
previousLink = null;
//make body visible again if it was hidden
showBody();
};
}
function onLinkError() {
//remove event listeners
@ -77,22 +77,23 @@
setThemeSelect(document.querySelectorAll(`.${STYLESHEET_CLASSNAME}`)[0].id)
//make body visible again if it was hidden
showBody();
};
}
/* Saves the current theme in localstorage */
function saveTheme(themeName) {
localStorage.setItem(THEME_KEY, themeName);
};
}
/* Clears the current theme in localstorage */
function clearTheme() {
localStorage.removeItem(THEME_KEY);
};
}
/* Hides the body of the page */
function hideBody() {
var head = document.getElementsByTagName('head')[0];
var style = document.createElement('style');
let head = document.getElementsByTagName('head')[0];
let style = document.createElement('style');
let css = 'body{visibility:hidden;}';
style.id = STOP_BLINK_CSS_ID;
style.setAttribute('type', 'text/css');
@ -100,17 +101,17 @@
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode('body{visibility:hidden;}'));
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
};
}
/* Shows the body of the page */
function showBody() {
let css = document.getElementById(STOP_BLINK_CSS_ID);
if (css)
css.remove();
};
}
/* Sets the theme selection to the given theme */
function setThemeSelect(theme) {
@ -167,6 +168,6 @@
}
});
}
}(switch_css = window.switch_css || {}));
}(switch_css = window.switch_css || {})); // eslint-disable-line
switch_css.init();
switch_css.init(); // eslint-disable-line

View file

@ -14,7 +14,7 @@ module.exports = {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader']
use: ["babel-loader", "eslint-loader"]
}]
},
resolve: {

File diff suppressed because it is too large Load diff