let json: unknown;
try {
json = await response.json();
- } catch (e) {
+ } catch {
throw new InvalidJson(response);
}
let json: ResponseData;
try {
json = await response.json();
- } catch (e) {
+ } catch {
throw new InvalidJson(response);
}
let json: ErrorResponse | undefined = undefined;
try {
json = await error.response.clone().json();
- } catch (e) {
+ } catch {
message = await error.response.clone().text();
}
if (this.getContentType(xhr) === "application/json") {
try {
data = JSON.parse(xhr.responseText) as ResponseData;
- } catch (e) {
+ } catch {
// invalid JSON
this._failure(xhr, options);
let data: ResponseData | null = null;
try {
data = JSON.parse(xhr.responseText);
- } catch (e) {
+ } catch {
// Ignore JSON parsing failure.
}
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);
}
} catch (error) {
await handleValidationErrors(error, () => {
// The comment id is invalid or there is a mismatch, silently ignore it.
- permaLinkComment!.remove();
+ permaLinkComment.remove();
return true;
});
} catch (error) {
await handleValidationErrors(error, () => {
// The response id is invalid or there is a mismatch, silently ignore it.
- permalinkResponse!.remove();
+ permalinkResponse.remove();
return true;
});
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();
if (settings !== null) {
_settings = JSON.parse(settings);
}
- } catch (e) {
+ } catch {
// Ignore JSON parsing failure.
}
return null;
})
- .filter((v) => v !== null) as string[];
+ .filter((v) => v !== null);
return {
[this._fieldId]: values,
reader.addEventListener("error", () => {
reader.abort();
- reject(reader.error);
+ if (reader.error) {
+ reject(reader.error);
+ } else {
+ reject();
+ }
});
reader.addEventListener("load", () => {
reader.addEventListener("error", () => {
reader.abort();
- reject(reader.error);
+ if (reader.error) {
+ reject(reader.error);
+ } else {
+ reject();
+ }
});
image.addEventListener("error", reject);
// remove list item
try {
this._listItems.get(mediaId)!.remove();
- } catch (e) {
+ } catch {
// ignore errors if item has already been removed by other code
}
return null;
})
- .filter((s) => s !== null) as string[];
+ .filter((s) => s !== null);
}
/**
pollData = JSON.parse(pollData as string);
keepAliveData = JSON.parse(keepAliveData as string);
- } catch (e) {
+ } catch {
abort = true;
}
UiDropdownSimple.close(containerId);
_menus.get(containerId)?.remove();
- } catch (e) {
+ } catch {
// the elements might not exist anymore thus ignore all errors while cleaning up
}
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)) {
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);
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);
_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.
}
listItem.removeEventListener("transitionend", callback);
- } catch (e) {
+ } catch {
// ignore errors if the element has already been removed
}
};
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);
});
}
}
countSpan.innerHTML = StringUtil.shortUnit(count);
createdElement.appendChild(countSpan);
- summaryList!.appendChild(createdElement);
+ summaryList.appendChild(createdElement);
triggerChange = true;
}
parameters.set(key, data[key]);
});
}
- } catch (e) {
+ } catch {
// Ignore JSON parsing failure.
}
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);
}
});
try {
const template = new Template(value);
return template.fetch.bind(template);
- } catch (e) {
+ } catch {
return function () {
return value;
};
try {
json = await response.json();
}
- catch (e) {
+ catch {
throw new Error_1.InvalidJson(response);
}
return json;
try {
json = await response.json();
}
- catch (e) {
+ catch {
throw new Error_1.InvalidJson(response);
}
return json;
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) {
try {
data = JSON.parse(xhr.responseText);
}
- catch (e) {
+ catch {
// invalid JSON
this._failure(xhr, options);
return;
try {
data = JSON.parse(xhr.responseText);
}
- catch (e) {
+ catch {
// Ignore JSON parsing failure.
}
let showError = true;
}
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");
_settings = JSON.parse(settings);
}
}
- catch (e) {
+ catch {
// Ignore JSON parsing failure.
}
if (!_settings.editorAutosave) {
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));
});
reader.addEventListener("error", () => {
reader.abort();
- reject(reader.error);
+ if (reader.error) {
+ reject(reader.error);
+ }
+ else {
+ reject();
+ }
});
image.addEventListener("error", reject);
image.addEventListener("load", () => {
try {
this._listItems.get(mediaId).remove();
}
- catch (e) {
+ catch {
// ignore errors if item has already been removed by other code
}
this._listItems.delete(mediaId);
pollData = JSON.parse(pollData);
keepAliveData = JSON.parse(keepAliveData);
}
- catch (e) {
+ catch {
abort = true;
}
if (!abort) {
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);
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);
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;
_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");
}
listItem.removeEventListener("transitionend", callback);
}
- catch (e) {
+ catch {
// ignore errors if the element has already been removed
}
};
});
}
}
- catch (e) {
+ catch {
// Ignore JSON parsing failure.
}
if (objectType && objectType !== "everywhere") {