From 6607455e8f1cbf9abb3729d1baebaa3bd6674834 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 18 Dec 2017 09:57:00 +0300 Subject: [PATCH] silence eslint; switch shirt-circuiting to single-line if/else --- content/install-hook-userstyles.js | 3 ++- js/messaging.js | 5 +++-- js/usercss.js | 4 +--- manage/manage.js | 2 +- vendor-overwrites/colorpicker/colorview.js | 5 +++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/content/install-hook-userstyles.js b/content/install-hook-userstyles.js index e533b03a..95cb5e66 100644 --- a/content/install-hook-userstyles.js +++ b/content/install-hook-userstyles.js @@ -1,3 +1,4 @@ +/* global cloneInto */ 'use strict'; (() => { @@ -93,7 +94,7 @@ if (typeof cloneInto !== 'undefined') { // Firefox requires explicit cloning, however USO can't process our messages anyway // because USO tries to use a global "event" variable deprecated in Firefox - detail = cloneInto(detail, document); // eslint-disable-line no-undef + detail = cloneInto(detail, document); } onDOMready().then(() => { document.dispatchEvent(new CustomEvent(type, detail)); diff --git a/js/messaging.js b/js/messaging.js index 5f1a6cf2..c4abfe81 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -159,7 +159,7 @@ function sendMessage(msg, callback) { fn(...args, r => { const err = r && r.__ERROR__; (err ? reject : resolve)(err || r); - chrome.runtime.lastError; // eslint-disable-line no-unused-expressions + ignoreChromeError(); }); }); } @@ -268,7 +268,8 @@ function stringAsRegExp(s, flags) { function ignoreChromeError() { - chrome.runtime.lastError; // eslint-disable-line no-unused-expressions + // eslint-disable-next-line no-unused-expressions + chrome.runtime.lastError; } diff --git a/js/usercss.js b/js/usercss.js index 11e1dac0..cf3f7e63 100644 --- a/js/usercss.js +++ b/js/usercss.js @@ -51,9 +51,7 @@ var usercss = (() => { return loadScript('/vendor/stylus-lang/stylus.min.js').then(() => ( new Promise((resolve, reject) => { const varDef = Object.keys(vars).map(key => `${key} = ${vars[key].value};\n`).join(''); - - // eslint-disable-next-line no-undef - stylus(varDef + source).render((err, output) => { + window.stylus(varDef + source).render((err, output) => { if (err) { reject(err); } else { diff --git a/manage/manage.js b/manage/manage.js index a521de74..19426204 100644 --- a/manage/manage.js +++ b/manage/manage.js @@ -392,7 +392,7 @@ Object.assign(handleEvent, { }, config(event, {styleMeta}) { - event.preventDefault() + event.preventDefault(); configDialog(styleMeta); }, }); diff --git a/vendor-overwrites/colorpicker/colorview.js b/vendor-overwrites/colorpicker/colorview.js index cadd70ae..59aa3577 100644 --- a/vendor-overwrites/colorpicker/colorview.js +++ b/vendor-overwrites/colorpicker/colorview.js @@ -183,7 +183,7 @@ } lineCacheAlive = true; - !elements && (elements = text.getElementsByClassName(OWN_TOKEN_CLASS)); + if (!elements) elements = text.getElementsByClassName(OWN_TOKEN_CLASS); do { el = elements[elementIndex]; elementIndex += el && el.classList.contains(DISABLED_NEXT_TOKEN_CLASS) ? 2 : 1; @@ -202,7 +202,7 @@ bg.title = options.tooltip; } bg.style.setProperty('background-color', data.color, 'important'); - !bg.parentNode && el.appendChild(bg); + if (!bg.parentNode) el.appendChild(bg); } if (lineCacheAlive) { @@ -450,6 +450,7 @@ } openPopup(color) { + // eslint-disable-next-line prefer-const let {line, ch} = this.cm.getCursor(); const lineText = this.cm.getLine(line); const lineTextLC = lineText.toLowerCase();