Fix the ESLint configuration and a bunch of minor issues
authorAlexander Ebert <ebert@woltlab.com>
Wed, 25 Sep 2024 14:42:30 +0000 (16:42 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 25 Sep 2024 14:42:30 +0000 (16:42 +0200)
53 files changed:
eslint.config.mjs
ts/WoltLabSuite/Core/Ajax/Backend.ts
ts/WoltLabSuite/Core/Ajax/DboAction.ts
ts/WoltLabSuite/Core/Ajax/Error.ts
ts/WoltLabSuite/Core/Ajax/Request.ts
ts/WoltLabSuite/Core/Api/Result.ts
ts/WoltLabSuite/Core/Bbcode/Code.ts
ts/WoltLabSuite/Core/Component/Attachment/List.ts
ts/WoltLabSuite/Core/Component/Comment/Add.ts
ts/WoltLabSuite/Core/Component/Comment/List.ts
ts/WoltLabSuite/Core/Component/Comment/Response/Add.ts
ts/WoltLabSuite/Core/Component/Comment/Response/woltlab-core-comment-response.ts
ts/WoltLabSuite/Core/Component/Comment/woltlab-core-comment.ts
ts/WoltLabSuite/Core/Component/File/Upload.ts
ts/WoltLabSuite/Core/Controller/Popover.ts
ts/WoltLabSuite/Core/Devtools.ts
ts/WoltLabSuite/Core/Form/Builder/Field/Checkboxes.ts
ts/WoltLabSuite/Core/Image/ExifUtil.ts
ts/WoltLabSuite/Core/Image/Resizer.ts
ts/WoltLabSuite/Core/Media/Manager/Base.ts
ts/WoltLabSuite/Core/Media/Manager/Editor.ts
ts/WoltLabSuite/Core/Notification/Handler.ts
ts/WoltLabSuite/Core/Notification/ServiceWorker.ts
ts/WoltLabSuite/Core/Ui/Dropdown/Simple.ts
ts/WoltLabSuite/Core/Ui/FlexibleMenu.ts
ts/WoltLabSuite/Core/Ui/Page/Action.ts
ts/WoltLabSuite/Core/Ui/Page/JumpTo.ts
ts/WoltLabSuite/Core/Ui/Reaction/CountButtons.ts
ts/WoltLabSuite/Core/Ui/Search/Page.ts
ts/WoltLabSuite/Core/Upload.ts
ts/WoltLabSuite/WebComponent/Language.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Backend.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/DboAction.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Error.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js
wcfsetup/install/files/js/WoltLabSuite/Core/Api/Result.js
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Comment/Add.js
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Comment/List.js
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Comment/Response/Add.js
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Comment/Response/woltlab-core-comment-response.js
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Comment/woltlab-core-comment.js
wcfsetup/install/files/js/WoltLabSuite/Core/Component/File/Upload.js
wcfsetup/install/files/js/WoltLabSuite/Core/Controller/Popover.js
wcfsetup/install/files/js/WoltLabSuite/Core/Devtools.js
wcfsetup/install/files/js/WoltLabSuite/Core/Image/ExifUtil.js
wcfsetup/install/files/js/WoltLabSuite/Core/Image/Resizer.js
wcfsetup/install/files/js/WoltLabSuite/Core/Media/Manager/Base.js
wcfsetup/install/files/js/WoltLabSuite/Core/Notification/Handler.js
wcfsetup/install/files/js/WoltLabSuite/Core/Notification/ServiceWorker.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Simple.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/FlexibleMenu.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Action.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Page.js

index 60ff7ac1304872d2fe6427b5186c9fc078fb1602..a4c13262860b5e70ffaa343d8ae061c49e678fb2 100644 (file)
@@ -15,7 +15,7 @@ const compat = new FlatCompat({
 
 export default [
        {
-               ignores: ["**/*.js", "**/extra", "node_modules/**/*"],
+               ignores: ["**/*.js", "**/extra", "node_modules/**/*", "eslint.config.mjs"],
        },
        ...compat.extends(
                "eslint:recommended",
@@ -34,23 +34,12 @@ export default [
                        sourceType: "script",
 
                        parserOptions: {
-                               tsconfigRootDir: "/opt/homebrew/var/www/wcf/WCF",
+                               tsconfigRootDir: __dirname,
                                project: ["./tsconfig.json", "./ts/WoltLabSuite/WebComponent/tsconfig.json"],
                        },
                },
 
                rules: {
-                       "@typescript-eslint/ban-types": [
-                               "error",
-                               {
-                                       types: {
-                                               object: false,
-                                       },
-
-                                       extendDefaults: true,
-                               },
-                       ],
-
                        "@typescript-eslint/no-explicit-any": 0,
                        "@typescript-eslint/no-non-null-assertion": 0,
                        "@typescript-eslint/no-unsafe-argument": 0,
@@ -73,6 +62,7 @@ export default [
                                        checksVoidReturn: false,
                                },
                        ],
+                       "@typescript-eslint/prefer-promise-reject-errors": ["error", { allowEmptyReject: true }],
                },
        },
 ];
index 40b6a9cb6f84b9e43d65e30945a0dffe4524d6e6..7ad96c4f971d3c2aa3367d15cecfa3f21be4c7b1 100644 (file)
@@ -110,7 +110,7 @@ class BackendRequest {
     let json: unknown;
     try {
       json = await response.json();
-    } catch (e) {
+    } catch {
       throw new InvalidJson(response);
     }
 
index 0cfd2f86bfa8f80765a0ff604cb87569e85f8f43..004a27ac6d927d8cc31f7593abfa57fac7e2566b 100644 (file)
@@ -217,7 +217,7 @@ async function tryParseAsJson(response: Response): Promise<ResponseData> {
   let json: ResponseData;
   try {
     json = await response.json();
-  } catch (e) {
+  } catch {
     throw new InvalidJson(response);
   }
 
index 16b8352e29b0c236ba7c0464fdc357cc56fc91f5..1326b99ba7e453951ec624732ce74a0bf8196ea5 100644 (file)
@@ -60,7 +60,7 @@ async function getErrorHtml(error: ApiError): Promise<string | HTMLIFrameElement
       let json: ErrorResponse | undefined = undefined;
       try {
         json = await error.response.clone().json();
-      } catch (e) {
+      } catch {
         message = await error.response.clone().text();
       }
 
index 697dbf34fb3f802e6bc46f927a9d9ba9ed50c97c..2cbe31184dc0d7381f9deff4822fd65443ea98b1 100644 (file)
@@ -235,7 +235,7 @@ class AjaxRequest {
       if (this.getContentType(xhr) === "application/json") {
         try {
           data = JSON.parse(xhr.responseText) as ResponseData;
-        } catch (e) {
+        } catch {
           // invalid JSON
           this._failure(xhr, options);
 
@@ -275,7 +275,7 @@ class AjaxRequest {
     let data: ResponseData | null = null;
     try {
       data = JSON.parse(xhr.responseText);
-    } catch (e) {
+    } catch {
       // Ignore JSON parsing failure.
     }
 
index f00ac9b5331cfd0a331768f370149b0336f7575d..72ff7c44081d19844348e095f5531ee276972b3d 100644 (file)
@@ -35,7 +35,7 @@ export function apiResultFromValue<T>(value: T): ApiResult<T> {
   };
 }
 
-export async function apiResultFromError(error: unknown): Promise<ApiResult<never>> {
+export async function apiResultFromError(error: Error): Promise<ApiResult<never>> {
   if (error instanceof StatusNotOk) {
     return apiResultFromStatusNotOk(error);
   }
@@ -77,7 +77,7 @@ export async function apiResultFromStatusNotOk(e: StatusNotOk): Promise<ApiResul
       ok: false,
       error: apiError,
       unwrap() {
-        throw apiError;
+        throw new Error("Trying to unwrap an erroneous result.", { cause: apiError });
       },
     };
   }
index 5199d0a04cf6199a347d5e34857295dec28224d6..e1ea6ee1688f9c21b352661cb16c31916323cb57 100644 (file)
@@ -115,7 +115,7 @@ class Code {
       const chunkEnd = Math.min(chunkStart + Code.chunkSize, max);
 
       for (let offset = chunkStart; offset < chunkEnd; offset++) {
-        const toReplace = originalLines[offset]!;
+        const toReplace = originalLines[offset];
         const replacement = highlightedLines.next().value as Element;
         toReplace.parentNode!.replaceChild(replacement, toReplace);
       }
index 8848aa29a6bd12cd641fa662628ec3130e0f62a4..02f3211b6a29615b3485de120d1ce3967ab7eeca 100644 (file)
@@ -39,7 +39,7 @@ export function setup(editorId: string): void {
   }
 
   uploadButton.addEventListener("uploadStart", (event: CustomEvent<WoltlabCoreFileElement>) => {
-    fileToAttachment(fileList!, event.detail, editor);
+    fileToAttachment(fileList, event.detail, editor);
   });
 
   listenToCkeditor(editor)
@@ -79,7 +79,7 @@ export function setup(editorId: string): void {
   const existingFiles = container.querySelector<HTMLElement>(".attachment__list__existingFiles");
   if (existingFiles !== null) {
     existingFiles.querySelectorAll("woltlab-core-file").forEach((file) => {
-      fileToAttachment(fileList!, file, editor);
+      fileToAttachment(fileList, file, editor);
     });
 
     existingFiles.remove();
index 5da5966f79c66f1b370b0f9c31e2b9a198895785..d2fea0b4891988904e8439231b61436d214743f9 100644 (file)
@@ -132,7 +132,7 @@ export class CommentAdd {
     if (!response.ok) {
       const validationError = response.error.getValidationError();
       if (validationError === undefined) {
-        throw response.error;
+        throw new Error("Unexpected validation error", { cause: response.error });
       }
       this.#throwError(this.#getEditor().element, validationError.code);
       this.#hideLoadingOverlay();
index d1935e1724a53f1e4aac955aa45efb898e9f71a8..c426f097bc2db8a34e68fa97cb004fb77893764b 100644 (file)
@@ -354,7 +354,7 @@ class CommentList {
     if (!response.ok) {
       const validationError = response.error.getValidationError();
       if (validationError === undefined) {
-        throw response.error;
+        throw new Error("Unexpected validation error", { cause: response.error });
       }
 
       return;
@@ -376,7 +376,7 @@ class CommentList {
     if (!response.ok) {
       const validationError = response.error.getValidationError();
       if (validationError === undefined) {
-        throw response.error;
+        throw new Error("Unexpected validation error", { cause: response.error });
       }
 
       return;
index 3de9ba27ff6db40b0e68b876fd95bf1a75e570c8..a9da16d6b71130dc7a37a0d9d68589a1d53adbb4 100644 (file)
@@ -113,7 +113,7 @@ export class CommentResponseAdd {
     if (!response.ok) {
       const validationError = response.error.getValidationError();
       if (validationError === undefined) {
-        throw response.error;
+        throw new Error("Unexpected validation error", { cause: response.error });
       }
       this.#throwError(this.#getEditor().element, validationError.code);
       this.#hideLoadingOverlay();
index a751f27f7a2ef6ca77ea65e468b094febb88ce40..a3d017ccc36da121cc6b751341f039313b61b812 100644 (file)
@@ -115,7 +115,7 @@ export class WoltlabCoreCommentResponseElement extends HTMLParsedElement {
     if (!response.ok) {
       const validationError = response.error.getValidationError();
       if (validationError === undefined) {
-        throw response.error;
+        throw new Error("Unexpected validation error", { cause: response.error });
       }
       DomUtil.innerError(document.getElementById(this.#editorId)!, validationError.code);
       this.#hideLoadingIndicator();
index 63e58812d074d1730346eb56ff260554d6b9dc4e..68701a5320070d7d3b9a0bb25ac1a6c9f6c621b5 100644 (file)
@@ -120,7 +120,7 @@ export class WoltlabCoreCommentElement extends HTMLParsedElement {
     if (!response.ok) {
       const validationError = response.error.getValidationError();
       if (validationError === undefined) {
-        throw response.error;
+        throw new Error("Unexpected validation error", { cause: response.error });
       }
       DomUtil.innerError(document.getElementById(this.#editorId)!, validationError.code);
       this.#hideLoadingIndicator();
index 19e2504769e6af6ddfbe7d3e6b279afd10b53723..a44178222b1087c49b20df62f3b41cde11df0149 100644 (file)
@@ -54,7 +54,7 @@ async function upload(element: WoltlabCoreFileUploadElement, file: File): Promis
     if (validationError === undefined) {
       fileElement.uploadFailed(response.error);
 
-      throw response.error;
+      throw new Error("Unexpected validation error", { cause: response.error });
     }
 
     fileElement.uploadFailed(response.error);
@@ -78,7 +78,7 @@ async function upload(element: WoltlabCoreFileUploadElement, file: File): Promis
     if (!response.ok) {
       fileElement.uploadFailed(response.error);
 
-      throw response.error;
+      throw new Error("Unexpected validation error", { cause: response.error });
     }
 
     notifyChunkProgress(fileElement, i + 1, numberOfChunks);
index 809a386049db3a375ea671e3d67fa09d61ef9f26..f4262734ee1c5e5b1cf79ba1b7369c4ff6a7a1bb 100644 (file)
@@ -321,8 +321,8 @@ class ControllerPopover implements AjaxCallbackObject {
     if (forceHide) {
       this.popover.classList.add("forceHide");
 
-      // force layout
-      //noinspection BadExpressionStatementJS
+      // Query a layout related property to force a reflow, otherwise the transition is optimized away.
+      // eslint-disable-next-line @typescript-eslint/no-unused-expressions
       this.popover.offsetTop;
 
       this.clearContent();
index 1d6dd9b71cd846b4fca9cad52587d9528a599ff3..92e22cb06d163b8283c57d09700bf5d684109a56 100644 (file)
@@ -87,7 +87,7 @@ const Devtools = {
           if (settings !== null) {
             _settings = JSON.parse(settings);
           }
-        } catch (e) {
+        } catch {
           // Ignore JSON parsing failure.
         }
 
index 18e62d2e80ecd497dcb7fb9bc21377053aea80f2..efcd2b3fd8b4657ad1c40f8fcc4049857be4053e 100644 (file)
@@ -21,7 +21,7 @@ class Checkboxes extends Field {
 
         return null;
       })
-      .filter((v) => v !== null) as string[];
+      .filter((v) => v !== null);
 
     return {
       [this._fieldId]: values,
index 6d45a2ac19a6034db12cd3f7427c354f6d3267e1..4a6df6e762e572f0049b33fabbf5e4e7d5262bf0 100644 (file)
@@ -55,7 +55,11 @@ async function blobToUint8(blob: Blob | File): Promise<Uint8Array> {
 
     reader.addEventListener("error", () => {
       reader.abort();
-      reject(reader.error);
+      if (reader.error) {
+        reject(reader.error);
+      } else {
+        reject();
+      }
     });
 
     reader.addEventListener("load", () => {
index 00dc13c2cac29c965abf3dac02f04be1686064ec..2eb659a770e0f85b901f09a57f89652f7f014c58 100644 (file)
@@ -117,7 +117,11 @@ class ImageResizer {
 
       reader.addEventListener("error", () => {
         reader.abort();
-        reject(reader.error);
+        if (reader.error) {
+          reject(reader.error);
+        } else {
+          reject();
+        }
       });
 
       image.addEventListener("error", reject);
index 03357f96e1c9da4c3c0a7bfd28f85313c8f61019..fe4bad9914816c2f02c3af455f26b360688d228a 100644 (file)
@@ -444,7 +444,7 @@ abstract class MediaManager<TOptions extends MediaManagerOptions = MediaManagerO
       // remove list item
       try {
         this._listItems.get(mediaId)!.remove();
-      } catch (e) {
+      } catch {
         // ignore errors if item has already been removed by other code
       }
 
index 916b0b38d921d5669b0ebe9999588546c44b3526..91b3f49c83957849642d695a112069b521d5ee9a 100644 (file)
@@ -196,7 +196,7 @@ export class MediaManagerEditor extends MediaManager<MediaManagerEditorOptions>
 
         return null;
       })
-      .filter((s) => s !== null) as string[];
+      .filter((s) => s !== null);
   }
 
   /**
index 281e13ab5ecab66e395986eb82c449aa8c9acc06..1da2b00f4548b2b48f783f97c15817722d8eeaee 100644 (file)
@@ -169,7 +169,7 @@ class NotificationHandler {
 
       pollData = JSON.parse(pollData as string);
       keepAliveData = JSON.parse(keepAliveData as string);
-    } catch (e) {
+    } catch {
       abort = true;
     }
 
index 8f8261f96fc9267f927f232197b811ea1edaf739..f4a29fd0f560d70a8f767a0f55f6f0f66ab2f91a 100644 (file)
@@ -27,12 +27,14 @@ class ServiceWorker {
   }
 
   async register(): Promise<void> {
-    const currentSubscription = await(await this.#serviceWorkerRegistration).pushManager.getSubscription();
+    const currentSubscription = await (await this.#serviceWorkerRegistration).pushManager.getSubscription();
     if (currentSubscription && this.#compareApplicationServerKey(currentSubscription)) {
       return;
     }
     await this.unsubscribe(currentSubscription);
-    const subscription = await(await this.#serviceWorkerRegistration).pushManager.subscribe({
+    const subscription = await (
+      await this.#serviceWorkerRegistration
+    ).pushManager.subscribe({
       userVisibleOnly: true,
       applicationServerKey: this.#urlBase64ToUint8Array(this.#publicKey),
     });
@@ -75,7 +77,7 @@ class ServiceWorker {
         })
         .disableLoadingIndicator()
         .fetchAsResponse();
-    } catch (_) {
+    } catch {
       // ignore registration errors
     }
   }
index 1ce0d133c456c744cdea4417afad83b727ac96f4..8d1ba020ee401a22b890c8e0cb059ec049c1d660 100644 (file)
@@ -620,7 +620,7 @@ const UiDropdownSimple = {
       UiDropdownSimple.close(containerId);
 
       _menus.get(containerId)?.remove();
-    } catch (e) {
+    } catch {
       // the elements might not exist anymore thus ignore all errors while cleaning up
     }
 
index 2c292b576544a98797efd025d3204549a36677c6..e0475e3da3432a3972b408c947296b02dab0de0e 100644 (file)
@@ -42,7 +42,7 @@ export function setup(): void {
 export function register(containerId: string): void {
   const container = document.getElementById(containerId);
   if (container === null) {
-    throw "Expected a valid element id, '" + containerId + "' does not exist.";
+    throw new Error("Expected a valid element id, '" + containerId + "' does not exist.");
   }
 
   if (_containers.has(containerId)) {
@@ -51,7 +51,7 @@ export function register(containerId: string): void {
 
   const list = DomTraverse.childByTag(container, "UL");
   if (list === null) {
-    throw "Expected an <ul> element as child of container '" + containerId + "'.";
+    throw new Error("Expected an <ul> element as child of container '" + containerId + "'.");
   }
 
   _containers.set(containerId, container);
@@ -90,7 +90,7 @@ export function rebuildAll(): void {
 export function rebuild(containerId: string): void {
   const container = _containers.get(containerId);
   if (container === undefined) {
-    throw "Expected a valid element id, '" + containerId + "' is unknown.";
+    throw new Error("Expected a valid element id, '" + containerId + "' is unknown.");
   }
 
   const styles = window.getComputedStyle(container);
index 575cf81581c27a0c27813dacc77e23a6e85ec82a..cf75907d5ef4cb2c4243cca8d9291b7e58c33825 100644 (file)
@@ -204,7 +204,7 @@ export function add(buttonName: string, button: HTMLElement, insertBeforeButton?
   _buttons.set(buttonName, button);
 
   // Query a layout related property to force a reflow, otherwise the transition is optimized away.
-  // noinspection BadExpressionStatementJS
+  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
   wrapper.offsetParent;
 
   // Toggle the visibility to force the transition to be applied.
@@ -242,7 +242,7 @@ export function remove(buttonName: string): void {
         }
 
         listItem.removeEventListener("transitionend", callback);
-      } catch (e) {
+      } catch {
         // ignore errors if the element has already been removed
       }
     };
index 4bf9103d31c68f8af15ef4eaa31465bda8c0e8e7..2a03d68d5639b3b8080ce44cf06078467a0a2ada 100644 (file)
@@ -39,7 +39,7 @@ class UiPageJumpTo implements DialogCallbackObject {
     if (!this.elements.has(element)) {
       element.querySelectorAll(".jumpTo").forEach((jumpTo: HTMLElement) => {
         jumpTo.addEventListener("click", (ev) => this.click(element, ev));
-        this.elements.set(element, callback!);
+        this.elements.set(element, callback);
       });
     }
   }
index 1d42cd2bf62bbb6743714905bce16aafebe8d454..173f1c0443a518070004d66bedb899c59eaab633 100644 (file)
@@ -172,7 +172,7 @@ class CountButtons {
           countSpan.innerHTML = StringUtil.shortUnit(count);
           createdElement.appendChild(countSpan);
 
-          summaryList!.appendChild(createdElement);
+          summaryList.appendChild(createdElement);
 
           triggerChange = true;
         }
index 663c637a1e35dadff37ffb3bf9a8b7e13bdaef28..f8520a74b61ca387fe163e44dd76c3bda0133b15 100644 (file)
@@ -27,7 +27,7 @@ function click(event: MouseEvent): void {
         parameters.set(key, data[key] as string);
       });
     }
-  } catch (e) {
+  } catch {
     // Ignore JSON parsing failure.
   }
 
index f61cb96a00ce4f79e0eca0fbc1e7b015998b5528..aa1334ea0b4b456e752a6e54ce0efcfa5070a663 100644 (file)
@@ -360,10 +360,10 @@ abstract class Upload<TOptions extends UploadOptions = UploadOptions> {
 
       Object.entries(parameters).forEach(([key, value]) => {
         if (typeof value === "object") {
-          const newPrefix = prefix!.length === 0 ? key : `${prefix!}[${key}]`;
+          const newPrefix = prefix.length === 0 ? key : `${prefix}[${key}]`;
           appendFormData(value, newPrefix);
         } else {
-          const dataName = prefix!.length === 0 ? key : `${prefix!}[${key}]`;
+          const dataName = prefix.length === 0 ? key : `${prefix}[${key}]`;
           formData.append(dataName, value);
         }
       });
index 7cf1fc0e3601e142114d0d72876b5fe743b3ae8e..89c96be8165903b7138c743a0464143e4041dc92 100644 (file)
@@ -44,7 +44,7 @@ function compile(value: string): Phrase {
   try {
     const template = new Template(value);
     return template.fetch.bind(template);
-  } catch (e) {
+  } catch {
     return function () {
       return value;
     };
index efe06052d162c2d3e06d58dba0d67089a53e8d3f..6acd8db02fb84a2c77c4f7df4140382bf29fc091 100644 (file)
@@ -77,7 +77,7 @@ define(["require", "exports", "tslib", "./Status", "./Error", "../Core"], functi
             try {
                 json = await response.json();
             }
-            catch (e) {
+            catch {
                 throw new Error_1.InvalidJson(response);
             }
             return json;
index 962465a579bbee9b8c9a26e7a523e827339d1f83..1871af86567327a1ca29fa1948ddfb4762abc1ac 100644 (file)
@@ -157,7 +157,7 @@ define(["require", "exports", "tslib", "./Error", "./Status", "../Core"], functi
         try {
             json = await response.json();
         }
-        catch (e) {
+        catch {
             throw new Error_1.InvalidJson(response);
         }
         return json;
index fd3e5a0a28cc527bb7e5e64d4003dbf9b5d5df19..330d19dd2d0c121a67c095a27a0e6ffe485c5214 100644 (file)
@@ -46,7 +46,7 @@ define(["require", "exports", "tslib", "../Component/Dialog", "../Core", "../Lan
                 try {
                     json = await error.response.clone().json();
                 }
-                catch (e) {
+                catch {
                     message = await error.response.clone().text();
                 }
                 if (json && Core.isPlainObject(json) && Object.keys(json).length > 0) {
index ce3db1bfb563dacef70744dc045a2570fe57bf5f..b25a7264528042bbee9e079a07e672e0bffb1fa6 100644 (file)
@@ -202,7 +202,7 @@ define(["require", "exports", "tslib", "./Status", "../Core", "../Dom/Change/Lis
                     try {
                         data = JSON.parse(xhr.responseText);
                     }
-                    catch (e) {
+                    catch {
                         // invalid JSON
                         this._failure(xhr, options);
                         return;
@@ -235,7 +235,7 @@ define(["require", "exports", "tslib", "./Status", "../Core", "../Dom/Change/Lis
             try {
                 data = JSON.parse(xhr.responseText);
             }
-            catch (e) {
+            catch {
                 // Ignore JSON parsing failure.
             }
             let showError = true;
index b99c6491c5dee0e89c1396bce451a9ffa1082f28..385f2d17a09bdea1234a7a41f9f98cec236436a9 100644 (file)
@@ -57,7 +57,7 @@ define(["require", "exports", "../Ajax/Error", "../Core", "./Error"], function (
                 ok: false,
                 error: apiError,
                 unwrap() {
-                    throw apiError;
+                    throw new Error("Trying to unwrap an erroneous result.", { cause: apiError });
                 },
             };
         }
index e169637fbb2417cd054a23a46dfceb064c21f568..b64c0063a21960de2fa2755ad8444aca04189e2c 100644 (file)
@@ -108,7 +108,7 @@ define(["require", "exports", "tslib", "../../Ui/Scroll", "../../Ui/Notification
             if (!response.ok) {
                 const validationError = response.error.getValidationError();
                 if (validationError === undefined) {
-                    throw response.error;
+                    throw new Error("Unexpected validation error", { cause: response.error });
                 }
                 this.#throwError(this.#getEditor().element, validationError.code);
                 this.#hideLoadingOverlay();
index 0dc0de46cb11cdd96b46e7d349a0ba9c7d6d2062..1dac6b10b49f037c94c64e988f7f375e1be35b6d 100644 (file)
@@ -259,7 +259,7 @@ define(["require", "exports", "tslib", "../../Dom/Change/Listener", "../../Dom/U
             if (!response.ok) {
                 const validationError = response.error.getValidationError();
                 if (validationError === undefined) {
-                    throw response.error;
+                    throw new Error("Unexpected validation error", { cause: response.error });
                 }
                 return;
             }
@@ -276,7 +276,7 @@ define(["require", "exports", "tslib", "../../Dom/Change/Listener", "../../Dom/U
             if (!response.ok) {
                 const validationError = response.error.getValidationError();
                 if (validationError === undefined) {
-                    throw response.error;
+                    throw new Error("Unexpected validation error", { cause: response.error });
                 }
                 return;
             }
index 4f463433d07818e282300cd5a5e2283479cbc930..968e3edfe0fc28efcb8fa6513c56f17a2ed6ea31 100644 (file)
@@ -90,7 +90,7 @@ define(["require", "exports", "tslib", "../../../Dom/Util", "../../../Language",
             if (!response.ok) {
                 const validationError = response.error.getValidationError();
                 if (validationError === undefined) {
-                    throw response.error;
+                    throw new Error("Unexpected validation error", { cause: response.error });
                 }
                 this.#throwError(this.#getEditor().element, validationError.code);
                 this.#hideLoadingOverlay();
index 9237bbb072bff879ff409649dcde4074ec991670..b142438281f7c278c06c1b97bd45d79ad959430d 100644 (file)
@@ -90,7 +90,7 @@ define(["require", "exports", "tslib", "../../../Dom/Util", "../../../Ui/Dropdow
             if (!response.ok) {
                 const validationError = response.error.getValidationError();
                 if (validationError === undefined) {
-                    throw response.error;
+                    throw new Error("Unexpected validation error", { cause: response.error });
                 }
                 Util_1.default.innerError(document.getElementById(this.#editorId), validationError.code);
                 this.#hideLoadingIndicator();
index 004e164335e55734021094d8cadd9f6d164de831..062351f89b911c3bc482bf67a8b43a5eb0a88b54 100644 (file)
@@ -94,7 +94,7 @@ define(["require", "exports", "tslib", "../../Dom/Util", "../../Ui/Dropdown/Simp
             if (!response.ok) {
                 const validationError = response.error.getValidationError();
                 if (validationError === undefined) {
-                    throw response.error;
+                    throw new Error("Unexpected validation error", { cause: response.error });
                 }
                 Util_1.default.innerError(document.getElementById(this.#editorId), validationError.code);
                 this.#hideLoadingIndicator();
index e3ef7a7f22f0714d9a2bdb4d3bbe4d43824401ca..157795b9358eb43d7a8de530a0bb2d2925a76209 100644 (file)
@@ -17,7 +17,7 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Helper/Selector", "Wol
             const validationError = response.error.getValidationError();
             if (validationError === undefined) {
                 fileElement.uploadFailed(response.error);
-                throw response.error;
+                throw new Error("Unexpected validation error", { cause: response.error });
             }
             fileElement.uploadFailed(response.error);
             return undefined;
@@ -33,7 +33,7 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Helper/Selector", "Wol
             const response = await (0, Chunk_1.uploadChunk)(identifier, i, checksum, chunk);
             if (!response.ok) {
                 fileElement.uploadFailed(response.error);
-                throw response.error;
+                throw new Error("Unexpected validation error", { cause: response.error });
             }
             notifyChunkProgress(fileElement, i + 1, numberOfChunks);
             await chunkUploadCompleted(fileElement, response.value);
index f1a5058eb3333357543a773ea23aa1611e16f46d..b21c96020d4b2a06d21c1d687953336457bc9a90 100644 (file)
@@ -239,8 +239,8 @@ define(["require", "exports", "tslib", "../Ajax", "../Dom/Change/Listener", "../
             }
             if (forceHide) {
                 this.popover.classList.add("forceHide");
-                // force layout
-                //noinspection BadExpressionStatementJS
+                // Query a layout related property to force a reflow, otherwise the transition is optimized away.
+                // eslint-disable-next-line @typescript-eslint/no-unused-expressions
                 this.popover.offsetTop;
                 this.clearContent();
                 this.popover.classList.remove("forceHide");
index 661918fcb324c3fde65d773338f5a72fd6a3654e..8d2eaf40dbf7e77b3c861e5f80d39096dc748a24 100644 (file)
@@ -70,7 +70,7 @@ define(["require", "exports"], function (require, exports) {
                             _settings = JSON.parse(settings);
                         }
                     }
-                    catch (e) {
+                    catch {
                         // Ignore JSON parsing failure.
                     }
                     if (!_settings.editorAutosave) {
index f56d528609793938ce24cd3420d5ef0a53761a12..e09ff1091d93baf82937f2c46f4ddf0ca26efe5c 100644 (file)
@@ -53,7 +53,12 @@ define(["require", "exports"], function (require, exports) {
             const reader = new FileReader();
             reader.addEventListener("error", () => {
                 reader.abort();
-                reject(reader.error);
+                if (reader.error) {
+                    reject(reader.error);
+                }
+                else {
+                    reject();
+                }
             });
             reader.addEventListener("load", () => {
                 resolve(new Uint8Array(reader.result));
index 41065b21c84e65a334280fe7d7a04938408b0096..f36920c1e5cd47914b63e53d7f730491c722094e 100644 (file)
@@ -92,7 +92,12 @@ define(["require", "exports", "tslib", "../FileUtil", "./ExifUtil", "pica"], fun
                 });
                 reader.addEventListener("error", () => {
                     reader.abort();
-                    reject(reader.error);
+                    if (reader.error) {
+                        reject(reader.error);
+                    }
+                    else {
+                        reject();
+                    }
                 });
                 image.addEventListener("error", reject);
                 image.addEventListener("load", () => {
index 2ceb6f575e90dbcb01ed7be2ae1f97d46a568268..26af3bcdc24df58215c05a55856cf617e14e016e 100644 (file)
@@ -365,7 +365,7 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../../Pe
                 try {
                     this._listItems.get(mediaId).remove();
                 }
-                catch (e) {
+                catch {
                     // ignore errors if item has already been removed by other code
                 }
                 this._listItems.delete(mediaId);
index 78c21404c7e16765e3205f6c01e48c59475a8f73..35691130f76ad967879352f3dd7f475c4924fd8c 100644 (file)
@@ -125,7 +125,7 @@ define(["require", "exports", "tslib", "../Ajax", "../Core", "../Event/Handler",
                 pollData = JSON.parse(pollData);
                 keepAliveData = JSON.parse(keepAliveData);
             }
-            catch (e) {
+            catch {
                 abort = true;
             }
             if (!abort) {
index 9982fb7d40d9cba64312f87d2dc9efa6a3567d1c..6ffeba9ce9397108ba65a4b73657ebeb2478fae8 100644 (file)
@@ -72,7 +72,7 @@ define(["require", "exports", "WoltLabSuite/Core/Ajax/Backend"], function (requi
                     .disableLoadingIndicator()
                     .fetchAsResponse();
             }
-            catch (_) {
+            catch {
                 // ignore registration errors
             }
         }
index 36e0b07d010465809ed2993f0998c96e6f08395d..0b3fdc65aa4051b1e83320e11b15738f3da76504 100644 (file)
@@ -515,7 +515,7 @@ define(["require", "exports", "tslib", "../../CallbackList", "../../Core", "../.
                 UiDropdownSimple.close(containerId);
                 _menus.get(containerId)?.remove();
             }
-            catch (e) {
+            catch {
                 // the elements might not exist anymore thus ignore all errors while cleaning up
             }
             _menus.delete(containerId);
index 87dd38ce571a809435a1d48d5b33a243fb0845be..688e74f8fa51c5ab72715a04a237946c801485d4 100644 (file)
@@ -44,14 +44,14 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Dom/Util",
     function register(containerId) {
         const container = document.getElementById(containerId);
         if (container === null) {
-            throw "Expected a valid element id, '" + containerId + "' does not exist.";
+            throw new Error("Expected a valid element id, '" + containerId + "' does not exist.");
         }
         if (_containers.has(containerId)) {
             return;
         }
         const list = DomTraverse.childByTag(container, "UL");
         if (list === null) {
-            throw "Expected an <ul> element as child of container '" + containerId + "'.";
+            throw new Error("Expected an <ul> element as child of container '" + containerId + "'.");
         }
         _containers.set(containerId, container);
         _itemLists.set(containerId, list);
@@ -85,7 +85,7 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Dom/Util",
     function rebuild(containerId) {
         const container = _containers.get(containerId);
         if (container === undefined) {
-            throw "Expected a valid element id, '" + containerId + "' is unknown.";
+            throw new Error("Expected a valid element id, '" + containerId + "' is unknown.");
         }
         const styles = window.getComputedStyle(container);
         const parent = container.parentNode;
index 349faf9f214a7174758d653e885296857bc671fb..cb7e6a7795fad79025d5487f581d4ad7fbeda4b5 100644 (file)
@@ -168,7 +168,7 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../../Ui
         _wrapper.classList.remove("scrolledDown");
         _buttons.set(buttonName, button);
         // Query a layout related property to force a reflow, otherwise the transition is optimized away.
-        // noinspection BadExpressionStatementJS
+        // eslint-disable-next-line @typescript-eslint/no-unused-expressions
         wrapper.offsetParent;
         // Toggle the visibility to force the transition to be applied.
         wrapper.setAttribute("aria-hidden", "false");
@@ -201,7 +201,7 @@ define(["require", "exports", "tslib", "../../Core", "../../Language", "../../Ui
                     }
                     listItem.removeEventListener("transitionend", callback);
                 }
-                catch (e) {
+                catch {
                     // ignore errors if the element has already been removed
                 }
             };
index 29f5da79253e9c2944ea209dc86301bf9e73d2d6..eb0f99ee0f33023ef933a61fd9c118d135b761db 100644 (file)
@@ -26,7 +26,7 @@ define(["require", "exports", "tslib", "../../Core", "../../Dom/Util", "../Dropd
                 });
             }
         }
-        catch (e) {
+        catch {
             // Ignore JSON parsing failure.
         }
         if (objectType && objectType !== "everywhere") {