eslint: Fix @typescript-eslint/prefer-regexp-exec.

https://typescript-eslint.io/rules/prefer-regexp-exec/

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-08-25 13:50:13 -07:00 committed by Tim Abbott
parent e6344bd1f5
commit 8196c4f63d
4 changed files with 6 additions and 6 deletions

View File

@ -567,7 +567,7 @@ export function paste_handler_converter(paste_html: string): string {
const className = codeElement.getAttribute("class") ?? ""; const className = codeElement.getAttribute("class") ?? "";
const language = node.parentElement?.classList.contains("zulip-code-block") const language = node.parentElement?.classList.contains("zulip-code-block")
? (node.closest<HTMLElement>(".codehilite")?.dataset?.codeLanguage ?? "") ? (node.closest<HTMLElement>(".codehilite")?.dataset?.codeLanguage ?? "")
: (className.match(/language-(\S+)/) ?? [null, ""])[1]; : (/language-(\S+)/.exec(className) ?? [null, ""])[1];
assert(options.fence !== undefined); assert(options.fence !== undefined);
const fenceChar = options.fence.charAt(0); const fenceChar = options.fence.charAt(0);

View File

@ -170,7 +170,7 @@ export function create<ItemType extends {type: string}>(
if (value.length === 0) { if (value.length === 0) {
return true; return true;
} }
if (store.split_text_on_comma && value.match(",")) { if (store.split_text_on_comma && value.includes(",")) {
funcs.insertManyPills(value); funcs.insertManyPills(value);
return false; return false;
} }

View File

@ -397,7 +397,7 @@ export function build_open_media_function(
const payload = parse_media_data(util.the($media)); const payload = parse_media_data(util.the($media));
assert(payload !== undefined); assert(payload !== undefined);
if (payload.type.match("-video")) { if (payload.type.includes("-video")) {
display_video(payload); display_video(payload);
} else if (payload.type === "image") { } else if (payload.type === "image") {
display_image(payload); display_image(payload);
@ -509,7 +509,7 @@ export function parse_media_data(media: HTMLMediaElement | HTMLImageElement): Pa
let original_width_px; let original_width_px;
let original_height_px; let original_height_px;
if (original_dimensions) { if (original_dimensions) {
const found = original_dimensions.match(/^(\d+)x(\d+)$/); const found = /^(\d+)x(\d+)$/.exec(original_dimensions);
if (found) { if (found) {
original_width_px = Number(found[1]); original_width_px = Number(found[1]);
original_height_px = Number(found[2]); original_height_px = Number(found[2]);

View File

@ -198,8 +198,8 @@ export function find_stream_wildcard_mentions(message_content: string): string |
// We cannot use the exact same regex as the server side uses (in zerver/lib/mention.py) // We cannot use the exact same regex as the server side uses (in zerver/lib/mention.py)
// because Safari < 16.4 does not support look-behind assertions. Reframe the lookbehind of a // because Safari < 16.4 does not support look-behind assertions. Reframe the lookbehind of a
// negative character class as a start-of-string or positive character class. // negative character class as a start-of-string or positive character class.
const mention = message_content.match( const mention = /(?:^|[\s"'(/<[{])(@\*{2}(all|everyone|stream|channel)\*{2})/.exec(
/(?:^|[\s"'(/<[{])(@\*{2}(all|everyone|stream|channel)\*{2})/, message_content,
); );
if (mention === null) { if (mention === null) {
return null; return null;