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", fixStyle: "inline-type-imports",
}, },
], ],
"@typescript-eslint/consistent-type-exports": "error",
"@typescript-eslint/prefer-readonly": "warn", "@typescript-eslint/prefer-readonly": "warn",
"@typescript-eslint/class-literal-property-style": ["warn", "getters"], "@typescript-eslint/class-literal-property-style": ["warn", "getters"],
"@typescript-eslint/consistent-generic-constructors": "error", "@typescript-eslint/consistent-generic-constructors": "error",
@@ -41,6 +42,13 @@ module.exports = {
// "@typescript-eslint/prefer-nullish-coalescing": "warn", // "@typescript-eslint/prefer-nullish-coalescing": "warn",
"@typescript-eslint/prefer-optional-chain": "warn", "@typescript-eslint/prefer-optional-chain": "warn",
"@typescript-eslint/prefer-string-starts-ends-with": "error", "@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 */ /* end stylistic rules */
/* start recommended rules */ /* start recommended rules */
@@ -48,13 +56,13 @@ module.exports = {
"@typescript-eslint/no-base-to-string": "warn", "@typescript-eslint/no-base-to-string": "warn",
"@typescript-eslint/no-duplicate-enum-values": "error", "@typescript-eslint/no-duplicate-enum-values": "error",
"@typescript-eslint/no-duplicate-type-constituents": "warn", "@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-extra-non-null-assertion": "error",
// "@typescript-eslint/no-floating-promises": "warn", "@typescript-eslint/no-floating-promises": "warn",
"@typescript-eslint/no-for-in-array": "warn", "@typescript-eslint/no-for-in-array": "warn",
"no-unused-vars": "off", "no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": [ "@typescript-eslint/no-unused-vars": [
"warn", "error",
{ {
argsIgnorePattern: "^_", argsIgnorePattern: "^_",
varsIgnorePattern: "^_", varsIgnorePattern: "^_",
@@ -68,7 +76,7 @@ module.exports = {
"@typescript-eslint/no-misused-new": "error", "@typescript-eslint/no-misused-new": "error",
"@typescript-eslint/no-misused-promises": [ "@typescript-eslint/no-misused-promises": [
"error", "error",
{ checksVoidReturn: { arguments: false } }, { checksVoidReturn: false },
], ],
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error", "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
"@typescript-eslint/no-non-null-asserted-optional-chain": "warn", "@typescript-eslint/no-non-null-asserted-optional-chain": "warn",
@@ -76,18 +84,20 @@ module.exports = {
"@typescript-eslint/no-this-alias": "warn", "@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/no-unnecessary-type-assertion": "warn", "@typescript-eslint/no-unnecessary-type-assertion": "warn",
"@typescript-eslint/no-unnecessary-type-constraint": "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-assignment": "warn",
// "@typescript-eslint/no-unsafe-call": "warn", // "@typescript-eslint/no-unsafe-call": "warn",
"@typescript-eslint/no-unsafe-declaration-merging": "warn", "@typescript-eslint/no-unsafe-declaration-merging": "warn",
"@typescript-eslint/no-unsafe-enum-comparison": "warn", "@typescript-eslint/no-unsafe-enum-comparison": "warn",
// "@typescript-eslint/no-unsafe-member-access": "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", "@typescript-eslint/prefer-as-const": "warn",
"require-await": "off", "require-await": "off",
"@typescript-eslint/require-await": "warn", // "@typescript-eslint/require-await": "warn",
"@typescript-eslint/restrict-template-expressions": "warn", "@typescript-eslint/restrict-template-expressions": "warn",
"@typescript-eslint/unbound-method": "off", "@typescript-eslint/unbound-method": "off",
"@typescript-eslint/method-signature-style": "error",
}, },
reportUnusedDisableDirectives: true, reportUnusedDisableDirectives: true,
ignorePatterns: [ ignorePatterns: [
+4
View File
@@ -646,6 +646,8 @@ export class ReplayWebApp extends LitElement {
onStartLoad(event) { onStartLoad(event) {
// just redirect right away? // 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); this.pageParams.set("source", event.detail.sourceUrl);
const url = new URL(window.location.href); const url = new URL(window.location.href);
@@ -678,6 +680,8 @@ export class ReplayWebApp extends LitElement {
//this.initRoute(); //this.initRoute();
if (event.detail.sourceUrl !== this.sourceUrl) { 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); this.pageParams.set("source", event.detail.sourceUrl);
window.location.search = this.pageParams.toString(); window.location.search = this.pageParams.toString();
} }
+6
View File
@@ -21,6 +21,8 @@ export class Chooser extends LitElement {
droppedFile: FileWithPath | null = null; droppedFile: FileWithPath | null = null;
@property({ type: Boolean }) @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; hasNativeFS = !!window.showOpenFilePicker && !IS_APP;
@property({ type: Object }) @property({ type: Object })
@@ -60,6 +62,8 @@ export class Chooser extends LitElement {
.flat(2); .flat(2);
const fileHasAllowedExtension = allowedFileExtensions.some( 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), (extension) => this.droppedFile?.name.endsWith(extension),
); );
@@ -77,6 +81,8 @@ export class Chooser extends LitElement {
if (event.currentTarget.files.length === 0) { if (event.currentTarget.files.length === 0) {
return; 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]); this.setFile(event.currentTarget.files[0]);
} }
+6
View File
@@ -17,11 +17,15 @@ async function getColl(name: string) {
await dbs[name].initing; 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]; return dbs[name];
} }
async function getDB(name: string) { async function getDB(name: string) {
const coll = await getColl(name); 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; return coll.store;
} }
@@ -43,6 +47,8 @@ async function getResponse(
return; 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 headers = Object.fromEntries(result.headers.entries());
const buffer = await result.getBuffer(); 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()); app.whenReady().then(() => this.onAppReady());
// Quit when all windows are closed. // Quit when all windows are closed.
@@ -161,6 +163,8 @@ class ElectronReplayApp {
autoUpdater.logger = log; autoUpdater.logger = log;
// @ts-expect-error - TS2339 - Property 'transports' does not exist on type 'Logger'. // @ts-expect-error - TS2339 - Property 'transports' does not exist on type 'Logger'.
autoUpdater.logger.transports.file.level = "info"; 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(); autoUpdater.checkForUpdatesAndNotify();
} }
@@ -173,12 +177,16 @@ class ElectronReplayApp {
contents.setWindowOpenHandler(({ url }) => { contents.setWindowOpenHandler(({ url }) => {
// load docs in native browser for now // load docs in native browser for now
if (url === STATIC_PREFIX + "docs") { 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/"); shell.openExternal("https://replayweb.page/docs/");
return { action: "deny" }; return { action: "deny" };
} }
// load external URLs in native browser // load external URLs in native browser
if (!url.startsWith(STATIC_PREFIX)) { 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); shell.openExternal(url);
return { action: "deny" }; return { action: "deny" };
} }
@@ -189,10 +197,14 @@ class ElectronReplayApp {
const sesh = session.defaultSession; 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) => sesh.protocol.interceptStreamProtocol("http", (request, callback) =>
this.doIntercept(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) => protocol.registerStreamProtocol(FILE_PROTO, (request, callback) =>
this.doHandleFile(request, callback), this.doHandleFile(request, callback),
); );
@@ -211,9 +223,13 @@ class ElectronReplayApp {
return; 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 filename = url.fileURLToPath(request.url.replace(FILE_PROTO, "file"));
const headers = { "Content-Type": "application/octet-stream" }; 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); const reqHeaders = new Headers(request.headers);
if (filename) { if (filename) {
@@ -283,6 +299,8 @@ class ElectronReplayApp {
filename = "docs/index.html"; 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); let ext = path.extname(filename);
if (!ext) { if (!ext) {
ext = ".html"; ext = ".html";
@@ -292,6 +310,8 @@ class ElectronReplayApp {
const mimeType = mime.contentType(ext); const mimeType = mime.contentType(ext);
if (mimeType) { 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); const fullPath = path.join(this.staticContentPath, filename);
console.log("fullPath: " + fullPath); console.log("fullPath: " + fullPath);
@@ -333,6 +353,8 @@ class ElectronReplayApp {
let response; let response;
try { 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 }); response = await fetch(url, { method, headers, body });
} catch (e) { } catch (e) {
console.warn("fetch failed for: " + url); console.warn("fetch failed for: " + url);
@@ -342,6 +364,8 @@ class ElectronReplayApp {
const data = method === "HEAD" ? null : response.body; const data = method === "HEAD" ? null : response.body;
const statusCode = response.status; 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()); headers = Object.fromEntries(response.headers.entries());
callback({ statusCode, headers, data }); callback({ statusCode, headers, data });
} }
@@ -379,6 +403,8 @@ class ElectronReplayApp {
console.log("got response for: " + url); 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); headers = new Headers(headers);
const date = new Date(); const date = new Date();
@@ -399,11 +425,15 @@ class ElectronReplayApp {
useBaseRules: true, 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); request.headers = new Headers(request.headers);
try { try {
response = await rewriter.rewrite(response, request); 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()); headers = Object.fromEntries(response.headers.entries());
let data = await response.getBuffer(); let data = await response.getBuffer();
@@ -481,6 +511,8 @@ class ElectronReplayApp {
theWindow.maximize(); 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); theWindow.loadURL(STATIC_PREFIX + this.mainWindowUrl + sourceString);
if (process.env.NODE_ENV === "development") { if (process.env.NODE_ENV === "development") {
theWindow.webContents.openDevTools(); theWindow.webContents.openDevTools();
@@ -513,10 +545,14 @@ class ElectronReplayApp {
const openTS = argv.ts || argv.timestamp; const openTS = argv.ts || argv.timestamp;
if (openUrl) { 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); urlParams.set("url", openUrl);
} }
if (openTS) { 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); urlParams.set("ts", openTS);
} }
+14 -10
View File
@@ -319,16 +319,20 @@ export class RWPEmbedReceipt extends LitElement {
class="has-text-black" class="has-text-black"
target="_blank" target="_blank"
href="https://github.com/webrecorder/replayweb.page" href="https://github.com/webrecorder/replayweb.page"
>${this.appLogo >${
? html` // TODO: Fix this the next time the file is edited.
<fa-icon // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
class="menu-logo mr-1" this.appLogo
size="1.0rem" ? html`
aria-hidden="true" <fa-icon
.svg=${this.appLogo} class="menu-logo mr-1"
></fa-icon> size="1.0rem"
` aria-hidden="true"
: nothing} .svg=${this.appLogo}
></fa-icon>
`
: nothing
}
Powered by ReplayWeb.page Powered by ReplayWeb.page
</a> </a>
</span> </span>
+18
View File
@@ -103,6 +103,8 @@ class Embed extends LitElement {
await this.swmanager.register(); await this.swmanager.register();
this.inited = true; this.inited = true;
} catch (e) { } 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); this.errorMessage = this.swmanager.renderErrorReport(this.logo);
} }
} }
@@ -123,6 +125,8 @@ class Embed extends LitElement {
return; 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 currHash = new URLSearchParams(event.data);
const url = new URL(window.location.href); const url = new URL(window.location.href);
url.hash = "#" + currHash.toString(); 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", "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(); this.doRegister();
window.addEventListener("message", (event) => this.handleMessage(event)); window.addEventListener("message", (event) => this.handleMessage(event));
@@ -156,12 +162,16 @@ class Embed extends LitElement {
if ( if (
// @ts-expect-error - TS2339 - Property 'GestureEvent' does not exist on type 'Window & typeof globalThis'. // @ts-expect-error - TS2339 - Property 'GestureEvent' does not exist on type 'Window & typeof globalThis'.
window.GestureEvent !== undefined && 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 window.SharedWorker === undefined
) { ) {
this.noWebWorker = true; this.noWebWorker = true;
} }
// if no storage manager or estimate, don't cache // 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) { if (!navigator.storage?.estimate) {
this.noCache = true; this.noCache = true;
} }
@@ -189,6 +199,8 @@ class Embed extends LitElement {
} }
mergeConfigs() { mergeConfigs() {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!this.customConfig) { if (!this.customConfig) {
return this.config; return this.config;
} }
@@ -217,6 +229,8 @@ class Embed extends LitElement {
this.source = this.src; 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 source = new URL(this.source, document.baseURI);
const config = this.mergeConfigs(); const config = this.mergeConfigs();
@@ -353,6 +367,8 @@ class Embed extends LitElement {
this.reloadCount <= 2 this.reloadCount <= 2
) { ) {
this.reloadCount++; 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); setTimeout(() => win.location.reload(), 100);
return; return;
} }
@@ -375,6 +391,8 @@ async function main() {
customElements.define("replay-web-page", Embed); 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(); main();
export { Embed }; export { Embed };
+10
View File
@@ -31,6 +31,8 @@ class GDrive extends LitElement {
if (changedProperties.has("sourceUrl")) { if (changedProperties.has("sourceUrl")) {
this.error = false; this.error = false;
this.state = "trypublic"; 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) => { this.tryPublicAccess().then((result) => {
if (!result) { if (!result) {
this.state = "tryauto"; this.state = "tryauto";
@@ -67,6 +69,8 @@ class GDrive extends LitElement {
try { try {
const abort = new AbortController(); const abort = new AbortController();
const signal = abort.signal; 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 }); resp = await fetch(publicUrl, { signal });
abort.abort(); abort.abort();
if (resp.status != 200) { if (resp.status != 200) {
@@ -99,6 +103,8 @@ class GDrive extends LitElement {
this.state = "trymanual"; this.state = "trymanual";
} }
} else { } else {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.authed(response); this.authed(response);
} }
}); });
@@ -107,6 +113,8 @@ class GDrive extends LitElement {
onClickAuth() { onClickAuth() {
this.gauth("select_account", (response) => { this.gauth("select_account", (response) => {
if (!response.error) { 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); this.authed(response);
} }
}); });
@@ -201,6 +209,8 @@ class GDrive extends LitElement {
response_type: "token", response_type: "token",
prompt, prompt,
}, },
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
callback, callback,
); );
}); });
+18 -4
View File
@@ -64,6 +64,8 @@ class ItemIndex extends LitElement {
} }
firstUpdated() { firstUpdated() {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.loadItems(); this.loadItems();
} }
@@ -112,6 +114,8 @@ class ItemIndex extends LitElement {
this.sortedItems = []; this.sortedItems = [];
} catch (e) { } catch (e) {
// likely no sw registered yet, or waiting for new sw to register, retry again // 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); setTimeout(() => this.loadItems(), 500);
} }
} }
@@ -120,6 +124,8 @@ class ItemIndex extends LitElement {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!this.sortedItems) { if (!this.sortedItems) {
return; return;
} }
@@ -128,6 +134,8 @@ class ItemIndex extends LitElement {
const item = this.sortedItems[index]; 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]) { if (!item || this._deleting[item.sourceUrl]) {
return; return;
} }
@@ -318,7 +326,9 @@ class ItemIndex extends LitElement {
</div> </div>
<div class="coll-list"> <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` (item, i) => html`
<div class="coll-block panel-block"> <div class="coll-block panel-block">
${this.renderItemInfo(item)} ${this.renderItemInfo(item)}
@@ -344,9 +354,13 @@ class ItemIndex extends LitElement {
` `
: html` : html`
<div class="panel-block extra-padding"> <div class="panel-block extra-padding">
${this.sortedItems === null ${
? html`<i>Loading Archives...</i>` // TODO: Fix this the next time the file is edited.
: this.renderEmpty()} // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
this.sortedItems === null
? html`<i>Loading Archives...</i>`
: this.renderEmpty()
}
</div> </div>
`} `}
</div> </div>
+2
View File
@@ -234,6 +234,8 @@ class ItemInfo extends LitElement {
onCopy(event: Event, text: string | undefined) { onCopy(event: Event, text: string | undefined) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); 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); if (text) navigator.clipboard.writeText(text);
return false; return false;
} }
+52 -6
View File
@@ -249,6 +249,8 @@ class Item extends LitElement {
} }
willUpdate(changedProperties: Map<string, Record<string, unknown>>) { 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) { if (changedProperties.has("tabData") && this.tabData) {
// Format tab data from URL query params // Format tab data from URL query params
const tabData = {}; const tabData = {};
@@ -264,6 +266,8 @@ class Item extends LitElement {
const prevTabData = changedProperties.get("tabData"); const prevTabData = changedProperties.get("tabData");
if (this.tabData.url && this.tabData.url !== prevTabData?.url) { 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(); this.getMultiTimestamps();
} }
} }
@@ -279,6 +283,8 @@ class Item extends LitElement {
// } // }
if (changedProperties.has("sourceUrl")) { 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(); this.doUpdateInfo();
} }
if (changedProperties.has("editable")) { if (changedProperties.has("editable")) {
@@ -424,6 +430,8 @@ class Item extends LitElement {
} }
this.hasStory = Boolean( 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, this.itemInfo!.desc || this.itemInfo!.lists?.length,
); );
@@ -440,6 +448,8 @@ class Item extends LitElement {
} }
onItemLoaded(event) { onItemLoaded(event) {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.doUpdateInfo(); this.doUpdateInfo();
this.loadInfo = null; this.loadInfo = null;
if (event.detail.sourceUrl) { if (event.detail.sourceUrl) {
@@ -478,7 +488,9 @@ class Item extends LitElement {
) { ) {
const view = this.hasStory const view = this.hasStory
? "story" ? "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" ? "pages"
: "resources"; : "resources";
@@ -530,11 +542,15 @@ class Item extends LitElement {
) { ) {
this.updateTabData( this.updateTabData(
event.detail.data, 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 */, event.detail.replaceLoc /*, false */,
); );
} else if (this.showSidebar && this.tabData.url) { } else if (this.showSidebar && this.tabData.url) {
this.updateTabData( this.updateTabData(
event.detail.data, 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 */, event.detail.replaceLoc /*, true */,
); );
} }
@@ -868,6 +884,8 @@ class Item extends LitElement {
const isReplay = !!this.tabData.url; const isReplay = !!this.tabData.url;
const isSidebar = isReplay && this.showSidebar; 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) { if (!isReplay && this.tabData?.view) {
const detail = { const detail = {
title: this.tabLabels[this.tabData.view], title: this.tabLabels[this.tabData.view],
@@ -1532,7 +1550,11 @@ class Item extends LitElement {
@coll-tab-nav="${this.onItemTabNav}" @coll-tab-nav="${this.onItemTabNav}"
id="story" id="story"
.isSidebar="${isSidebar}" .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")}" role="${ifDefined(isSidebar ? undefined : "main")}"
> >
</wr-coll-story>` </wr-coll-story>`
@@ -1547,9 +1569,11 @@ class Item extends LitElement {
@coll-tab-nav="${this.onItemTabNav}" @coll-tab-nav="${this.onItemTabNav}"
id="resources" id="resources"
.isSidebar="${isSidebar}" .isSidebar="${isSidebar}"
class="is-paddingless ${isResources ? "" : "is-hidden"} ${isSidebar class="is-paddingless ${
? "sidebar" // 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")}" role="${ifDefined(isSidebar ? undefined : "main")}"
> >
</wr-coll-resources>` </wr-coll-resources>`
@@ -1567,7 +1591,11 @@ class Item extends LitElement {
@coll-tab-nav="${this.onItemTabNav}" @coll-tab-nav="${this.onItemTabNav}"
id="pages" id="pages"
@coll-update="${this.onItemUpdate}" @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")}" role="${ifDefined(isSidebar ? undefined : "main")}"
> >
</wr-page-view>` </wr-page-view>`
@@ -1608,8 +1636,12 @@ class Item extends LitElement {
event.preventDefault(); event.preventDefault();
this.menuActive = false; this.menuActive = false;
if (!this.isFullscreen) { if (!this.isFullscreen) {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.requestFullscreen(); this.requestFullscreen();
} else { } else {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
document.exitFullscreen(); document.exitFullscreen();
} }
} }
@@ -1650,6 +1682,8 @@ class Item extends LitElement {
async onFavIcons(event) { async onFavIcons(event) {
for (const icon of event.detail.icons) { 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); const resp = await fetch(icon.href);
if (resp.status === 200) { if (resp.status === 200) {
const ct = resp.headers.get("Content-Type"); const ct = resp.headers.get("Content-Type");
@@ -1672,6 +1706,8 @@ class Item extends LitElement {
? event.detail.reload ? event.detail.reload
: true; : 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); this.deleteFully(reload);
} }
@@ -1716,10 +1752,14 @@ class Item extends LitElement {
const btn = event.currentTarget as HTMLButtonElement; const btn = event.currentTarget as HTMLButtonElement;
const dropdown = btn.closest<SlDropdown>("sl-dropdown"); const dropdown = btn.closest<SlDropdown>("sl-dropdown");
const relatedTarget = event.relatedTarget as HTMLElement; 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)) { if (relatedTarget && dropdown?.contains(relatedTarget)) {
return; return;
} }
if (dropdown?.open) { if (dropdown?.open) {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
dropdown.hide(); dropdown.hide();
} }
} }
@@ -1753,6 +1793,8 @@ class Item extends LitElement {
} }
_stringToParams(value) { _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 q = new URLSearchParams(value.slice(RWP_SCHEME.length));
const data: Partial<URLResource> = {}; const data: Partial<URLResource> = {};
data.url = ""; data.url = "";
@@ -1812,9 +1854,13 @@ class Item extends LitElement {
this.dispatchEvent(new CustomEvent("about-show")); this.dispatchEvent(new CustomEvent("about-show"));
} }
onShowInfoDialog() { onShowInfoDialog() {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.archiveInfoDialog.value?.show(); this.archiveInfoDialog.value?.show();
} }
onHideInfoDialog() { onHideInfoDialog() {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.archiveInfoDialog.value?.hide(); this.archiveInfoDialog.value?.hide();
} }
} }
+16
View File
@@ -47,6 +47,8 @@ class Loader extends LitElement {
if (!this.noWebWorker) { if (!this.noWebWorker) {
this.worker = new Worker(this.swName!); this.worker = new Worker(this.swName!);
} else { } else {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!navigator.serviceWorker) { if (!navigator.serviceWorker) {
return; return;
} }
@@ -144,6 +146,8 @@ class Loader extends LitElement {
switch (scheme) { switch (scheme) {
case "googledrive": case "googledrive":
this.state = "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; source = (await this.googledriveInit()) ?? null;
break; 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() { googledriveInit() {
this._gdWait = new Promise((resolve) => (this._gdResolve = resolve)); this._gdWait = new Promise((resolve) => (this._gdResolve = resolve));
return this._gdWait; return this._gdWait;
} }
onLoadReady(event: CustomEvent) { 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) { if (this._gdResolve) {
//const digest = await digestMessage(url, 'SHA-256'); //const digest = await digestMessage(url, 'SHA-256');
//this.coll = "id-" + digest.slice(0, 12); //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); 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; return;
} }
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (navigator.serviceWorker?.controller) { if (navigator.serviceWorker?.controller) {
navigator.serviceWorker.controller.postMessage(msg); navigator.serviceWorker.controller.postMessage(msg);
if (this.pingInterval) { 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")) || Boolean(this.sourceUrl && changedProperties.has("sourceUrl")) ||
changedProperties.has("tryFileHandle") changedProperties.has("tryFileHandle")
) { ) {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.doLoad(); this.doLoad();
} }
} }
@@ -425,6 +439,8 @@ You can select a file to upload from the main page by clicking the 'Choose File.
mode: "read", mode: "read",
}); });
if (result === "granted") { if (result === "granted") {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.doLoad(); this.doLoad();
} }
} }
+2
View File
@@ -104,6 +104,8 @@ class FaIcon extends LitElement {
<g> <g>
${ ${
// @ts-expect-error - TS2339 - Property 'svg' does not exist on type 'FaIcon'. // @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) unsafeSVG(this.svg)
} }
</g> </g>
+19 -3
View File
@@ -218,8 +218,20 @@ class PageEntry extends LitElement {
` `
: ""} : ""}
<div class="column col-date is-2"> <div class="column col-date is-2">
<div>${date ? date.toLocaleDateString() : ""}</div> <div>
<div>${date ? date.toLocaleTimeString() : ""}</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>
<div class="column"> <div class="column">
<div class="media"> <div class="media">
@@ -246,7 +258,11 @@ class PageEntry extends LitElement {
>${this.thumbnailValid ? this.renderFavicon() : ""} >${this.thumbnailValid ? this.renderFavicon() : ""}
</p> </p>
<p class="has-text-grey-dark text is-inline-date"> <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> </p>
</a> </a>
${this.textSnippet ${this.textSnippet
+51 -3
View File
@@ -126,23 +126,35 @@ class Pages extends LitElement {
if (this.newQuery !== null) { if (this.newQuery !== null) {
this.query = this.newQuery; this.query = this.newQuery;
this.newQuery = null; this.newQuery = null;
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.filter(); this.filter();
} }
} }
async updated(changedProperties: PropertyValues<this>) { async updated(changedProperties: PropertyValues<this>) {
if (changedProperties.has("collInfo")) { 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(); this.updateTextSearch();
} else if (changedProperties.has("query")) { } 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(); this.filter();
} else if (changedProperties.has("currList")) { } 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(); this.filter();
} else if (changedProperties.has("showAllPages")) { } 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(); this.filter();
} }
if (changedProperties.has("active") && this.active) { if (changedProperties.has("active") && this.active) {
if (this.changeNeeded) { if (this.changeNeeded) {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.filter(); this.filter();
} }
} }
@@ -241,6 +253,8 @@ class Pages extends LitElement {
this.dispatchEvent(new CustomEvent("coll-tab-nav", { detail: { data } })); 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) { addPages(pages) {
const flex = new FlexIndex(); const flex = new FlexIndex();
@@ -254,6 +268,8 @@ class Pages extends LitElement {
); );
return Promise.all( 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) => { pages.map((page, index) => {
let text = page.url; let text = page.url;
if (page.title) { if (page.title) {
@@ -262,6 +278,8 @@ class Pages extends LitElement {
if (page.text) { if (page.text) {
text += " " + 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); return flex.addAsync(index, text);
}), }),
); );
@@ -285,6 +303,8 @@ class Pages extends LitElement {
if (!resp || !Number(resp.headers.get("Content-Length"))) { if (!resp || !Number(resp.headers.get("Content-Length"))) {
resp = await fetch(indexUrl); resp = await fetch(indexUrl);
if (resp.status === 200 && Number(resp.headers.get("Content-Length"))) { 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()); cache.put(indexUrl, resp.clone());
} }
} }
@@ -723,7 +743,11 @@ class Pages extends LitElement {
<a <a
role="button" role="button"
href="#" 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}" @keyup="${clickOnSpacebarPress}"
class="dropdown-item" class="dropdown-item"
> >
@@ -733,7 +757,11 @@ class Pages extends LitElement {
<a <a
role="button" role="button"
href="#" 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}" @keyup="${clickOnSpacebarPress}"
class="dropdown-item" class="dropdown-item"
> >
@@ -743,7 +771,11 @@ class Pages extends LitElement {
<a <a
role="button" role="button"
href="#" 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}" @keyup="${clickOnSpacebarPress}"
class="dropdown-item" class="dropdown-item"
> >
@@ -883,8 +915,12 @@ class Pages extends LitElement {
if (page.url === this.url) { if (page.url === this.url) {
let ts = page.timestamp; let ts = page.timestamp;
if (!ts && page.date) { 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); ts = getTS(page.date);
} else if (typeof page.ts === "string") { } 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); ts = getTS(page.ts);
} }
return ts === this.ts; return ts === this.ts;
@@ -945,6 +981,8 @@ class Pages extends LitElement {
const body = JSON.stringify({ title }); 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`, { fetch(`${this.collInfo!.apiPrefix}/metadata`, {
method: "POST", method: "POST",
body, body,
@@ -993,8 +1031,12 @@ class Pages extends LitElement {
onSelectToggle(event) { onSelectToggle(event) {
const { page, selected } = event.detail; const { page, selected } = event.detail;
if (selected) { 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); this.selectedPages.add(page);
} else { } 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.selectedPages.delete(page);
} }
this.allSelected = this.selectedPages.size === this.sortedPages.length; this.allSelected = this.selectedPages.size === this.sortedPages.length;
@@ -1025,6 +1067,8 @@ class Pages extends LitElement {
"pages", "pages",
selected ? Array.from(this.selectedPages.keys()).join(",") : "all", 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); params.set("format", format);
if (this.collInfo!.filename) { if (this.collInfo!.filename) {
params.set("filename", this.collInfo!.filename); params.set("filename", this.collInfo!.filename);
@@ -1077,6 +1121,8 @@ class Pages extends LitElement {
continue; 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); const inx = this.collInfo!.pages.indexOf(page);
if (inx < 0) { if (inx < 0) {
continue; continue;
@@ -1088,6 +1134,8 @@ class Pages extends LitElement {
this.toDeletePages = null; this.toDeletePages = null;
this.toDeletePage = 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.updateTextSearch();
this.requestUpdate(); this.requestUpdate();
} }
+2
View File
@@ -43,6 +43,8 @@ function getDateFromTS(ts: string | number) {
let date: Date | null = null; let date: Date | null = null;
date = new Date(ts); date = new Date(ts);
const timestamp = 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()) : ""; date && date instanceof Date ? getTS(date.toISOString()) : "";
return timestamp; return timestamp;
} }
+2
View File
@@ -48,6 +48,8 @@ class Replay extends LitElement {
firstUpdated() { firstUpdated() {
window.addEventListener("message", (event) => this.onReplayMessage(event)); 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) => navigator.serviceWorker.addEventListener("message", (event) =>
this.handleAuthMessage(event), this.handleAuthMessage(event),
); );
+24 -4
View File
@@ -54,6 +54,8 @@ class Story extends LitElement {
updated(changedProperties: PropertyValues<this>) { updated(changedProperties: PropertyValues<this>) {
if (changedProperties.has("collInfo")) { 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(); this.doLoadCurated();
} }
@@ -88,6 +90,8 @@ class Story extends LitElement {
this.splitter = null; 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) { if (sidebar && content && !this.splitter) {
const opts: Split.Options = { const opts: Split.Options = {
sizes: [20, 80], sizes: [20, 80],
@@ -114,6 +118,8 @@ class Story extends LitElement {
} }
for (const curated of this.collInfo.curatedPages) { 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]) { if (!this.curatedPageMap[curated.list]) {
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'. // @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)) : "" this.collInfo.desc ? unsafeHTML(marked(this.collInfo.desc)) : ""
} }
</section> </section>
@@ -317,9 +325,13 @@ class Story extends LitElement {
<h3>${list.title}</h3> <h3>${list.title}</h3>
<p>${list.desc}</p> <p>${list.desc}</p>
<ol> <ol>
${this.curatedPageMap[list.id] ${
? this.curatedPageMap[list.id].map((p) => this.renderCPage(p)) // TODO: Fix this the next time the file is edited.
: html``} // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
this.curatedPageMap[list.id]
? this.curatedPageMap[list.id].map((p) => this.renderCPage(p))
: html``
}
</ol> </ol>
</div> </div>
</article> </article>
@@ -328,6 +340,8 @@ class Story extends LitElement {
} }
renderCPage(p) { 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 date = new Date(p.ts);
const ts = getTS(date.toISOString()); const ts = getTS(date.toISOString());
@@ -338,7 +352,11 @@ class Story extends LitElement {
@click="${this.onReplay}" @click="${this.onReplay}"
data-url="${p.url}" data-url="${p.url}"
data-ts="${ts}" 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="is-size-6 has-text-weight-bold has-text-link">${p.title}</p>
<p class="has-text-dark">${p.url}</p> <p class="has-text-dark">${p.url}</p>
@@ -422,6 +440,8 @@ class Story extends LitElement {
} }
} }
this.lastST = currST; 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 && next != curr) {
if (next.id.startsWith("list-")) { if (next.id.startsWith("list-")) {
this.currList = Number(next.id.slice(5)); this.currList = Number(next.id.slice(5));
+2
View File
@@ -10,6 +10,8 @@ type Self = Window &
sw: SWReplay; 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) { if ((self as Self).registration) {
const staticData = new Map(); const staticData = new Map();
+6
View File
@@ -27,6 +27,8 @@ export class SWManager {
this.appName = newAppName; this.appName = newAppName;
} }
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/promise-function-async
register() { register() {
let resolve, reject; 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'. // @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, { register(this.scope + this.name, {
// @ts-expect-error - TS2339 - Property 'scope' does not exist on type 'SWManager'. // @ts-expect-error - TS2339 - Property 'scope' does not exist on type 'SWManager'.
registrationOptions: { scope: this.scope }, registrationOptions: { scope: this.scope },
@@ -105,6 +109,8 @@ export class SWManager {
} }
getSWErrorMsg() { getSWErrorMsg() {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (navigator.serviceWorker) { if (navigator.serviceWorker) {
// must be loaded from a cross-origin (eg. subdomain) // must be loaded from a cross-origin (eg. subdomain)
// @ts-expect-error - TS2339 - Property 'requireSubdomainIframe' does not exist on type 'SWManager'. // @ts-expect-error - TS2339 - Property 'requireSubdomainIframe' does not exist on type 'SWManager'.
+8
View File
@@ -117,6 +117,8 @@ class URLResources extends LitElement {
} }
_timedUpdate() { _timedUpdate() {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (this.newQuery !== null) { if (this.newQuery !== null) {
this.query = this.newQuery; this.query = this.newQuery;
this.newQuery = null; this.newQuery = null;
@@ -129,6 +131,8 @@ class URLResources extends LitElement {
changedProperties.has("urlSearchType") || changedProperties.has("urlSearchType") ||
changedProperties.has("currMime") changedProperties.has("currMime")
) { ) {
// TODO: Fix this the next time the file is edited.
// eslint-disable-next-line @typescript-eslint/no-floating-promises
this.doLoadResources(); this.doLoadResources();
const data = { const data = {
query: this.query, query: this.query,
@@ -188,6 +192,8 @@ class URLResources extends LitElement {
`${this.collInfo!.apiPrefix}/urls?${params.toString()}`, `${this.collInfo!.apiPrefix}/urls?${params.toString()}`,
); );
const data = await resp.json(); 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; this.results = isMore ? this.results.concat(data.urls) : data.urls;
// can be more than count if multiple mimes // can be more than count if multiple mimes
this.tryMore = data.urls.length >= count; this.tryMore = data.urls.length >= count;
@@ -229,6 +235,8 @@ class URLResources extends LitElement {
const diff = const diff =
element.scrollHeight - element.scrollTop - element.clientHeight; element.scrollHeight - element.scrollTop - element.clientHeight;
if (this.tryMore && diff < 40) { 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); this.doLoadResources(true);
} }
} }