From 21ab10d5b961dce5b0550d6087050740015bf608 Mon Sep 17 00:00:00 2001 From: Zerebos Date: Thu, 22 Feb 2024 00:55:46 -0500 Subject: [PATCH] Fix linting issues --- preload/src/api/fetch.js | 12 ++++++------ preload/src/api/https.js | 3 ++- renderer/src/modules/api/contextmenu.js | 7 +++++-- renderer/src/modules/api/fetch.js | 6 +++--- renderer/src/modules/api/index.js | 2 +- renderer/src/modules/api/webpack.js | 9 ++++----- renderer/src/modules/webpackmodules.js | 6 ++++-- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/preload/src/api/fetch.js b/preload/src/api/fetch.js index 098f46f1..321c812b 100644 --- a/preload/src/api/fetch.js +++ b/preload/src/api/fetch.js @@ -16,12 +16,12 @@ const redirectCodes = new Set([301, 302, 307, 308]); */ /** - * @param {string} url - * @param {FetchOptions} options + * @param {string} requestedUrl + * @param {FetchOptions} fetchOptions */ -export function nativeFetch(url, options) { +export function nativeFetch(requestedUrl, fetchOptions) { let state = "PENDING"; - const data = {content: [], headers: null, statusCode: null, url: url, statusText: "", redirected: false}; + const data = {content: [], headers: null, statusCode: null, url: requestedUrl, statusText: "", redirected: false}; const listeners = new Set(); const errors = new Set(); @@ -121,11 +121,11 @@ export function nativeFetch(url, options) { * reference to the object below so they have no way of * listening to the error through onError. */ - const parsed = new URL(url); + const parsed = new URL(requestedUrl); if (parsed.protocol !== "http:" && parsed.protocol !== "https:") { throw new Error(`Unsupported protocol: ${parsed.protocol}`); } - execute(parsed, options); + execute(parsed, fetchOptions); return { onComplete(listener) { diff --git a/preload/src/api/https.js b/preload/src/api/https.js index e2e6ae0a..9f84bccc 100644 --- a/preload/src/api/https.js +++ b/preload/src/api/https.js @@ -39,7 +39,8 @@ const makeRequest = (url, options, callback, setReq) => { // Make sure to close the socket. try {req.write(options.formData);} finally {req.end();} - } else { + } + else { req.end(); } diff --git a/renderer/src/modules/api/contextmenu.js b/renderer/src/modules/api/contextmenu.js index 2af01498..ac14efdf 100644 --- a/renderer/src/modules/api/contextmenu.js +++ b/renderer/src/modules/api/contextmenu.js @@ -35,7 +35,8 @@ const ContextMenuActions = (() => { } startupComplete &&= typeof(out.closeContextMenu) === "function" && typeof(out.openContextMenu) === "function"; - } catch (error) { + } + catch (error) { startupComplete = false; Logger.stacktrace("ContextMenu~Components", "Fatal startup error:", error); @@ -222,6 +223,7 @@ class ContextMenu { // This is done to make sure the UI actually displays the on/off correctly if (type === "toggle") { + // eslint-disable-next-line react-hooks/rules-of-hooks const [active, doToggle] = React.useState(props.checked || false); const originalAction = props.action; props.checked = active; @@ -330,7 +332,8 @@ Object.freeze(ContextMenu.prototype); try { MenuPatcher.initialize(); -} catch (error) { +} +catch (error) { Logger.error("ContextMenu~Patcher", "Fatal error:", error); } diff --git a/renderer/src/modules/api/fetch.js b/renderer/src/modules/api/fetch.js index 5a20e8c4..fa82a020 100644 --- a/renderer/src/modules/api/fetch.js +++ b/renderer/src/modules/api/fetch.js @@ -80,13 +80,13 @@ export default function fetch(url, options = {}) { ctx.onComplete(() => { try { - const data = ctx.readData(); + const resultData = ctx.readData(); const req = new FetchResponse({ method: options.method ?? "GET", - status: data.statusCode, + status: resultData.statusCode, ...options, - ...data + ...resultData }); resolve(req); diff --git a/renderer/src/modules/api/index.js b/renderer/src/modules/api/index.js index 37cb7fc3..421c5a95 100644 --- a/renderer/src/modules/api/index.js +++ b/renderer/src/modules/api/index.js @@ -58,7 +58,7 @@ export default class BdApi { get ContextMenu() {return ContextMenuAPI;} Components = { get Tooltip() {return DiscordModules.Tooltip;} - } + }; Net = {fetch}; } diff --git a/renderer/src/modules/api/webpack.js b/renderer/src/modules/api/webpack.js index c6f27887..2c45443c 100644 --- a/renderer/src/modules/api/webpack.js +++ b/renderer/src/modules/api/webpack.js @@ -4,11 +4,10 @@ import WebpackModules, {Filters} from "@modules/webpackmodules"; const getOptions = (args, defaultOptions = {}) => { - if (args.length > 1 && - typeof(args[args.length - 1]) === "object" && - !Array.isArray(args[args.length - 1]) && - args[args.length - 1] !== null - ) { + if (args.length > 1 + && typeof(args[args.length - 1]) === "object" // eslint-disable-line operator-linebreak + && !Array.isArray(args[args.length - 1]) // eslint-disable-line operator-linebreak + && args[args.length - 1] !== null) { // eslint-disable-line operator-linebreak Object.assign(defaultOptions, args.pop()); } diff --git a/renderer/src/modules/webpackmodules.js b/renderer/src/modules/webpackmodules.js index da646646..40cb9659 100644 --- a/renderer/src/modules/webpackmodules.js +++ b/renderer/src/modules/webpackmodules.js @@ -190,7 +190,8 @@ export default class WebpackModules { if (!modules.hasOwnProperty(index)) continue; let module = null; - try {module = modules[index];} catch {continue;} + try {module = modules[index];} + catch {continue;} const {exports} = module; if (!exports || exports === window || exports === document.documentElement || exports[Symbol.toStringTag] === "DOMTokenList") continue; @@ -199,7 +200,8 @@ export default class WebpackModules { for (const key in exports) { let foundModule = null; let wrappedExport = null; - try {wrappedExport = exports[key];} catch {continue;} + try {wrappedExport = exports[key];} + catch {continue;} if (!wrappedExport) continue; if (wrappedFilter(wrappedExport, module, index)) foundModule = wrappedExport;