chore: migrate to oxlint and oxfmt
Co-authored-by: Christoph Nakazawa <christoph.pojer@gmail.com>
This commit is contained in:
29
src/utils.ts
29
src/utils.ts
@@ -85,10 +85,7 @@ function resolveLidMappingDirs(opts?: JidToE164Options): string[] {
|
||||
return [...dirs];
|
||||
}
|
||||
|
||||
function readLidReverseMapping(
|
||||
lid: string,
|
||||
opts?: JidToE164Options,
|
||||
): string | null {
|
||||
function readLidReverseMapping(lid: string, opts?: JidToE164Options): string | null {
|
||||
const mappingFilename = `lid-mapping-${lid}_reverse.json`;
|
||||
const mappingDirs = resolveLidMappingDirs(opts);
|
||||
for (const dir of mappingDirs) {
|
||||
@@ -161,20 +158,11 @@ function isLowSurrogate(codeUnit: number): boolean {
|
||||
return codeUnit >= 0xdc00 && codeUnit <= 0xdfff;
|
||||
}
|
||||
|
||||
export function sliceUtf16Safe(
|
||||
input: string,
|
||||
start: number,
|
||||
end?: number,
|
||||
): string {
|
||||
export function sliceUtf16Safe(input: string, start: number, end?: number): string {
|
||||
const len = input.length;
|
||||
|
||||
let from = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
|
||||
let to =
|
||||
end === undefined
|
||||
? len
|
||||
: end < 0
|
||||
? Math.max(len + end, 0)
|
||||
: Math.min(end, len);
|
||||
let to = end === undefined ? len : end < 0 ? Math.max(len + end, 0) : Math.min(end, len);
|
||||
|
||||
if (to < from) {
|
||||
const tmp = from;
|
||||
@@ -184,10 +172,7 @@ export function sliceUtf16Safe(
|
||||
|
||||
if (from > 0 && from < len) {
|
||||
const codeUnit = input.charCodeAt(from);
|
||||
if (
|
||||
isLowSurrogate(codeUnit) &&
|
||||
isHighSurrogate(input.charCodeAt(from - 1))
|
||||
) {
|
||||
if (isLowSurrogate(codeUnit) && isHighSurrogate(input.charCodeAt(from - 1))) {
|
||||
from += 1;
|
||||
}
|
||||
}
|
||||
@@ -265,11 +250,7 @@ export function formatTerminalLink(
|
||||
const safeLabel = label.replaceAll(esc, "");
|
||||
const safeUrl = url.replaceAll(esc, "");
|
||||
const allow =
|
||||
opts?.force === true
|
||||
? true
|
||||
: opts?.force === false
|
||||
? false
|
||||
: Boolean(process.stdout.isTTY);
|
||||
opts?.force === true ? true : opts?.force === false ? false : Boolean(process.stdout.isTTY);
|
||||
if (!allow) {
|
||||
return opts?.fallback ?? `${safeLabel} (${safeUrl})`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user