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.
This commit is contained in:
Emma Segal-Grossman
2024-03-07 20:12:50 -05:00
committed by GitHub
parent 57123e8a63
commit 40d84f3383
21 changed files with 315 additions and 37 deletions
+17 -7
View File
@@ -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: [
+4
View File
@@ -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();
}
+6
View File
@@ -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]);
}
+6
View File
@@ -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();
+36
View File
@@ -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);
}
+14 -10
View File
@@ -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`
<fa-icon
class="menu-logo mr-1"
size="1.0rem"
aria-hidden="true"
.svg=${this.appLogo}
></fa-icon>
`
: nothing}
>${
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
this.appLogo
? html`
<fa-icon
class="menu-logo mr-1"
size="1.0rem"
aria-hidden="true"
.svg=${this.appLogo}
></fa-icon>
`
: nothing
}
Powered by ReplayWeb.page
</a>
</span>
+18
View File
@@ -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 };
+10
View File
@@ -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,
);
});
+18 -4
View File
@@ -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 {
</div>
<div class="coll-list">
${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`
<div class="coll-block panel-block">
${this.renderItemInfo(item)}
@@ -344,9 +354,13 @@ class ItemIndex extends LitElement {
`
: html`
<div class="panel-block extra-padding">
${this.sortedItems === null
? html`<i>Loading Archives...</i>`
: 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`<i>Loading Archives...</i>`
: this.renderEmpty()
}
</div>
`}
</div>
+2
View File
@@ -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;
}
+52 -6
View File
@@ -249,6 +249,8 @@ class Item extends LitElement {
}
willUpdate(changedProperties: Map<string, Record<string, unknown>>) {
// 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")}"
>
</wr-coll-story>`
@@ -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")}"
>
</wr-coll-resources>`
@@ -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")}"
>
</wr-page-view>`
@@ -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<SlDropdown>("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<URLResource> = {};
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();
}
}
+16
View File
@@ -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();
}
}
+2
View File
@@ -104,6 +104,8 @@ class FaIcon extends LitElement {
<g>
${
// @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)
}
</g>
+19 -3
View File
@@ -218,8 +218,20 @@ class PageEntry extends LitElement {
`
: ""}
<div class="column col-date is-2">
<div>${date ? date.toLocaleDateString() : ""}</div>
<div>${date ? date.toLocaleTimeString() : ""}</div>
<div>
${
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
date ? date.toLocaleDateString() : ""
}
</div>
<div>
${
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
date ? date.toLocaleTimeString() : ""
}
</div>
</div>
<div class="column">
<div class="media">
@@ -246,7 +258,11 @@ class PageEntry extends LitElement {
>${this.thumbnailValid ? this.renderFavicon() : ""}
</p>
<p class="has-text-grey-dark text is-inline-date">
${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() : ""
}
</p>
</a>
${this.textSnippet
+51 -3
View File
@@ -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<this>) {
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 {
<a
role="button"
href="#"
@click="${(e) => this.onDownload(e, "wacz")}"
@click="${
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/promise-function-async
(e) => this.onDownload(e, "wacz")
}"
@keyup="${clickOnSpacebarPress}"
class="dropdown-item"
>
@@ -733,7 +757,11 @@ class Pages extends LitElement {
<a
role="button"
href="#"
@click="${(e) => this.onDownload(e, "warc")}"
@click="${
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/promise-function-async
(e) => this.onDownload(e, "warc")
}"
@keyup="${clickOnSpacebarPress}"
class="dropdown-item"
>
@@ -743,7 +771,11 @@ class Pages extends LitElement {
<a
role="button"
href="#"
@click="${(e) => this.onDownload(e, "warc1.0")}"
@click="${
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/promise-function-async
(e) => this.onDownload(e, "warc1.0")
}"
@keyup="${clickOnSpacebarPress}"
class="dropdown-item"
>
@@ -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();
}
+2
View File
@@ -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;
}
+2
View File
@@ -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),
);
+24 -4
View File
@@ -54,6 +54,8 @@ class Story extends LitElement {
updated(changedProperties: PropertyValues<this>) {
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)) : ""
}
</section>
@@ -317,9 +325,13 @@ class Story extends LitElement {
<h3>${list.title}</h3>
<p>${list.desc}</p>
<ol>
${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``
}
</ol>
</div>
</article>
@@ -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 class="is-size-6 has-text-weight-bold has-text-link">${p.title}</p>
<p class="has-text-dark">${p.url}</p>
@@ -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));
+2
View File
@@ -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();
+6
View File
@@ -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'.
+8
View File
@@ -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);
}
}