Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Remove straightforward Web lint suppressions

Manav Rathi3dd5e71748da
diff --git a/web/apps/albums/src/public-album/upload/services/upload-manager.ts b/web/apps/albums/src/public-album/upload/services/upload-manager.ts
index e80d0bad76..7b0eac5553 100644
--- a/web/apps/albums/src/public-album/upload/services/upload-manager.ts
+++ b/web/apps/albums/src/public-album/upload/services/upload-manager.ts
@@ -177,8 +177,7 @@ class UIService {
this.perFileProgress *
(this.finishedUploads.size || this.filesUploadedCount);
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- for (const [_, progress] of this.inProgressUploads) {
+ for (const progress of this.inProgressUploads.values()) {
if (progress < 0) {
continue;
}
diff --git a/web/apps/photos/src/components/Upload.tsx b/web/apps/photos/src/components/Upload.tsx
index 80f15789ae..c62f380d0a 100644
--- a/web/apps/photos/src/components/Upload.tsx
+++ b/web/apps/photos/src/components/Upload.tsx
@@ -330,8 +330,6 @@ export const Upload: React.FC<UploadProps> = ({
setInProgressUploads,
setFinishedUploads,
setUploadPhase,
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
setUploadFilenames: setUploadFileNames,
setHasLivePhotos,
setUploadProgressView,
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 1efe576cfa..f713389992 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -708,13 +708,13 @@ const Page: React.FC = () => {
return;
}
- const selected = {
+ const selected: SelectedState = {
ownCount: 0,
count: 0,
collectionID: activeCollectionID,
context:
barMode == "people" && activePersonID
- ? { mode: "people" as const, personID: activePersonID }
+ ? { mode: "people", personID: activePersonID }
: {
mode: barMode as
| "albums"
@@ -729,7 +729,6 @@ const Page: React.FC = () => {
selected.ownCount++;
}
selected.count++;
- // @ts-expect-error Selection code needs type fixing
selected[item.id] = true;
});
setSelected(selected);
@@ -738,13 +737,13 @@ const Page: React.FC = () => {
const handleSelectAll = () => {
if (!user || !filteredFiles.length) return;
- const selected = {
+ const selected: SelectedState = {
ownCount: 0,
count: 0,
collectionID: activeCollectionID,
context:
barMode == "people" && activePersonID
- ? { mode: "people" as const, personID: activePersonID }
+ ? { mode: "people", personID: activePersonID }
: {
mode: barMode as
| "albums"
@@ -759,7 +758,6 @@ const Page: React.FC = () => {
selected.ownCount++;
}
selected.count++;
- // @ts-expect-error Selection code needs type fixing
selected[item.id] = true;
});
setSelected(selected);
diff --git a/web/apps/photos/src/services/upload-manager.ts b/web/apps/photos/src/services/upload-manager.ts
index 89c0c67af5..35665b021f 100644
--- a/web/apps/photos/src/services/upload-manager.ts
+++ b/web/apps/photos/src/services/upload-manager.ts
@@ -148,7 +148,7 @@ interface ProgressUpdater {
setFinishedUploads: React.Dispatch<
React.SetStateAction<SegregatedFinishedUploads>
>;
- setUploadFilenames: React.Dispatch<React.SetStateAction<UploadFileNames>>;
+ setUploadFilenames: (filenames: UploadFileNames) => void;
setHasLivePhotos: React.Dispatch<React.SetStateAction<boolean>>;
setUploadProgressView: React.Dispatch<React.SetStateAction<boolean>>;
}
@@ -267,8 +267,7 @@ class UIService {
this.perFileProgress *
(this.finishedUploads.size || this.filesUploadedCount);
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
- for (const [_, progress] of this.inProgressUploads) {
+ for (const progress of this.inProgressUploads.values()) {
if (progress < 0) {
continue;
}
@@ -305,9 +304,9 @@ const groupByResult = (finishedUploads: FinishedUploads) => {
};
class UploadManager {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- private comlinkCryptoWorkers: ComlinkWorker<typeof CryptoWorker>[] =
- new Array(maxConcurrentUploads);
+ private comlinkCryptoWorkers = new Array<
+ ComlinkWorker<typeof CryptoWorker>
+ >(maxConcurrentUploads);
private parsedMetadataJSONMap = new Map<string, ParsedMetadataJSON>();
private itemsToBeUploaded: ClusteredUploadItem[] = [];
private failedItems: ClusteredUploadItem[] = [];
@@ -345,8 +344,8 @@ class UploadManager {
this.itemsToBeUploaded = [];
this.failedItems = [];
this.itemResults = [];
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- this.parsedMetadataJSONMap = parsedMetadataJSONMap ?? new Map();
+ this.parsedMetadataJSONMap =
+ parsedMetadataJSONMap ?? new Map<string, ParsedMetadataJSON>();
this.shouldUploadBeCancelled = false;
this.fatalUploadError = undefined;
diff --git a/web/packages/gallery/components/FileInfo.tsx b/web/packages/gallery/components/FileInfo.tsx
index ab2a0c16ab..2e5996f8d4 100644
--- a/web/packages/gallery/components/FileInfo.tsx
+++ b/web/packages/gallery/components/FileInfo.tsx
@@ -1067,25 +1067,25 @@ const RawExif: React.FC<RawExifProps> = ({
tags,
)
.map(([namespace, namespaceTags]) => {
- return Object.entries(namespaceTags).map(([tagName, tag]) => {
- const key = `${namespace}:${tagName}`;
- let description = "<...>";
- if (typeof tag == "string") {
- description = tag;
- } else if (typeof tag == "number") {
- description = `${tag}`;
- } else if (
- tag &&
- typeof tag == "object" &&
- "description" in tag &&
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- typeof tag.description == "string"
- ) {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
- description = tag.description;
- }
- return [key, namespace, tagName, description] as const;
- });
+ return Object.entries(namespaceTags).map(
+ ([tagName, tag]: [string, unknown]) => {
+ const key = `${namespace}:${tagName}`;
+ let description = "<...>";
+ if (typeof tag == "string") {
+ description = tag;
+ } else if (typeof tag == "number") {
+ description = `${tag}`;
+ } else if (
+ tag &&
+ typeof tag == "object" &&
+ "description" in tag &&
+ typeof tag.description == "string"
+ ) {
+ description = tag.description;
+ }
+ return [key, namespace, tagName, description] as const;
+ },
+ );
})
.flat()
.filter(([, , , description]) => description);
diff --git a/web/packages/gallery/services/download-core.ts b/web/packages/gallery/services/download-core.ts
index e10ffab533..f2f22c81bf 100644
--- a/web/packages/gallery/services/download-core.ts
+++ b/web/packages/gallery/services/download-core.ts
@@ -276,7 +276,7 @@ export class DownloadManagerCore {
file.key,
);
- let leftoverBytes = new Uint8Array();
+ let leftoverBytes: Uint8Array = new Uint8Array();
return new ReadableStream({
pull: async (controller) => {
@@ -327,8 +327,6 @@ export class DownloadManagerCore {
didEnqueue = true;
controller.close();
} else {
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
- // @ts-ignore
leftoverBytes = data;
}
} while (!didEnqueue);
diff --git a/web/packages/new/photos/components/ImageEditorOverlay.tsx b/web/packages/new/photos/components/ImageEditorOverlay.tsx
index 1853b607b0..03e104df58 100644
--- a/web/packages/new/photos/components/ImageEditorOverlay.tsx
+++ b/web/packages/new/photos/components/ImageEditorOverlay.tsx
@@ -639,8 +639,7 @@ export const ImageEditorOverlay: React.FC<ImageEditorOverlayProps> = ({
>
<Tabs
value={currentTab}
- onChange={(_, value) => {
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
+ onChange={(_, value: OperationTab) => {
setCurrentTab(value);
}}
>
diff --git a/web/packages/utils/type-guards.ts b/web/packages/utils/type-guards.ts
index c950a7ef68..50d9ce6ad2 100644
--- a/web/packages/utils/type-guards.ts
+++ b/web/packages/utils/type-guards.ts
@@ -1,8 +1,4 @@
-// TypeScript does not allow the standard Array.includes to act as a type guard
-// that narrows an arbitrary T to one of the known U[]. See:
-// https://github.com/microsoft/TypeScript/issues/48247
-// https://github.com/microsoft/TypeScript/issues/26255#issuecomment-502899689
export function includes<T, U extends T>(us: readonly U[], t: T): t is U {
- // @ts-expect-error Array.includes cannot narrow an arbitrary T to U.
- return us.includes(t);
+ const values: readonly T[] = us;
+ return values.includes(t);
}