get rid of eslint errors, seemingly without things breaking this time

This commit is contained in:
wearrrrr 2024-11-10 14:41:49 -06:00
parent fd7cec815c
commit f8bcd5ae08
22 changed files with 34 additions and 40 deletions

View file

@ -20,9 +20,11 @@ export default [
...config, ...config,
files: ["**/*.ts"], files: ["**/*.ts"],
})), })),
{
ignores: ["dist", "rewriter"]
},
{ {
files: ["**/*.ts"], files: ["**/*.ts"],
plugins: { plugins: {
"@typescript-eslint": typescriptEslint, "@typescript-eslint": typescriptEslint,
}, },
@ -34,7 +36,7 @@ export default [
rules: { rules: {
"no-await-in-loop": "warn", "no-await-in-loop": "warn",
"no-unused-labels": "warn", "no-unused-labels": "warn",
quotes: ["error", "double"], "quotes": ["error", "double"],
"getter-return": "error", "getter-return": "error",
"newline-before-return": "error", "newline-before-return": "error",
"no-multiple-empty-lines": "error", "no-multiple-empty-lines": "error",

View file

@ -1,11 +1,11 @@
import { ScramjetClient } from "../client"; 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", { client.Trap("Element.prototype.attributes", {
get(ctx) { get(ctx) {
const map = ctx.get() as NamedNodeMap; const map = ctx.get() as NamedNodeMap;
const proxy = new Proxy(map, { const proxy = new Proxy(map, {
get(target, prop, receiver) { get(target, prop, _receiver) {
const value = Reflect.get(target, prop); const value = Reflect.get(target, prop);
if (prop === "length") { if (prop === "length") {

View file

@ -1,7 +1,7 @@
import { rewriteUrl } from "../../shared"; import { rewriteUrl } from "../../shared";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export default function (client: ScramjetClient, self) { export default function (client: ScramjetClient, _self: Self) {
client.Proxy("Navigator.prototype.sendBeacon", { client.Proxy("Navigator.prototype.sendBeacon", {
apply(ctx) { apply(ctx) {
ctx.args[0] = rewriteUrl(ctx.args[0], client.meta); ctx.args[0] = rewriteUrl(ctx.args[0], client.meta);

View file

@ -1,17 +1,18 @@
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
import { rewriteCss, unrewriteCss } from "../../shared"; import { rewriteCss, unrewriteCss } from "../../shared";
const cssProperties = [ // Why is this here?
"background", // const cssProperties = [
"background-image", // "background",
"mask", // "background-image",
"mask-image", // "mask",
"list-style", // "mask-image",
"list-style-image", // "list-style",
"border-image", // "list-style-image",
"border-image-source", // "border-image",
"cursor", // "border-image-source",
]; // "cursor",
// ];
export default function (client: ScramjetClient) { export default function (client: ScramjetClient) {
client.Proxy("CSSStyleDeclaration.prototype.setProperty", { client.Proxy("CSSStyleDeclaration.prototype.setProperty", {

View file

@ -1,7 +1,7 @@
import { rewriteHtml } from "../../shared"; import { rewriteHtml } from "../../shared";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export default function (client: ScramjetClient, self: typeof window) { export default function (client: ScramjetClient, _self: Self) {
client.Proxy("Document.prototype.write", { client.Proxy("Document.prototype.write", {
apply(ctx) { apply(ctx) {
if (ctx.args[0]) if (ctx.args[0])

View file

@ -5,16 +5,12 @@ import {
unrewriteUrl, unrewriteUrl,
htmlRules, htmlRules,
unrewriteHtml, unrewriteHtml,
unrewriteBlob,
} from "../../shared"; } from "../../shared";
import { import {
rewriteUrl,
rewriteCss, rewriteCss,
rewriteHtml, rewriteHtml,
rewriteJs, rewriteJs,
rewriteSrcset,
} from "../../shared"; } from "../../shared";
import type { URLMeta } from "../../shared/rewriters/url";
export default function (client: ScramjetClient, self: typeof window) { export default function (client: ScramjetClient, self: typeof window) {
const _nativeGetAttribute = self.Element.prototype.getAttribute; const _nativeGetAttribute = self.Element.prototype.getAttribute;
@ -140,7 +136,7 @@ export default function (client: ScramjetClient, self: typeof window) {
}); });
client.Proxy("Element.prototype.setAttributeNS", { client.Proxy("Element.prototype.setAttributeNS", {
apply(ctx) { apply(ctx) {
const [namespace, name, value] = ctx.args; const [_namespace, name, value] = ctx.args;
const ruleList = htmlRules.find((rule) => { const ruleList = htmlRules.find((rule) => {
const r = rule[name.toLowerCase()]; const r = rule[name.toLowerCase()];

View file

@ -2,7 +2,7 @@ import { ScramjetClient } from "../client";
import { rewriteUrl } from "../../shared"; import { rewriteUrl } from "../../shared";
import { UrlChangeEvent } from "../events"; import { UrlChangeEvent } from "../events";
export default function (client: ScramjetClient, self: typeof globalThis) { export default function (client: ScramjetClient, _self: Self) {
client.Proxy("History.prototype.pushState", { client.Proxy("History.prototype.pushState", {
apply(ctx) { apply(ctx) {
if (ctx.args[2] || ctx.args[2] === "") if (ctx.args[2] || ctx.args[2] === "")

View file

@ -1,7 +1,6 @@
import { ScramjetClient } from "../client"; 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", { client.Trap("origin", {
get() { get() {
// this isn't right!! // this isn't right!!

View file

@ -1,7 +1,7 @@
import { unrewriteUrl } from "../../shared"; import { unrewriteUrl } from "../../shared";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export default function (client: ScramjetClient, self: typeof globalThis) { export default function (client: ScramjetClient, _self: Self) {
client.Trap("PerformanceEntry.prototype.name", { client.Trap("PerformanceEntry.prototype.name", {
get(ctx) { get(ctx) {
return unrewriteUrl(ctx.get() as string); return unrewriteUrl(ctx.get() as string);

View file

@ -1,4 +1,4 @@
import { config, rewriteUrl } from "../../shared"; import { rewriteUrl } from "../../shared";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
import { type MessageC2W } from "../../worker"; import { type MessageC2W } from "../../worker";
import { getOwnPropertyDescriptorHandler } from "../helpers"; import { getOwnPropertyDescriptorHandler } from "../helpers";

View file

@ -88,7 +88,6 @@ export default function (client: ScramjetClient, self: typeof window) {
}; };
const realLocalStorage = self.localStorage; const realLocalStorage = self.localStorage;
const realSessionStorage = self.sessionStorage;
const localStorageProxy = new Proxy(self.localStorage, handler); const localStorageProxy = new Proxy(self.localStorage, handler);
const sessionStorageProxy = new Proxy(self.sessionStorage, handler); const sessionStorageProxy = new Proxy(self.sessionStorage, handler);

View file

@ -4,7 +4,6 @@ import { SCRAMJETCLIENT } from "../symbols";
import { ScramjetClient } from "./client"; import { ScramjetClient } from "./client";
// import { config } from "../shared"; // import { config } from "../shared";
import { getOwnPropertyDescriptorHandler } from "./helpers"; import { getOwnPropertyDescriptorHandler } from "./helpers";
import { indirectEval } from "./shared/eval";
export const UNSAFE_GLOBALS = [ export const UNSAFE_GLOBALS = [
"window", "window",

View file

@ -1,7 +1,7 @@
// @ts-nocheck // @ts-nocheck
import { ScramjetClient } from "./client"; import { ScramjetClient } from "./client";
import { nativeGetOwnPropertyDescriptor } from "./natives"; import { nativeGetOwnPropertyDescriptor } from "./natives";
import { unrewriteUrl, rewriteUrl } from "../shared"; import { rewriteUrl } from "../shared";
import { UrlChangeEvent } from "./events"; import { UrlChangeEvent } from "./events";
import { iswindow } from "."; import { iswindow } from ".";

View file

@ -10,10 +10,10 @@ export default function (client: ScramjetClient) {
const log = console.log; const log = console.log;
client.Trap("console.log", { client.Trap("console.log", {
set(ctx, v) { set(_ctx, _v) {
// is there a legitimate reason to let sites do this? // is there a legitimate reason to let sites do this?
}, },
get(ctx) { get(_ctx) {
return log; return log;
}, },
}); });

View file

@ -1,7 +1,7 @@
import { rewriteUrl } from "../../shared"; import { rewriteUrl } from "../../shared";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export default function (client: ScramjetClient, self: typeof globalThis) { export default function (client: ScramjetClient, _self: Self) {
client.Proxy("CacheStorage.prototype.open", { client.Proxy("CacheStorage.prototype.open", {
apply(ctx) { apply(ctx) {
ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`; ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`;

View file

@ -1,5 +1,4 @@
import { flagEnabled } from "../../scramjet"; import { flagEnabled } from "../../scramjet";
import { config } from "../../shared";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export const enabled = (client: ScramjetClient) => export const enabled = (client: ScramjetClient) =>

View file

@ -8,7 +8,7 @@ function rewriteFunction(ctx: ProxyCtx, client: ScramjetClient) {
ctx.return(ctx.fn(content)()); ctx.return(ctx.fn(content)());
} }
export default function (client: ScramjetClient, self: Self) { export default function (client: ScramjetClient, _self: Self) {
const handler: Proxy = { const handler: Proxy = {
apply(ctx) { apply(ctx) {
rewriteFunction(ctx, client); rewriteFunction(ctx, client);

View file

@ -1,6 +1,6 @@
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export default function (client: ScramjetClient, self: Self) { export default function (client: ScramjetClient) {
client.Proxy("IDBFactory.prototype.open", { client.Proxy("IDBFactory.prototype.open", {
apply(ctx) { apply(ctx) {
ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`; ctx.args[0] = `${client.url.origin}@${ctx.args[0]}`;

View file

@ -1,7 +1,6 @@
import { iswindow } from ".."; import { iswindow } from "..";
import { BareMuxConnection } from "../../shared"; import { BareMuxConnection } from "../../shared";
import { rewriteUrl } from "../../shared"; import { rewriteUrl } from "../../shared";
import type { MessageC2W } from "../../worker";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
export default function (client: ScramjetClient, self: typeof globalThis) { export default function (client: ScramjetClient, self: typeof globalThis) {

View file

@ -1,4 +1,4 @@
import { iswindow, isworker } from ".."; import { iswindow } from "..";
import { SCRAMJETCLIENT } from "../../symbols"; import { SCRAMJETCLIENT } from "../../symbols";
import { ScramjetClient } from "../client"; import { ScramjetClient } from "../client";
import { config } from "../../shared"; import { config } from "../../shared";

View file

@ -123,7 +123,7 @@ function handleMessage(
function trustEvent(event: Event): Event { function trustEvent(event: Event): Event {
return new Proxy(event, { return new Proxy(event, {
get(target, prop, reciever) { get(target, prop, _reciever) {
if (prop === "isTrusted") return true; if (prop === "isTrusted") return true;
return Reflect.get(target, prop); return Reflect.get(target, prop);

View file

@ -2,7 +2,7 @@ import { $scramjet } from "../../scramjet";
import { rewriteJs } from "./js"; import { rewriteJs } from "./js";
import { URLMeta } from "./url"; import { URLMeta } from "./url";
const clientscripts = ["wasm", "shared", "client"]; // const clientscripts = ["wasm", "shared", "client"];
export function rewriteWorkers( export function rewriteWorkers(
js: string | ArrayBuffer, js: string | ArrayBuffer,
type: string, type: string,