Fix linting issues

This commit is contained in:
Zerebos 2024-02-22 00:55:46 -05:00
parent d3639d12ae
commit 21ab10d5b9
7 changed files with 25 additions and 20 deletions

View File

@ -16,12 +16,12 @@ const redirectCodes = new Set([301, 302, 307, 308]);
*/ */
/** /**
* @param {string} url * @param {string} requestedUrl
* @param {FetchOptions} options * @param {FetchOptions} fetchOptions
*/ */
export function nativeFetch(url, options) { export function nativeFetch(requestedUrl, fetchOptions) {
let state = "PENDING"; 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 listeners = new Set();
const errors = 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 * reference to the object below so they have no way of
* listening to the error through onError. * listening to the error through onError.
*/ */
const parsed = new URL(url); const parsed = new URL(requestedUrl);
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") { if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
throw new Error(`Unsupported protocol: ${parsed.protocol}`); throw new Error(`Unsupported protocol: ${parsed.protocol}`);
} }
execute(parsed, options); execute(parsed, fetchOptions);
return { return {
onComplete(listener) { onComplete(listener) {

View File

@ -39,7 +39,8 @@ const makeRequest = (url, options, callback, setReq) => {
// Make sure to close the socket. // Make sure to close the socket.
try {req.write(options.formData);} try {req.write(options.formData);}
finally {req.end();} finally {req.end();}
} else { }
else {
req.end(); req.end();
} }

View File

@ -35,7 +35,8 @@ const ContextMenuActions = (() => {
} }
startupComplete &&= typeof(out.closeContextMenu) === "function" && typeof(out.openContextMenu) === "function"; startupComplete &&= typeof(out.closeContextMenu) === "function" && typeof(out.openContextMenu) === "function";
} catch (error) { }
catch (error) {
startupComplete = false; startupComplete = false;
Logger.stacktrace("ContextMenu~Components", "Fatal startup error:", error); 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 // This is done to make sure the UI actually displays the on/off correctly
if (type === "toggle") { if (type === "toggle") {
// eslint-disable-next-line react-hooks/rules-of-hooks
const [active, doToggle] = React.useState(props.checked || false); const [active, doToggle] = React.useState(props.checked || false);
const originalAction = props.action; const originalAction = props.action;
props.checked = active; props.checked = active;
@ -330,7 +332,8 @@ Object.freeze(ContextMenu.prototype);
try { try {
MenuPatcher.initialize(); MenuPatcher.initialize();
} catch (error) { }
catch (error) {
Logger.error("ContextMenu~Patcher", "Fatal error:", error); Logger.error("ContextMenu~Patcher", "Fatal error:", error);
} }

View File

@ -80,13 +80,13 @@ export default function fetch(url, options = {}) {
ctx.onComplete(() => { ctx.onComplete(() => {
try { try {
const data = ctx.readData(); const resultData = ctx.readData();
const req = new FetchResponse({ const req = new FetchResponse({
method: options.method ?? "GET", method: options.method ?? "GET",
status: data.statusCode, status: resultData.statusCode,
...options, ...options,
...data ...resultData
}); });
resolve(req); resolve(req);

View File

@ -58,7 +58,7 @@ export default class BdApi {
get ContextMenu() {return ContextMenuAPI;} get ContextMenu() {return ContextMenuAPI;}
Components = { Components = {
get Tooltip() {return DiscordModules.Tooltip;} get Tooltip() {return DiscordModules.Tooltip;}
} };
Net = {fetch}; Net = {fetch};
} }

View File

@ -4,11 +4,10 @@ import WebpackModules, {Filters} from "@modules/webpackmodules";
const getOptions = (args, defaultOptions = {}) => { const getOptions = (args, defaultOptions = {}) => {
if (args.length > 1 && if (args.length > 1
typeof(args[args.length - 1]) === "object" && && typeof(args[args.length - 1]) === "object" // eslint-disable-line operator-linebreak
!Array.isArray(args[args.length - 1]) && && !Array.isArray(args[args.length - 1]) // eslint-disable-line operator-linebreak
args[args.length - 1] !== null && args[args.length - 1] !== null) { // eslint-disable-line operator-linebreak
) {
Object.assign(defaultOptions, args.pop()); Object.assign(defaultOptions, args.pop());
} }

View File

@ -190,7 +190,8 @@ export default class WebpackModules {
if (!modules.hasOwnProperty(index)) continue; if (!modules.hasOwnProperty(index)) continue;
let module = null; let module = null;
try {module = modules[index];} catch {continue;} try {module = modules[index];}
catch {continue;}
const {exports} = module; const {exports} = module;
if (!exports || exports === window || exports === document.documentElement || exports[Symbol.toStringTag] === "DOMTokenList") continue; 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) { for (const key in exports) {
let foundModule = null; let foundModule = null;
let wrappedExport = null; let wrappedExport = null;
try {wrappedExport = exports[key];} catch {continue;} try {wrappedExport = exports[key];}
catch {continue;}
if (!wrappedExport) continue; if (!wrappedExport) continue;
if (wrappedFilter(wrappedExport, module, index)) foundModule = wrappedExport; if (wrappedFilter(wrappedExport, module, index)) foundModule = wrappedExport;