Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

eslint: Fix unicorn/no-unsafe-string-replacement.

Anders Kaseorga2f20bb747e3
diff --git a/tools/check-openapi.ts b/tools/check-openapi.ts
index 719122f3a4d..eabf44888a1 100755
--- a/tools/check-openapi.ts
+++ b/tools/check-openapi.ts
@@ -136,7 +136,7 @@ async function checkFile(file: string): Promise<void> {
diff += prefix;
diff += part.value
.replace(/\n$/, "")
- .replaceAll("\n", "\n" + prefix);
+ .replaceAll("\n", () => "\n" + prefix);
diff += "\n";
}
diff += "\u{1B}[0m";
diff --git a/web/src/buttons.ts b/web/src/buttons.ts
index 7d616d66f35..e5292b870e7 100644
--- a/web/src/buttons.ts
+++ b/web/src/buttons.ts
@@ -84,6 +84,6 @@ export function modify_button_icon($button: JQuery, new_icon: string): void {
$button
.find(".zulip-icon")
.attr("class", (_index, className) =>
- className.replaceAll(/zulip-icon-[^\s]+/g, `zulip-icon-${new_icon}`),
+ className.replaceAll(/zulip-icon-[^\s]+/g, () => `zulip-icon-${new_icon}`),
);
}
diff --git a/web/src/lightbox.ts b/web/src/lightbox.ts
index f0d3d783dcf..40a9f0611b6 100644
--- a/web/src/lightbox.ts
+++ b/web/src/lightbox.ts
@@ -590,7 +590,7 @@ export function parse_media_data(media: HTMLMediaElement | HTMLImageElement): Me
// It's an HEIC and we support it -- don't use the transcoded version
source = url;
} else {
- source = preview_src.replace(/\/[^/]+$/, "/" + transcoded_image);
+ source = preview_src.replace(/\/[^/]+$/, () => "/" + transcoded_image);
}
} else {
source = url;
diff --git a/web/src/message_list_hover.ts b/web/src/message_list_hover.ts
index e920ea45a20..be2728f2dd2 100644
--- a/web/src/message_list_hover.ts
+++ b/web/src/message_list_hover.ts
@@ -156,7 +156,7 @@ export function initialize(): void {
);
$img.attr(
"src",
- $img.attr("src")!.replace(/\/[^/]+$/, "/" + thumbnail.animated_format.name),
+ $img.attr("src")!.replace(/\/[^/]+$/, () => "/" + thumbnail.animated_format.name),
);
},
);
@@ -174,7 +174,7 @@ export function initialize(): void {
);
$img.attr(
"src",
- $img.attr("src")!.replace(/\/[^/]+$/, "/" + thumbnail.preferred_format.name),
+ $img.attr("src")!.replace(/\/[^/]+$/, () => "/" + thumbnail.preferred_format.name),
);
},
);
diff --git a/web/src/portico/showroom.ts b/web/src/portico/showroom.ts
index 5700110db1b..1dc676c17e7 100644
--- a/web/src/portico/showroom.ts
+++ b/web/src/portico/showroom.ts
@@ -337,7 +337,7 @@ $(window).on("load", () => {
$(".action-button .zulip-icon, .icon-button .zulip-icon").attr(
"class",
(_index, className) =>
- className.replaceAll(/zulip-icon-[^\s]+/g, `zulip-icon-${icon_name}`),
+ className.replaceAll(/zulip-icon-[^\s]+/g, () => `zulip-icon-${icon_name}`),
);
});
diff --git a/web/src/postprocess_content.ts b/web/src/postprocess_content.ts
index b47577e174d..c4e69b47ba1 100644
--- a/web/src/postprocess_content.ts
+++ b/web/src/postprocess_content.ts
@@ -266,7 +266,7 @@ export function postprocess_content(html: string): string {
}
message_media_image.src = message_media_image.src.replace(
/\/[^/]+$/,
- "/" + thumbnail_name,
+ () => "/" + thumbnail_name,
);
}
}
diff --git a/web/src/stream_edit.ts b/web/src/stream_edit.ts
index d6e611e730f..65b3b329179 100644
--- a/web/src/stream_edit.ts
+++ b/web/src/stream_edit.ts
@@ -597,7 +597,7 @@ export function get_stream_email_address(flags: string[], address: string): stri
const flag_string = flags.map((flag) => "." + flag).join("");
- return clean_address.replace("@", flag_string + "@");
+ return clean_address.replace("@", () => flag_string + "@");
}
function show_stream_email_address_modal(address: string, sub: StreamSubscription): void {
diff --git a/web/src/topic_link_util.ts b/web/src/topic_link_util.ts
index 33445b80fe7..e973c94c9cd 100644
--- a/web/src/topic_link_util.ts
+++ b/web/src/topic_link_util.ts
@@ -54,7 +54,9 @@ export function html_unescape_invalid_stream_topic_characters(text: string): str
}
export function html_escape_markdown_syntax_characters(text: string): string {
- return text.replaceAll(invalid_stream_topic_regex, escape_invalid_stream_topic_characters);
+ return text.replaceAll(invalid_stream_topic_regex, (text) =>
+ escape_invalid_stream_topic_characters(text),
+ );
}
export function get_topic_link_content_with_stream_name(opts: {