From a2da02626ef7a026dc7f6ec4219fbb839f4c2721 Mon Sep 17 00:00:00 2001 From: abcang Date: Tue, 24 Nov 2020 01:35:14 +0900 Subject: Fixed ESLint error (#15214) * eslint --fix * fix consistent-return * fix promise/catch-or-return * ignore import rule --- app/javascript/mastodon/actions/notifications.js | 2 +- .../features/ui/components/focal_point_modal.js | 2 ++ app/javascript/mastodon/stream.js | 2 +- app/javascript/mastodon/utils/notifications.js | 3 ++- streaming/index.js | 23 ++++++++++++---------- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/javascript/mastodon/actions/notifications.js b/app/javascript/mastodon/actions/notifications.js index d40b65745..93e18fba9 100644 --- a/app/javascript/mastodon/actions/notifications.js +++ b/app/javascript/mastodon/actions/notifications.js @@ -257,7 +257,7 @@ export function setupBrowserNotifications() { if ('Notification' in window && 'permissions' in navigator) { navigator.permissions.query({ name: 'notifications' }).then((status) => { status.onchange = () => dispatch(setBrowserPermission(Notification.permission)); - }); + }).catch(console.warn); } }; } diff --git a/app/javascript/mastodon/features/ui/components/focal_point_modal.js b/app/javascript/mastodon/features/ui/components/focal_point_modal.js index 2288be61d..578375a7f 100644 --- a/app/javascript/mastodon/features/ui/components/focal_point_modal.js +++ b/app/javascript/mastodon/features/ui/components/focal_point_modal.js @@ -18,7 +18,9 @@ import { length } from 'stringz'; import { Tesseract as fetchTesseract } from 'mastodon/features/ui/util/async-components'; import GIFV from 'mastodon/components/gifv'; import { me } from 'mastodon/initial_state'; +// eslint-disable-next-line import/no-extraneous-dependencies import tesseractCorePath from 'tesseract.js-core/tesseract-core.wasm.js'; +// eslint-disable-next-line import/extensions import tesseractWorkerPath from 'tesseract.js/dist/worker.min.js'; import { assetHost } from 'mastodon/utils/config'; diff --git a/app/javascript/mastodon/stream.js b/app/javascript/mastodon/stream.js index cf1388aed..c6d12cd6f 100644 --- a/app/javascript/mastodon/stream.js +++ b/app/javascript/mastodon/stream.js @@ -16,7 +16,7 @@ let sharedConnection; * @property {function(): void} onDisconnect */ - /** +/** * @typedef StreamEvent * @property {string} event * @property {object} payload diff --git a/app/javascript/mastodon/utils/notifications.js b/app/javascript/mastodon/utils/notifications.js index ab119c2e3..7634cac21 100644 --- a/app/javascript/mastodon/utils/notifications.js +++ b/app/javascript/mastodon/utils/notifications.js @@ -3,6 +3,7 @@ const checkNotificationPromise = () => { try { + // eslint-disable-next-line promise/catch-or-return Notification.requestPermission().then(); } catch(e) { return false; @@ -22,7 +23,7 @@ const handlePermission = (permission, callback) => { export const requestNotificationPermission = (callback) => { if (checkNotificationPromise()) { - Notification.requestPermission().then((permission) => handlePermission(permission, callback)); + Notification.requestPermission().then((permission) => handlePermission(permission, callback)).catch(console.warn); } else { Notification.requestPermission((permission) => handlePermission(permission, callback)); } diff --git a/streaming/index.js b/streaming/index.js index 877f45d19..3279bd94e 100644 --- a/streaming/index.js +++ b/streaming/index.js @@ -230,13 +230,13 @@ const startWorker = (workerId) => { const FALSE_VALUES = [ false, 0, - "0", - "f", - "F", - "false", - "FALSE", - "off", - "OFF" + '0', + 'f', + 'F', + 'false', + 'FALSE', + 'off', + 'OFF', ]; /** @@ -377,6 +377,8 @@ const startWorker = (workerId) => { return 'direct'; case '/api/v1/streaming/list': return 'list'; + default: + return undefined; } }; @@ -475,7 +477,7 @@ const startWorker = (workerId) => { log.verbose(req.requestId, `Closing connection for ${req.accountId} due to expired access token`); eventHandlers.onKill(); } - } + }; }; /** @@ -530,7 +532,8 @@ const startWorker = (workerId) => { log.error(req.requestId, err.toString()); if (res.headersSent) { - return next(err); + next(err); + return; } res.writeHead(err.status || 500, { 'Content-Type': 'application/json' }); @@ -1032,7 +1035,7 @@ const startWorker = (workerId) => { if (type === 'subscribe') { subscribeWebsocketToChannel(session, firstParam(stream), params); } else if (type === 'unsubscribe') { - unsubscribeWebsocketFromChannel(session, firstParam(stream), params) + unsubscribeWebsocketFromChannel(session, firstParam(stream), params); } else { // Unknown action type } -- cgit