get rid of errors and warnings in error.ts

This commit is contained in:
wearrrrr 2024-10-10 19:42:02 -05:00
parent 6097b6e27e
commit c75f243866

View file

@ -2,7 +2,7 @@ import { config, decodeUrl } from "../../shared";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export const enabled = () => self.$scramjet.config.flags.cleanerrors; export const enabled = () => self.$scramjet.config.flags.cleanerrors;
export default function (client: ScramjetClient, self: Self) { export default function (client: ScramjetClient, _self: Self) {
// v8 only. all we need to do is clean the scramjet urls from stack traces // v8 only. all we need to do is clean the scramjet urls from stack traces
const closure = (error, stack) => { const closure = (error, stack) => {
let newstack = error.stack; let newstack = error.stack;
@ -12,9 +12,9 @@ export default function (client: ScramjetClient, self: Self) {
if (url.endsWith(config.client)) { if (url.endsWith(config.client)) {
// strip stack frames including scramjet handlers from the trace // strip stack frames including scramjet handlers from the trace
let lines = newstack.split("\n"); const lines = newstack.split("\n");
let i = lines.find((l) => l.includes(url)); const line = lines.find((l) => l.includes(url));
lines.splice(i, 1); lines.splice(line, 1);
newstack = lines.join("\n"); newstack = lines.join("\n");
continue; continue;
} }
@ -27,11 +27,11 @@ export default function (client: ScramjetClient, self: Self) {
return newstack; return newstack;
}; };
client.Trap("Error.prepareStackTrace", { client.Trap("Error.prepareStackTrace", {
get(ctx) { get(_ctx) {
// this is a funny js quirk. the getter is ran every time you type something in console // this is a funny js quirk. the getter is ran every time you type something in console
return closure; return closure;
}, },
set(value) { set(_value) {
// just ignore it if a site tries setting their own. not much we can really do // just ignore it if a site tries setting their own. not much we can really do
}, },
}); });