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,
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",

View file

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

View file

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

View file

@ -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", {

View file

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

View file

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

View file

@ -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] === "")

View file

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

View file

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

View file

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

View file

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

View file

@ -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",

View file

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

View file

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

View file

@ -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]}`;

View file

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

View file

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

View file

@ -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]}`;

View file

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

View file

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

View file

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

View file

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