mirror of https://github.com/zulip/zulip.git
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:
parent
e6344bd1f5
commit
8196c4f63d
|
@ -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);
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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]);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue