From 40d84f33837fd39a5a0d4054d47cda4f62b866b5 Mon Sep 17 00:00:00 2001 From: Emma Segal-Grossman Date: Thu, 7 Mar 2024 20:12:50 -0500 Subject: [PATCH] ESLint parity with the Browsertrix repo (#288) This copies the rules from the Browsertrix repo, and uses [`suppress-eslint-errors`](https://www.npmjs.com/package/suppress-eslint-errors) to suppose the violations. I'll take a pass at cleaning this up at some point in the future, and let's do our best to address these in the future as we come across them :) This'll help ensure new code being added to this repo is held to the same standard as code in Browsertrix's frontend. --- .eslintrc.js | 24 +++++++++++----- src/appmain.ts | 4 +++ src/chooser.ts | 6 ++++ src/electron-preload.ts | 6 ++++ src/electron-replay-app.ts | 36 +++++++++++++++++++++++ src/embed-receipt.ts | 24 +++++++++------- src/embed.ts | 18 ++++++++++++ src/gdrive.ts | 10 +++++++ src/item-index.ts | 22 ++++++++++++--- src/item-info.ts | 2 ++ src/item.ts | 58 ++++++++++++++++++++++++++++++++++---- src/loader.ts | 16 +++++++++++ src/misc.ts | 2 ++ src/pageentry.ts | 22 +++++++++++++-- src/pages.ts | 54 +++++++++++++++++++++++++++++++++-- src/pageutils.ts | 2 ++ src/replay.ts | 2 ++ src/story.ts | 28 +++++++++++++++--- src/sw.ts | 2 ++ src/swmanager.ts | 6 ++++ src/url-resources.ts | 8 ++++++ 21 files changed, 315 insertions(+), 37 deletions(-) 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 {
- ${this.sortedItems?.map( + ${// TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + this.sortedItems?.map( (item, i) => html`
${this.renderItemInfo(item)} @@ -344,9 +354,13 @@ class ItemIndex extends LitElement { ` : html`
- ${this.sortedItems === null - ? html`Loading Archives...` - : this.renderEmpty()} + ${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + this.sortedItems === null + ? html`Loading Archives...` + : this.renderEmpty() + }
`}
diff --git a/src/item-info.ts b/src/item-info.ts index 3f46775..0372103 100644 --- a/src/item-info.ts +++ b/src/item-info.ts @@ -234,6 +234,8 @@ class ItemInfo extends LitElement { onCopy(event: Event, text: string | undefined) { event.preventDefault(); event.stopPropagation(); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises if (text) navigator.clipboard.writeText(text); return false; } diff --git a/src/item.ts b/src/item.ts index 07891e8..6855b45 100644 --- a/src/item.ts +++ b/src/item.ts @@ -249,6 +249,8 @@ class Item extends LitElement { } willUpdate(changedProperties: Map>) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (changedProperties.has("tabData") && this.tabData) { // Format tab data from URL query params const tabData = {}; @@ -264,6 +266,8 @@ class Item extends LitElement { const prevTabData = changedProperties.get("tabData"); if (this.tabData.url && this.tabData.url !== prevTabData?.url) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.getMultiTimestamps(); } } @@ -279,6 +283,8 @@ class Item extends LitElement { // } if (changedProperties.has("sourceUrl")) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.doUpdateInfo(); } if (changedProperties.has("editable")) { @@ -424,6 +430,8 @@ class Item extends LitElement { } this.hasStory = Boolean( + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition this.itemInfo!.desc || this.itemInfo!.lists?.length, ); @@ -440,6 +448,8 @@ class Item extends LitElement { } onItemLoaded(event) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.doUpdateInfo(); this.loadInfo = null; if (event.detail.sourceUrl) { @@ -478,7 +488,9 @@ class Item extends LitElement { ) { const view = this.hasStory ? "story" - : this.editable || this.itemInfo.pages?.length + : // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + this.editable || this.itemInfo.pages?.length ? "pages" : "resources"; @@ -530,11 +542,15 @@ class Item extends LitElement { ) { this.updateTabData( event.detail.data, + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument event.detail.replaceLoc /*, false */, ); } else if (this.showSidebar && this.tabData.url) { this.updateTabData( event.detail.data, + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument event.detail.replaceLoc /*, true */, ); } @@ -868,6 +884,8 @@ class Item extends LitElement { const isReplay = !!this.tabData.url; const isSidebar = isReplay && this.showSidebar; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!isReplay && this.tabData?.view) { const detail = { title: this.tabLabels[this.tabData.view], @@ -1532,7 +1550,11 @@ class Item extends LitElement { @coll-tab-nav="${this.onItemTabNav}" id="story" .isSidebar="${isSidebar}" - class="${isStory ? "" : "is-hidden"} ${isSidebar ? "sidebar" : ""}" + class="${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + isStory ? "" : "is-hidden" + } ${isSidebar ? "sidebar" : ""}" role="${ifDefined(isSidebar ? undefined : "main")}" > ` @@ -1547,9 +1569,11 @@ class Item extends LitElement { @coll-tab-nav="${this.onItemTabNav}" id="resources" .isSidebar="${isSidebar}" - class="is-paddingless ${isResources ? "" : "is-hidden"} ${isSidebar - ? "sidebar" - : ""}" + class="is-paddingless ${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + isResources ? "" : "is-hidden" + } ${isSidebar ? "sidebar" : ""}" role="${ifDefined(isSidebar ? undefined : "main")}" > ` @@ -1567,7 +1591,11 @@ class Item extends LitElement { @coll-tab-nav="${this.onItemTabNav}" id="pages" @coll-update="${this.onItemUpdate}" - class="${isPages ? "" : "is-hidden"} ${isSidebar ? "sidebar" : ""}" + class="${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + isPages ? "" : "is-hidden" + } ${isSidebar ? "sidebar" : ""}" role="${ifDefined(isSidebar ? undefined : "main")}" > ` @@ -1608,8 +1636,12 @@ class Item extends LitElement { event.preventDefault(); this.menuActive = false; if (!this.isFullscreen) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.requestFullscreen(); } else { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises document.exitFullscreen(); } } @@ -1650,6 +1682,8 @@ class Item extends LitElement { async onFavIcons(event) { for (const icon of event.detail.icons) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const resp = await fetch(icon.href); if (resp.status === 200) { const ct = resp.headers.get("Content-Type"); @@ -1672,6 +1706,8 @@ class Item extends LitElement { ? event.detail.reload : true; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/no-unsafe-argument this.deleteFully(reload); } @@ -1716,10 +1752,14 @@ class Item extends LitElement { const btn = event.currentTarget as HTMLButtonElement; const dropdown = btn.closest("sl-dropdown"); const relatedTarget = event.relatedTarget as HTMLElement; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (relatedTarget && dropdown?.contains(relatedTarget)) { return; } if (dropdown?.open) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises dropdown.hide(); } } @@ -1753,6 +1793,8 @@ class Item extends LitElement { } _stringToParams(value) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const q = new URLSearchParams(value.slice(RWP_SCHEME.length)); const data: Partial = {}; data.url = ""; @@ -1812,9 +1854,13 @@ class Item extends LitElement { this.dispatchEvent(new CustomEvent("about-show")); } onShowInfoDialog() { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.archiveInfoDialog.value?.show(); } onHideInfoDialog() { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.archiveInfoDialog.value?.hide(); } } diff --git a/src/loader.ts b/src/loader.ts index dcb48eb..48da1c9 100644 --- a/src/loader.ts +++ b/src/loader.ts @@ -47,6 +47,8 @@ class Loader extends LitElement { if (!this.noWebWorker) { this.worker = new Worker(this.swName!); } else { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!navigator.serviceWorker) { return; } @@ -144,6 +146,8 @@ class Loader extends LitElement { switch (scheme) { case "googledrive": this.state = "googledrive"; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition source = (await this.googledriveInit()) ?? null; break; @@ -235,16 +239,22 @@ You can select a file to upload from the main page by clicking the 'Choose File. } } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/promise-function-async googledriveInit() { this._gdWait = new Promise((resolve) => (this._gdResolve = resolve)); return this._gdWait; } onLoadReady(event: CustomEvent) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (this._gdResolve) { //const digest = await digestMessage(url, 'SHA-256'); //this.coll = "id-" + digest.slice(0, 12); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this._gdResolve(event.detail); } } @@ -261,6 +271,8 @@ You can select a file to upload from the main page by clicking the 'Choose File. return; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (navigator.serviceWorker?.controller) { navigator.serviceWorker.controller.postMessage(msg); if (this.pingInterval) { @@ -274,6 +286,8 @@ You can select a file to upload from the main page by clicking the 'Choose File. Boolean(this.sourceUrl && changedProperties.has("sourceUrl")) || changedProperties.has("tryFileHandle") ) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.doLoad(); } } @@ -425,6 +439,8 @@ You can select a file to upload from the main page by clicking the 'Choose File. mode: "read", }); if (result === "granted") { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.doLoad(); } } diff --git a/src/misc.ts b/src/misc.ts index 56b9fc1..509703e 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -104,6 +104,8 @@ class FaIcon extends LitElement { ${ // @ts-expect-error - TS2339 - Property 'svg' does not exist on type 'FaIcon'. + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument unsafeSVG(this.svg) } diff --git a/src/pageentry.ts b/src/pageentry.ts index 03be52c..90498e8 100644 --- a/src/pageentry.ts +++ b/src/pageentry.ts @@ -218,8 +218,20 @@ class PageEntry extends LitElement { ` : ""}
-
${date ? date.toLocaleDateString() : ""}
-
${date ? date.toLocaleTimeString() : ""}
+
+ ${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + date ? date.toLocaleDateString() : "" + } +
+
+ ${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + date ? date.toLocaleTimeString() : "" + } +
@@ -246,7 +258,11 @@ class PageEntry extends LitElement { >${this.thumbnailValid ? this.renderFavicon() : ""}

- ${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) { if (changedProperties.has("collInfo")) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.updateTextSearch(); } else if (changedProperties.has("query")) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.filter(); } else if (changedProperties.has("currList")) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.filter(); } else if (changedProperties.has("showAllPages")) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.filter(); } if (changedProperties.has("active") && this.active) { if (this.changeNeeded) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.filter(); } } @@ -241,6 +253,8 @@ class Pages extends LitElement { this.dispatchEvent(new CustomEvent("coll-tab-nav", { detail: { data } })); } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/promise-function-async addPages(pages) { const flex = new FlexIndex(); @@ -254,6 +268,8 @@ class Pages extends LitElement { ); return Promise.all( + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/promise-function-async pages.map((page, index) => { let text = page.url; if (page.title) { @@ -262,6 +278,8 @@ class Pages extends LitElement { if (page.text) { text += " " + page.text; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return flex.addAsync(index, text); }), ); @@ -285,6 +303,8 @@ class Pages extends LitElement { if (!resp || !Number(resp.headers.get("Content-Length"))) { resp = await fetch(indexUrl); if (resp.status === 200 && Number(resp.headers.get("Content-Length"))) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises cache.put(indexUrl, resp.clone()); } } @@ -723,7 +743,11 @@ class Pages extends LitElement { @@ -733,7 +757,11 @@ class Pages extends LitElement { @@ -743,7 +771,11 @@ class Pages extends LitElement { @@ -883,8 +915,12 @@ class Pages extends LitElement { if (page.url === this.url) { let ts = page.timestamp; if (!ts && page.date) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ts = getTS(page.date); } else if (typeof page.ts === "string") { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument ts = getTS(page.ts); } return ts === this.ts; @@ -945,6 +981,8 @@ class Pages extends LitElement { const body = JSON.stringify({ title }); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises fetch(`${this.collInfo!.apiPrefix}/metadata`, { method: "POST", body, @@ -993,8 +1031,12 @@ class Pages extends LitElement { onSelectToggle(event) { const { page, selected } = event.detail; if (selected) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.selectedPages.add(page); } else { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.selectedPages.delete(page); } this.allSelected = this.selectedPages.size === this.sortedPages.length; @@ -1025,6 +1067,8 @@ class Pages extends LitElement { "pages", selected ? Array.from(this.selectedPages.keys()).join(",") : "all", ); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument params.set("format", format); if (this.collInfo!.filename) { params.set("filename", this.collInfo!.filename); @@ -1077,6 +1121,8 @@ class Pages extends LitElement { continue; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const inx = this.collInfo!.pages.indexOf(page); if (inx < 0) { continue; @@ -1088,6 +1134,8 @@ class Pages extends LitElement { this.toDeletePages = null; this.toDeletePage = null; + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.updateTextSearch(); this.requestUpdate(); } diff --git a/src/pageutils.ts b/src/pageutils.ts index be95213..cf28403 100644 --- a/src/pageutils.ts +++ b/src/pageutils.ts @@ -43,6 +43,8 @@ function getDateFromTS(ts: string | number) { let date: Date | null = null; date = new Date(ts); const timestamp = + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition date && date instanceof Date ? getTS(date.toISOString()) : ""; return timestamp; } diff --git a/src/replay.ts b/src/replay.ts index bf1915e..b87251f 100644 --- a/src/replay.ts +++ b/src/replay.ts @@ -48,6 +48,8 @@ class Replay extends LitElement { firstUpdated() { window.addEventListener("message", (event) => this.onReplayMessage(event)); + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/promise-function-async navigator.serviceWorker.addEventListener("message", (event) => this.handleAuthMessage(event), ); diff --git a/src/story.ts b/src/story.ts index 48510fd..ac706ad 100644 --- a/src/story.ts +++ b/src/story.ts @@ -54,6 +54,8 @@ class Story extends LitElement { updated(changedProperties: PropertyValues) { if (changedProperties.has("collInfo")) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-floating-promises this.doLoadCurated(); } @@ -88,6 +90,8 @@ class Story extends LitElement { this.splitter = null; } + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (sidebar && content && !this.splitter) { const opts: Split.Options = { sizes: [20, 80], @@ -114,6 +118,8 @@ class Story extends LitElement { } for (const curated of this.collInfo.curatedPages) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition if (!this.curatedPageMap[curated.list]) { this.curatedPageMap[curated.list] = []; } @@ -299,6 +305,8 @@ class Story extends LitElement { ${ // @ts-expect-error - TS2339 - Property 'collInfo' does not exist on type 'Story'. | TS2339 - Property 'collInfo' does not exist on type 'Story'. + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.collInfo.desc ? unsafeHTML(marked(this.collInfo.desc)) : "" } @@ -317,9 +325,13 @@ class Story extends LitElement {

${list.title}

${list.desc}

    - ${this.curatedPageMap[list.id] - ? this.curatedPageMap[list.id].map((p) => this.renderCPage(p)) - : html``} + ${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + this.curatedPageMap[list.id] + ? this.curatedPageMap[list.id].map((p) => this.renderCPage(p)) + : html`` + }
@@ -328,6 +340,8 @@ class Story extends LitElement { } renderCPage(p) { + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const date = new Date(p.ts); const ts = getTS(date.toISOString()); @@ -338,7 +352,11 @@ class Story extends LitElement { @click="${this.onReplay}" data-url="${p.url}" data-ts="${ts}" - href="${getReplayLink("story", p.url, ts)}" + href="${ + // TODO: Fix this the next time the file is edited. + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + getReplayLink("story", p.url, ts) + }" >

${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); } }