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 {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) {

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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);

View File

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

View File

@ -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());
}

View File

@ -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;