js: Fix @typescript-eslint/restrict-template-expressions.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-09-22 15:25:31 -07:00 committed by Anders Kaseorg
parent f7a7cfea62
commit abee9258c6
6 changed files with 18 additions and 15 deletions

View File

@ -511,21 +511,20 @@ class CommonUtils {
lineNumber,
columnNumber,
}: ConsoleMessageLocation): Promise<string> => {
if (lineNumber === undefined || columnNumber === undefined) {
return `${url}`;
}
let frame = new StackFrame({
fileName: url,
lineNumber: lineNumber + 1,
columnNumber: columnNumber + 1,
lineNumber: lineNumber === undefined ? undefined : lineNumber + 1,
columnNumber: columnNumber === undefined ? undefined : columnNumber + 1,
});
try {
frame = await this.gps.getMappedLocation(frame);
} catch {
// Ignore source mapping errors
}
return `${frame.fileName}:${frame.lineNumber}:${frame.columnNumber}`;
if (frame.lineNumber === undefined || frame.columnNumber === undefined) {
return String(frame.fileName);
}
return `${String(frame.fileName)}:${frame.lineNumber}:${frame.columnNumber}`;
};
const console_ready1 = console_ready;
@ -561,7 +560,9 @@ class CommonUtils {
} catch {
// Ignore source mapping errors
}
return `\n at ${frame.functionName} (${frame.fileName}:${frame.lineNumber}:${frame.columnNumber})`;
return `\n at ${String(frame.functionName)} (${String(
frame.fileName,
)}:${String(frame.lineNumber)}:${String(frame.columnNumber)})`;
}),
);
await console_ready1;

View File

@ -61,7 +61,9 @@ async function navigate_to_subscriptions(page: Page): Promise<void> {
}
async function test_reload_hash(page: Page): Promise<void> {
const initial_page_load_time = await page.evaluate(() => zulip_test.page_params.page_load_time);
const initial_page_load_time = await page.evaluate(
(): number => zulip_test.page_params.page_load_time,
);
console.log(`initial load time: ${initial_page_load_time}`);
const initial_hash = await page.evaluate(() => window.location.hash);
@ -82,7 +84,7 @@ async function navigation_tests(page: Page): Promise<void> {
await navigate_to_settings(page);
const verona_id = await page.evaluate(() => zulip_test.get_stream_id("Verona"));
const verona_id = await page.evaluate((): number => zulip_test.get_stream_id("Verona"));
const verona_narrow = `narrow/stream/${verona_id}-Verona`;
await navigate_using_left_sidebar(page, verona_narrow, "message_feed_container");

View File

@ -28,7 +28,7 @@ async function realm_creation_tests(page: Page): Promise<void> {
// Open the confirmation URL
const page_content = await page.evaluate(() => document.querySelector("body")!.textContent);
const confirmation_key = await JSON.parse(page_content!).confirmation_key;
const confirmation_key: string = JSON.parse(page_content!).confirmation_key;
const confirmation_url = `http://${host}/accounts/do_confirm/${confirmation_key}`;
await page.goto(confirmation_url);

View File

@ -20,7 +20,7 @@ export function make_indicator(
if (abs_positioned) {
// Create some additional containers to facilitate absolutely
// positioned spinners.
const container_id = container.attr("id");
const container_id = container.attr("id")!;
let inner_container = $("<div>", {id: `${container_id}_box_container`});
container.append(inner_container);
container = inner_container;

View File

@ -1,7 +1,7 @@
import $ from "jquery";
function collapse_spoiler(spoiler: JQuery): void {
const spoiler_height = spoiler.height();
const spoiler_height = spoiler.height() || 0;
// Set height to rendered height on next frame, then to zero on following
// frame to allow CSS transition animation to work
@ -21,7 +21,7 @@ function expand_spoiler(spoiler: JQuery): void {
// of the content). CSS animations do not work with properties set to
// `auto`, so we get the actual height of the content here and temporarily
// put it explicitly on the element styling to allow the transition to work.
const spoiler_height = spoiler.prop("scrollHeight");
const spoiler_height: number = spoiler.prop("scrollHeight");
spoiler.height(`${spoiler_height}px`);
// The `spoiler-content-open` class has CSS animations defined on it which
// will trigger on the frame after this class change.

View File

@ -62,7 +62,7 @@ export function validate_stream_ids(stream_ids: number[]): number[] {
}
if (bad_ids.length > 0) {
blueslip.warn(`We have untracked stream_ids: ${bad_ids}`);
blueslip.warn(`We have untracked stream_ids: ${bad_ids.toString()}`);
}
return good_ids;