diff --git a/.eslintrc.js b/.eslintrc.js index cc79053..a5dc356 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -30,6 +30,7 @@ module.exports = { fixStyle: "inline-type-imports", }, ], + "@typescript-eslint/consistent-type-exports": "error", "@typescript-eslint/prefer-readonly": "warn", "@typescript-eslint/class-literal-property-style": ["warn", "getters"], "@typescript-eslint/consistent-generic-constructors": "error", @@ -41,6 +42,13 @@ module.exports = { // "@typescript-eslint/prefer-nullish-coalescing": "warn", "@typescript-eslint/prefer-optional-chain": "warn", "@typescript-eslint/prefer-string-starts-ends-with": "error", + "@typescript-eslint/no-meaningless-void-operator": "error", + "@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn", + "@typescript-eslint/no-unnecessary-condition": "warn", + "@typescript-eslint/no-unnecessary-qualifier": "warn", + "@typescript-eslint/no-unnecessary-type-arguments": "warn", + "@typescript-eslint/prefer-reduce-type-parameter": "warn", + "@typescript-eslint/promise-function-async": "warn", /* end stylistic rules */ /* start recommended rules */ @@ -48,13 +56,13 @@ module.exports = { "@typescript-eslint/no-base-to-string": "warn", "@typescript-eslint/no-duplicate-enum-values": "error", "@typescript-eslint/no-duplicate-type-constituents": "warn", - "@typescript-eslint/no-explicit-any": "warn", + "@typescript-eslint/no-explicit-any": "error", "@typescript-eslint/no-extra-non-null-assertion": "error", - // "@typescript-eslint/no-floating-promises": "warn", + "@typescript-eslint/no-floating-promises": "warn", "@typescript-eslint/no-for-in-array": "warn", "no-unused-vars": "off", "@typescript-eslint/no-unused-vars": [ - "warn", + "error", { argsIgnorePattern: "^_", varsIgnorePattern: "^_", @@ -68,7 +76,7 @@ module.exports = { "@typescript-eslint/no-misused-new": "error", "@typescript-eslint/no-misused-promises": [ "error", - { checksVoidReturn: { arguments: false } }, + { checksVoidReturn: false }, ], "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error", "@typescript-eslint/no-non-null-asserted-optional-chain": "warn", @@ -76,18 +84,20 @@ module.exports = { "@typescript-eslint/no-this-alias": "warn", "@typescript-eslint/no-unnecessary-type-assertion": "warn", "@typescript-eslint/no-unnecessary-type-constraint": "warn", - // "@typescript-eslint/no-unsafe-argument": "warn", + /* TODO eventually turn all these on */ + "@typescript-eslint/no-unsafe-argument": "warn", // "@typescript-eslint/no-unsafe-assignment": "warn", // "@typescript-eslint/no-unsafe-call": "warn", "@typescript-eslint/no-unsafe-declaration-merging": "warn", "@typescript-eslint/no-unsafe-enum-comparison": "warn", // "@typescript-eslint/no-unsafe-member-access": "warn", - // "@typescript-eslint/no-unsafe-return": "warn", + "@typescript-eslint/no-unsafe-return": "warn", "@typescript-eslint/prefer-as-const": "warn", "require-await": "off", - "@typescript-eslint/require-await": "warn", + // "@typescript-eslint/require-await": "warn", "@typescript-eslint/restrict-template-expressions": "warn", "@typescript-eslint/unbound-method": "off", + "@typescript-eslint/method-signature-style": "error", }, reportUnusedDisableDirectives: true, ignorePatterns: [ diff --git a/src/appmain.ts b/src/appmain.ts index f16d26f..55808e9 100644 --- a/src/appmain.ts +++ b/src/appmain.ts @@ -646,6 +646,8 @@ export class ReplayWebApp extends LitElement { onStartLoad(event) { // just redirect right away? + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.pageParams.set("source", event.detail.sourceUrl); const url = new URL(window.location.href); @@ -678,6 +680,8 @@ export class ReplayWebApp extends LitElement { //this.initRoute(); if (event.detail.sourceUrl !== this.sourceUrl) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.pageParams.set("source", event.detail.sourceUrl); window.location.search = this.pageParams.toString(); } diff --git a/src/chooser.ts b/src/chooser.ts index 7c3f2e4..2a155df 100644 --- a/src/chooser.ts +++ b/src/chooser.ts @@ -21,6 +21,8 @@ export class Chooser extends LitElement { droppedFile: FileWithPath | null = null; @property({ type: Boolean }) + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition hasNativeFS = !!window.showOpenFilePicker && !IS_APP; @property({ type: Object }) @@ -60,6 +62,8 @@ export class Chooser extends LitElement { .flat(2); const fileHasAllowedExtension = allowedFileExtensions.some( + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument (extension) => this.droppedFile?.name.endsWith(extension), ); @@ -77,6 +81,8 @@ export class Chooser extends LitElement { if (event.currentTarget.files.length === 0) { return; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.setFile(event.currentTarget.files[0]); } diff --git a/src/electron-preload.ts b/src/electron-preload.ts index 7c3e18c..eb62cce 100644 --- a/src/electron-preload.ts +++ b/src/electron-preload.ts @@ -17,11 +17,15 @@ async function getColl(name: string) { await dbs[name].initing; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return dbs[name]; } async function getDB(name: string) { const coll = await getColl(name); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return coll.store; } @@ -43,6 +47,8 @@ async function getResponse( return; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const headers = Object.fromEntries(result.headers.entries()); const buffer = await result.getBuffer(); diff --git a/src/electron-replay-app.ts b/src/electron-replay-app.ts index 22b6039..03f1cac 100644 --- a/src/electron-replay-app.ts +++ b/src/electron-replay-app.ts @@ -146,6 +146,8 @@ class ElectronReplayApp { } }); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises app.whenReady().then(() => this.onAppReady()); // Quit when all windows are closed. @@ -161,6 +163,8 @@ class ElectronReplayApp { autoUpdater.logger = log; // @ts-expect-error - TS2339 - Property 'transports' does not exist on type 'Logger'. autoUpdater.logger.transports.file.level = "info"; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises autoUpdater.checkForUpdatesAndNotify(); } @@ -173,12 +177,16 @@ class ElectronReplayApp { contents.setWindowOpenHandler(({ url }) => { // load docs in native browser for now if (url === STATIC_PREFIX + "docs") { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises shell.openExternal("https://replayweb.page/docs/"); return { action: "deny" }; } // load external URLs in native browser if (!url.startsWith(STATIC_PREFIX)) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises shell.openExternal(url); return { action: "deny" }; } @@ -189,10 +197,14 @@ class ElectronReplayApp { const sesh = session.defaultSession; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/promise-function-async sesh.protocol.interceptStreamProtocol("http", (request, callback) => this.doIntercept(request, callback), ); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/promise-function-async protocol.registerStreamProtocol(FILE_PROTO, (request, callback) => this.doHandleFile(request, callback), ); @@ -211,9 +223,13 @@ class ElectronReplayApp { return; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const filename = url.fileURLToPath(request.url.replace(FILE_PROTO, "file")); const headers = { "Content-Type": "application/octet-stream" }; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const reqHeaders = new Headers(request.headers); if (filename) { @@ -283,6 +299,8 @@ class ElectronReplayApp { filename = "docs/index.html"; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument let ext = path.extname(filename); if (!ext) { ext = ".html"; @@ -292,6 +310,8 @@ class ElectronReplayApp { const mimeType = mime.contentType(ext); if (mimeType) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const fullPath = path.join(this.staticContentPath, filename); console.log("fullPath: " + fullPath); @@ -333,6 +353,8 @@ class ElectronReplayApp { let response; try { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument response = await fetch(url, { method, headers, body }); } catch (e) { console.warn("fetch failed for: " + url); @@ -342,6 +364,8 @@ class ElectronReplayApp { const data = method === "HEAD" ? null : response.body; const statusCode = response.status; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument headers = Object.fromEntries(response.headers.entries()); callback({ statusCode, headers, data }); } @@ -379,6 +403,8 @@ class ElectronReplayApp { console.log("got response for: " + url); } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument headers = new Headers(headers); const date = new Date(); @@ -399,11 +425,15 @@ class ElectronReplayApp { useBaseRules: true, }); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument request.headers = new Headers(request.headers); try { response = await rewriter.rewrite(response, request); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument headers = Object.fromEntries(response.headers.entries()); let data = await response.getBuffer(); @@ -481,6 +511,8 @@ class ElectronReplayApp { theWindow.maximize(); }); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises theWindow.loadURL(STATIC_PREFIX + this.mainWindowUrl + sourceString); if (process.env.NODE_ENV === "development") { theWindow.webContents.openDevTools(); @@ -513,10 +545,14 @@ class ElectronReplayApp { const openTS = argv.ts || argv.timestamp; if (openUrl) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument urlParams.set("url", openUrl); } if (openTS) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument urlParams.set("ts", openTS); } diff --git a/src/embed-receipt.ts b/src/embed-receipt.ts index 24ec311..8a11ff9 100644 --- a/src/embed-receipt.ts +++ b/src/embed-receipt.ts @@ -319,16 +319,20 @@ export class RWPEmbedReceipt extends LitElement { class="has-text-black" target="_blank" href="https://github.com/webrecorder/replayweb.page" - >${this.appLogo - ? html` - - ` - : nothing} + >${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + this.appLogo + ? html` + + ` + : nothing + } Powered by ReplayWeb.page diff --git a/src/embed.ts b/src/embed.ts index b4c9fa2..25cf00c 100644 --- a/src/embed.ts +++ b/src/embed.ts @@ -103,6 +103,8 @@ class Embed extends LitElement { await this.swmanager.register(); this.inited = true; } catch (e) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.errorMessage = this.swmanager.renderErrorReport(this.logo); } } @@ -123,6 +125,8 @@ class Embed extends LitElement { return; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const currHash = new URLSearchParams(event.data); const url = new URL(window.location.href); url.hash = "#" + currHash.toString(); @@ -136,6 +140,8 @@ class Embed extends LitElement { "The noSandbox flag is deprecated. ReplayWeb.page does not add a sandbox by default. To enable sandboxing, use 'sandbox' flag instead. This may result in PDFs not loading and pages opening in new windows, but may be more secure in some situations", ); } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.doRegister(); window.addEventListener("message", (event) => this.handleMessage(event)); @@ -156,12 +162,16 @@ class Embed extends LitElement { if ( // @ts-expect-error - TS2339 - Property 'GestureEvent' does not exist on type 'Window & typeof globalThis'. window.GestureEvent !== undefined && + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition window.SharedWorker === undefined ) { this.noWebWorker = true; } // if no storage manager or estimate, don't cache + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!navigator.storage?.estimate) { this.noCache = true; } @@ -189,6 +199,8 @@ class Embed extends LitElement { } mergeConfigs() { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!this.customConfig) { return this.config; } @@ -217,6 +229,8 @@ class Embed extends LitElement { this.source = this.src; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const source = new URL(this.source, document.baseURI); const config = this.mergeConfigs(); @@ -353,6 +367,8 @@ class Embed extends LitElement { this.reloadCount <= 2 ) { this.reloadCount++; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-return setTimeout(() => win.location.reload(), 100); return; } @@ -375,6 +391,8 @@ async function main() { customElements.define("replay-web-page", Embed); } +// TODO: Fix this the next time the file is edited. +// eslint-disable-next-line @typescript-eslint/no-floating-promises main(); export { Embed }; diff --git a/src/gdrive.ts b/src/gdrive.ts index b1c04b1..759d2c7 100644 --- a/src/gdrive.ts +++ b/src/gdrive.ts @@ -31,6 +31,8 @@ class GDrive extends LitElement { if (changedProperties.has("sourceUrl")) { this.error = false; this.state = "trypublic"; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.tryPublicAccess().then((result) => { if (!result) { this.state = "tryauto"; @@ -67,6 +69,8 @@ class GDrive extends LitElement { try { const abort = new AbortController(); const signal = abort.signal; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument resp = await fetch(publicUrl, { signal }); abort.abort(); if (resp.status != 200) { @@ -99,6 +103,8 @@ class GDrive extends LitElement { this.state = "trymanual"; } } else { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.authed(response); } }); @@ -107,6 +113,8 @@ class GDrive extends LitElement { onClickAuth() { this.gauth("select_account", (response) => { if (!response.error) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.authed(response); } }); @@ -201,6 +209,8 @@ class GDrive extends LitElement { response_type: "token", prompt, }, + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument callback, ); }); diff --git a/src/item-index.ts b/src/item-index.ts index b11e1ab..8d3ea94 100644 --- a/src/item-index.ts +++ b/src/item-index.ts @@ -64,6 +64,8 @@ class ItemIndex extends LitElement { } firstUpdated() { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.loadItems(); } @@ -112,6 +114,8 @@ class ItemIndex extends LitElement { this.sortedItems = []; } catch (e) { // likely no sw registered yet, or waiting for new sw to register, retry again + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/promise-function-async setTimeout(() => this.loadItems(), 500); } } @@ -120,6 +124,8 @@ class ItemIndex extends LitElement { event.preventDefault(); event.stopPropagation(); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!this.sortedItems) { return; } @@ -128,6 +134,8 @@ class ItemIndex extends LitElement { const item = this.sortedItems[index]; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!item || this._deleting[item.sourceUrl]) { return; } @@ -318,7 +326,9 @@ class ItemIndex extends LitElement {
- ${date ? date.toLocaleString() : ""} + ${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + date ? date.toLocaleString() : "" + }
${this.textSnippet diff --git a/src/pages.ts b/src/pages.ts index 9f95ac6..ace6b9f 100644 --- a/src/pages.ts +++ b/src/pages.ts @@ -126,23 +126,35 @@ class Pages extends LitElement { if (this.newQuery !== null) { this.query = this.newQuery; this.newQuery = null; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.filter(); } } async updated(changedProperties: PropertyValues${list.desc}
${p.title}
${p.url}
@@ -422,6 +440,8 @@ class Story extends LitElement { } } this.lastST = currST; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (next && next != curr) { if (next.id.startsWith("list-")) { this.currList = Number(next.id.slice(5)); diff --git a/src/sw.ts b/src/sw.ts index e56dbb0..1e7d72d 100644 --- a/src/sw.ts +++ b/src/sw.ts @@ -10,6 +10,8 @@ type Self = Window & sw: SWReplay; }; +// TODO: Fix this the next time the file is edited. +// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if ((self as Self).registration) { const staticData = new Map(); diff --git a/src/swmanager.ts b/src/swmanager.ts index f1be572..0cd2b46 100644 --- a/src/swmanager.ts +++ b/src/swmanager.ts @@ -27,6 +27,8 @@ export class SWManager { this.appName = newAppName; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/promise-function-async register() { let resolve, reject; @@ -64,6 +66,8 @@ export class SWManager { }; // @ts-expect-error - TS2339 - Property 'scope' does not exist on type 'SWManager'. | TS2339 - Property 'name' does not exist on type 'SWManager'. + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument register(this.scope + this.name, { // @ts-expect-error - TS2339 - Property 'scope' does not exist on type 'SWManager'. registrationOptions: { scope: this.scope }, @@ -105,6 +109,8 @@ export class SWManager { } getSWErrorMsg() { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (navigator.serviceWorker) { // must be loaded from a cross-origin (eg. subdomain) // @ts-expect-error - TS2339 - Property 'requireSubdomainIframe' does not exist on type 'SWManager'. diff --git a/src/url-resources.ts b/src/url-resources.ts index af77660..c02a20f 100644 --- a/src/url-resources.ts +++ b/src/url-resources.ts @@ -117,6 +117,8 @@ class URLResources extends LitElement { } _timedUpdate() { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (this.newQuery !== null) { this.query = this.newQuery; this.newQuery = null; @@ -129,6 +131,8 @@ class URLResources extends LitElement { changedProperties.has("urlSearchType") || changedProperties.has("currMime") ) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.doLoadResources(); const data = { query: this.query, @@ -188,6 +192,8 @@ class URLResources extends LitElement { `${this.collInfo!.apiPrefix}/urls?${params.toString()}`, ); const data = await resp.json(); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.results = isMore ? this.results.concat(data.urls) : data.urls; // can be more than count if multiple mimes this.tryMore = data.urls.length >= count; @@ -229,6 +235,8 @@ class URLResources extends LitElement { const diff = element.scrollHeight - element.scrollTop - element.clientHeight; if (this.tryMore && diff < 40) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.doLoadResources(true); } }