From f8bcd5ae08a24e828ad369af8ab88e370aa7b6d0 Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Sun, 10 Nov 2024 14:41:49 -0600 Subject: [PATCH] get rid of eslint errors, seemingly without things breaking this time --- eslint.config.mjs | 6 ++++-- src/client/dom/attr.ts | 4 ++-- src/client/dom/beacon.ts | 2 +- src/client/dom/css.ts | 23 ++++++++++++----------- src/client/dom/document.ts | 2 +- src/client/dom/element.ts | 6 +----- src/client/dom/history.ts | 2 +- src/client/dom/origin.ts | 3 +-- src/client/dom/performance.ts | 2 +- src/client/dom/serviceworker.ts | 2 +- src/client/dom/storage.ts | 1 - src/client/global.ts | 1 - src/client/location.ts | 2 +- src/client/shared/antiantidebugger.ts | 4 ++-- src/client/shared/caches.ts | 2 +- src/client/shared/err.ts | 1 - src/client/shared/function.ts | 2 +- src/client/shared/indexeddb.ts | 2 +- src/client/shared/worker.ts | 1 - src/client/shared/wrap.ts | 2 +- src/client/swruntime.ts | 2 +- src/shared/rewriters/worker.ts | 2 +- 22 files changed, 34 insertions(+), 40 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index b27bb99..bbaef5c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -20,9 +20,11 @@ export default [ ...config, files: ["**/*.ts"], })), + { + ignores: ["dist", "rewriter"] + }, { files: ["**/*.ts"], - plugins: { "@typescript-eslint": typescriptEslint, }, @@ -34,7 +36,7 @@ export default [ rules: { "no-await-in-loop": "warn", "no-unused-labels": "warn", - quotes: ["error", "double"], + "quotes": ["error", "double"], "getter-return": "error", "newline-before-return": "error", "no-multiple-empty-lines": "error", diff --git a/src/client/dom/attr.ts b/src/client/dom/attr.ts index c249180..dbcedd4 100644 --- a/src/client/dom/attr.ts +++ b/src/client/dom/attr.ts @@ -1,11 +1,11 @@ import { ScramjetClient } from "../client"; -export default function (client: ScramjetClient, self: typeof window) { +export default function (client: ScramjetClient, _self: typeof window) { client.Trap("Element.prototype.attributes", { get(ctx) { const map = ctx.get() as NamedNodeMap; const proxy = new Proxy(map, { - get(target, prop, receiver) { + get(target, prop, _receiver) { const value = Reflect.get(target, prop); if (prop === "length") { diff --git a/src/client/dom/beacon.ts b/src/client/dom/beacon.ts index 308d5fa..a82dab6 100644 --- a/src/client/dom/beacon.ts +++ b/src/client/dom/beacon.ts @@ -1,7 +1,7 @@ import { rewriteUrl } from "../../shared"; import { ScramjetClient } from "../client"; -export default function (client: ScramjetClient, self) { +export default function (client: ScramjetClient, _self: Self) { client.Proxy("Navigator.prototype.sendBeacon", { apply(ctx) { ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); diff --git a/src/client/dom/css.ts b/src/client/dom/css.ts index 6ae439a..d8bb0f8 100644 --- a/src/client/dom/css.ts +++ b/src/client/dom/css.ts @@ -1,17 +1,18 @@ import { ScramjetClient } from "../client"; import { rewriteCss, unrewriteCss } from "../../shared"; -const cssProperties = [ - "background", - "background-image", - "mask", - "mask-image", - "list-style", - "list-style-image", - "border-image", - "border-image-source", - "cursor", -]; +// Why is this here? +// const cssProperties = [ +// "background", +// "background-image", +// "mask", +// "mask-image", +// "list-style", +// "list-style-image", +// "border-image", +// "border-image-source", +// "cursor", +// ]; export default function (client: ScramjetClient) { client.Proxy("CSSStyleDeclaration.prototype.setProperty", { diff --git a/src/client/dom/document.ts b/src/client/dom/document.ts index e402611..090c787 100644 --- a/src/client/dom/document.ts +++ b/src/client/dom/document.ts @@ -1,7 +1,7 @@ import { rewriteHtml } from "../../shared"; import { ScramjetClient } from "../client"; -export default function (client: ScramjetClient, self: typeof window) { +export default function (client: ScramjetClient, _self: Self) { client.Proxy("Document.prototype.write", { apply(ctx) { if (ctx.args[0]) diff --git a/src/client/dom/element.ts b/src/client/dom/element.ts index e64cbeb..ded83ad 100644 --- a/src/client/dom/element.ts +++ b/src/client/dom/element.ts @@ -5,16 +5,12 @@ import { unrewriteUrl, htmlRules, unrewriteHtml, - unrewriteBlob, } from "../../shared"; import { - rewriteUrl, rewriteCss, rewriteHtml, rewriteJs, - rewriteSrcset, } from "../../shared"; -import type { URLMeta } from "../../shared/rewriters/url"; export default function (client: ScramjetClient, self: typeof window) { const _nativeGetAttribute = self.Element.prototype.getAttribute; @@ -140,7 +136,7 @@ export default function (client: ScramjetClient, self: typeof window) { }); client.Proxy("Element.prototype.setAttributeNS", { apply(ctx) { - const [namespace, name, value] = ctx.args; + const [_namespace, name, value] = ctx.args; const ruleList = htmlRules.find((rule) => { const r = rule[name.toLowerCase()]; diff --git a/src/client/dom/history.ts b/src/client/dom/history.ts index 6abd704..b294c43 100644 --- a/src/client/dom/history.ts +++ b/src/client/dom/history.ts @@ -2,7 +2,7 @@ import { ScramjetClient } from "../client"; import { rewriteUrl } from "../../shared"; import { UrlChangeEvent } from "../events"; -export default function (client: ScramjetClient, self: typeof globalThis) { +export default function (client: ScramjetClient, _self: Self) { client.Proxy("History.prototype.pushState", { apply(ctx) { if (ctx.args[2] || ctx.args[2] === "") diff --git a/src/client/dom/origin.ts b/src/client/dom/origin.ts index b0ee571..891baf8 100644 --- a/src/client/dom/origin.ts +++ b/src/client/dom/origin.ts @@ -1,7 +1,6 @@ import { ScramjetClient } from "../client"; -import { unrewriteUrl } from "../../shared"; -export default function (client: ScramjetClient, self: typeof window) { +export default function (client: ScramjetClient, _self: Self) { client.Trap("origin", { get() { // this isn't right!! diff --git a/src/client/dom/performance.ts b/src/client/dom/performance.ts index fce56e5..ebfec3d 100644 --- a/src/client/dom/performance.ts +++ b/src/client/dom/performance.ts @@ -1,7 +1,7 @@ import { unrewriteUrl } from "../../shared"; import { ScramjetClient } from "../client"; -export default function (client: ScramjetClient, self: typeof globalThis) { +export default function (client: ScramjetClient, _self: Self) { client.Trap("PerformanceEntry.prototype.name", { get(ctx) { return unrewriteUrl(ctx.get() as string); diff --git a/src/client/dom/serviceworker.ts b/src/client/dom/serviceworker.ts index 966a9df..39d9d23 100644 --- a/src/client/dom/serviceworker.ts +++ b/src/client/dom/serviceworker.ts @@ -1,4 +1,4 @@ -import { config, rewriteUrl } from "../../shared"; +import { rewriteUrl } from "../../shared"; import { ScramjetClient } from "../client"; import { type MessageC2W } from "../../worker"; import { getOwnPropertyDescriptorHandler } from "../helpers"; diff --git a/src/client/dom/storage.ts b/src/client/dom/storage.ts index af4bce7..dfbc38b 100644 --- a/src/client/dom/storage.ts +++ b/src/client/dom/storage.ts @@ -88,7 +88,6 @@ export default function (client: ScramjetClient, self: typeof window) { }; const realLocalStorage = self.localStorage; - const realSessionStorage = self.sessionStorage; const localStorageProxy = new Proxy(self.localStorage, handler); const sessionStorageProxy = new Proxy(self.sessionStorage, handler); diff --git a/src/client/global.ts b/src/client/global.ts index eaf1e1c..ea9ddac 100644 --- a/src/client/global.ts +++ b/src/client/global.ts @@ -4,7 +4,6 @@ import { SCRAMJETCLIENT } from "../symbols"; import { ScramjetClient } from "./client"; // import { config } from "../shared"; import { getOwnPropertyDescriptorHandler } from "./helpers"; -import { indirectEval } from "./shared/eval"; export const UNSAFE_GLOBALS = [ "window", diff --git a/src/client/location.ts b/src/client/location.ts index 385c438..633bc1e 100644 --- a/src/client/location.ts +++ b/src/client/location.ts @@ -1,7 +1,7 @@ // @ts-nocheck import { ScramjetClient } from "./client"; import { nativeGetOwnPropertyDescriptor } from "./natives"; -import { unrewriteUrl, rewriteUrl } from "../shared"; +import { rewriteUrl } from "../shared"; import { UrlChangeEvent } from "./events"; import { iswindow } from "."; diff --git a/src/client/shared/antiantidebugger.ts b/src/client/shared/antiantidebugger.ts index e119afd..0e67d17 100644 --- a/src/client/shared/antiantidebugger.ts +++ b/src/client/shared/antiantidebugger.ts @@ -10,10 +10,10 @@ export default function (client: ScramjetClient) { const log = console.log; client.Trap("console.log", { - set(ctx, v) { + set(_ctx, _v) { // is there a legitimate reason to let sites do this? }, - get(ctx) { + get(_ctx) { return log; }, }); diff --git a/src/client/shared/caches.ts b/src/client/shared/caches.ts index aaef53f..70a58db 100644 --- a/src/client/shared/caches.ts +++ b/src/client/shared/caches.ts @@ -1,7 +1,7 @@ import { rewriteUrl } from "../../shared"; import { ScramjetClient } from "../client"; -export default function (client: ScramjetClient, self: typeof globalThis) { +export default function (client: ScramjetClient, _self: Self) { client.Proxy("CacheStorage.prototype.open", { apply(ctx) { ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`; diff --git a/src/client/shared/err.ts b/src/client/shared/err.ts index 64a192f..95936f0 100644 --- a/src/client/shared/err.ts +++ b/src/client/shared/err.ts @@ -1,5 +1,4 @@ import { flagEnabled } from "../../scramjet"; -import { config } from "../../shared"; import { ScramjetClient } from "../client"; export const enabled = (client: ScramjetClient) => diff --git a/src/client/shared/function.ts b/src/client/shared/function.ts index 7a6a56a..7a2f9ec 100644 --- a/src/client/shared/function.ts +++ b/src/client/shared/function.ts @@ -8,7 +8,7 @@ function rewriteFunction(ctx: ProxyCtx, client: ScramjetClient) { ctx.return(ctx.fn(content)()); } -export default function (client: ScramjetClient, self: Self) { +export default function (client: ScramjetClient, _self: Self) { const handler: Proxy = { apply(ctx) { rewriteFunction(ctx, client); diff --git a/src/client/shared/indexeddb.ts b/src/client/shared/indexeddb.ts index 4b57257..f0160ff 100644 --- a/src/client/shared/indexeddb.ts +++ b/src/client/shared/indexeddb.ts @@ -1,6 +1,6 @@ import { ScramjetClient } from "../client"; -export default function (client: ScramjetClient, self: Self) { +export default function (client: ScramjetClient) { client.Proxy("IDBFactory.prototype.open", { apply(ctx) { ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`; diff --git a/src/client/shared/worker.ts b/src/client/shared/worker.ts index dde7749..3a13e9a 100644 --- a/src/client/shared/worker.ts +++ b/src/client/shared/worker.ts @@ -1,7 +1,6 @@ import { iswindow } from ".."; import { BareMuxConnection } from "../../shared"; import { rewriteUrl } from "../../shared"; -import type { MessageC2W } from "../../worker"; import { ScramjetClient } from "../client"; export default function (client: ScramjetClient, self: typeof globalThis) { diff --git a/src/client/shared/wrap.ts b/src/client/shared/wrap.ts index b4dcab5..b0b95ba 100644 --- a/src/client/shared/wrap.ts +++ b/src/client/shared/wrap.ts @@ -1,4 +1,4 @@ -import { iswindow, isworker } from ".."; +import { iswindow } from ".."; import { SCRAMJETCLIENT } from "../../symbols"; import { ScramjetClient } from "../client"; import { config } from "../../shared"; diff --git a/src/client/swruntime.ts b/src/client/swruntime.ts index 6b21b2c..e7ed8db 100644 --- a/src/client/swruntime.ts +++ b/src/client/swruntime.ts @@ -123,7 +123,7 @@ function handleMessage( function trustEvent(event: Event): Event { return new Proxy(event, { - get(target, prop, reciever) { + get(target, prop, _reciever) { if (prop === "isTrusted") return true; return Reflect.get(target, prop); diff --git a/src/shared/rewriters/worker.ts b/src/shared/rewriters/worker.ts index 5c0f353..733c653 100644 --- a/src/shared/rewriters/worker.ts +++ b/src/shared/rewriters/worker.ts @@ -2,7 +2,7 @@ import { $scramjet } from "../../scramjet"; import { rewriteJs } from "./js"; import { URLMeta } from "./url"; -const clientscripts = ["wasm", "shared", "client"]; +// const clientscripts = ["wasm", "shared", "client"]; export function rewriteWorkers( js: string | ArrayBuffer, type: string,