mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-17 22:39:42 +02:00
Fix all lint errors
This commit is contained in:
@@ -19,7 +19,8 @@ export function isJSON(text: string): boolean {
|
||||
try {
|
||||
JSON.parse(text);
|
||||
return true;
|
||||
} catch (_) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ export function tryFormatJson(text: string, pretty = true): string {
|
||||
try {
|
||||
if (pretty) return JSON.stringify(JSON.parse(text), null, INDENT);
|
||||
else return JSON.stringify(JSON.parse(text));
|
||||
} catch (_) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (err) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -18,7 +19,8 @@ export function tryFormatXml(text: string): string {
|
||||
|
||||
try {
|
||||
return xmlFormat(text, { throwOnFailure: true, strictMode: false, indentation: INDENT });
|
||||
} catch (_) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (err) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ export function extractKeyValue<T>(kv: KeyValue | null): T | undefined {
|
||||
try {
|
||||
return JSON.parse(kv.value) as T;
|
||||
} catch (err) {
|
||||
console.log('Failed to parse kv value', kv.value, err);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ export async function getResponseBodyText(response: HttpResponse): Promise<strin
|
||||
|
||||
try {
|
||||
return new TextDecoder(charset ?? 'utf-8', { fatal: true }).decode(bytes);
|
||||
} catch (_) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
} catch (err) {
|
||||
// Failed to decode as text, so return null
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user