From 5c1555c781cbb44ca183ec71f0c9aff0035caaa2 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 30 Jun 2017 15:02:09 +0300 Subject: [PATCH] code cosmetics: fix some eslint complaints Until https://github.com/eslint/eslint/issues/8594 is sorted out, we're switching to the old indent behavior (indent-legacy). --- .eslintrc | 2 +- apply.js | 1 - background.js | 1 - backup/fileSaveLoad.js | 3 +-- dom.js | 4 +++- edit.js | 2 +- install.js | 29 ++++++++++++++--------------- 7 files changed, 20 insertions(+), 22 deletions(-) diff --git a/.eslintrc b/.eslintrc index 6441aad4..a0e8a12e 100644 --- a/.eslintrc +++ b/.eslintrc @@ -93,7 +93,7 @@ rules: id-blacklist: [0] id-length: [0] id-match: [0] - indent: [2, 2, {VariableDeclarator: 0, SwitchCase: 1}] + indent-legacy: [2, 2, {VariableDeclarator: 0, SwitchCase: 1}] jsx-quotes: [0] key-spacing: [0] keyword-spacing: [2] diff --git a/apply.js b/apply.js index 2d85356a..6e310f05 100644 --- a/apply.js +++ b/apply.js @@ -60,7 +60,6 @@ function applyOnMessage(request, sender, sendResponse) { } switch (request.method) { - case 'styleDeleted': removeStyle(request); break; diff --git a/background.js b/background.js index 4a9bb27b..1cfea5f6 100644 --- a/background.js +++ b/background.js @@ -292,7 +292,6 @@ function updateIcon(tab, styles) { function onRuntimeMessage(request, sender, sendResponse) { switch (request.method) { - case 'getStyles': getStyles(request).then(sendResponse); return KEEP_CHANNEL_OPEN; diff --git a/backup/fileSaveLoad.js b/backup/fileSaveLoad.js index 4ac993ec..67f6b077 100644 --- a/backup/fileSaveLoad.js +++ b/backup/fileSaveLoad.js @@ -378,8 +378,7 @@ Object.assign(document.body, { if (event.target === this) { this.ondragend(); } - } - catch (e) { + } catch (e) { this.ondragend(); } }, diff --git a/dom.js b/dom.js index be081107..2dca2090 100644 --- a/dom.js +++ b/dom.js @@ -58,7 +58,9 @@ function animateElement( element.removeEventListener('animationend', _); element.classList.remove( className, - ...removeExtraClasses // In Firefox, `resolve()` might be called one frame later. This is helpful to clean-up on the same frame + // In Firefox, `resolve()` might be called one frame later. + // This is helpful to clean-up on the same frame + ...removeExtraClasses ); // TODO: investigate why animation restarts if the elements is removed in .then() if (remove) { diff --git a/edit.js b/edit.js index d84261b0..48ee1bad 100644 --- a/edit.js +++ b/edit.js @@ -1,4 +1,4 @@ -/* eslint no-tabs: 0, no-var: 0, indent: [2, tab, {VariableDeclarator: 0, SwitchCase: 1}], quotes: 0 */ +/* eslint no-tabs: 0, no-var: 0, indent-legacy: [2, tab, {VariableDeclarator: 0, SwitchCase: 1}], quotes: 0 */ /* global CodeMirror */ "use strict"; diff --git a/install.js b/install.js index f62af69f..7ce385e3 100644 --- a/install.js +++ b/install.js @@ -5,13 +5,13 @@ const FIREFOX = /Firefox/.test(navigator.userAgent); const VIVALDI = /Vivaldi/.test(navigator.userAgent); const OPERA = /OPR/.test(navigator.userAgent); -document.addEventListener("stylishUpdate", onUpdateClicked); -document.addEventListener("stylishUpdateChrome", onUpdateClicked); -document.addEventListener("stylishUpdateOpera", onUpdateClicked); +document.addEventListener('stylishUpdate', onUpdateClicked); +document.addEventListener('stylishUpdateChrome', onUpdateClicked); +document.addEventListener('stylishUpdateOpera', onUpdateClicked); -document.addEventListener("stylishInstall", onInstallClicked); -document.addEventListener("stylishInstallChrome", onInstallClicked); -document.addEventListener("stylishInstallOpera", onInstallClicked); +document.addEventListener('stylishInstall', onInstallClicked); +document.addEventListener('stylishInstallChrome', onInstallClicked); +document.addEventListener('stylishInstallOpera', onInstallClicked); chrome.runtime.onMessage.addListener((msg, sender, sendResponse) => { // orphaned content script check @@ -126,7 +126,7 @@ new MutationObserver((mutations, observer) => { US.o does not provide "advanced settings" on this url if browser is not Chrome, we need to fix this URL using "stylish-update-url" meta key */ -function getStyleURL () { +function getStyleURL() { const url = getMeta('stylish-code-chrome'); // TODO: remove when USO is fixed const directUrl = getMeta('stylish-update-url'); @@ -176,8 +176,7 @@ function checkUpdatability([installedStyle]) { function sendEvent(type, detail = null) { if (FIREFOX) { type = type.replace('Chrome', ''); - } - else if (OPERA || VIVALDI) { + } else if (OPERA || VIVALDI) { type = type.replace('Chrome', 'Opera'); } detail = {detail}; @@ -336,13 +335,13 @@ function orphanCheck() { } // we're orphaned due to an extension update // we can detach event listeners - document.removeEventListener("stylishUpdate", onUpdateClicked); - document.removeEventListener("stylishUpdateChrome", onUpdateClicked); - document.removeEventListener("stylishUpdateOpera", onUpdateClicked); + document.removeEventListener('stylishUpdate', onUpdateClicked); + document.removeEventListener('stylishUpdateChrome', onUpdateClicked); + document.removeEventListener('stylishUpdateOpera', onUpdateClicked); - document.removeEventListener("stylishInstall", onInstallClicked); - document.removeEventListener("stylishInstallChrome", onInstallClicked); - document.removeEventListener("stylishInstallOpera", onInstallClicked); + document.removeEventListener('stylishInstall', onInstallClicked); + document.removeEventListener('stylishInstallChrome', onInstallClicked); + document.removeEventListener('stylishInstallOpera', onInstallClicked); // we can't detach chrome.runtime.onMessage because it's no longer connected internally // we can destroy global functions in this context to free up memory