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/core": "^7.4.4",
"@babel/preset-env": "^7.4.4", "@babel/preset-env": "^7.4.4",
"babel-loader": "^8.0.5", "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": "^4.30.0",
"webpack-cli": "^3.3.2" "webpack-cli": "^3.3.2"
} }

View file

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

View file

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

File diff suppressed because it is too large Load diff