Switch to BiomeJS (#306)

This commit is contained in:
Gregory Schier
2025-11-23 08:38:13 -08:00
committed by GitHub
parent 2bac610efe
commit ec3e2e16a9
332 changed files with 3007 additions and 4097 deletions

View File

@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { PartialImportResources } from '@yaakapp/api';
import { convertId, convertTemplateSyntax, isJSObject } from './common';
// biome-ignore lint/suspicious/noExplicitAny: none
export function convertInsomniaV5(parsed: any) {
// Assert parsed is object
if (parsed == null || typeof parsed !== 'object') {
@@ -22,6 +22,7 @@ export function convertInsomniaV5(parsed: any) {
};
// Import workspaces
// biome-ignore lint/suspicious/noExplicitAny: none
const meta = ('meta' in parsed ? parsed.meta : {}) as Record<string, any>;
resources.workspaces.push({
id: convertId(meta.id ?? 'collection'),
@@ -37,10 +38,12 @@ export function convertInsomniaV5(parsed: any) {
// Import environments
resources.environments.push(
importEnvironment(parsed.environments, meta.id, true),
// biome-ignore lint/suspicious/noExplicitAny: none
...(parsed.environments.subEnvironments ?? []).map((r: any) => importEnvironment(r, meta.id)),
);
// Import folders
// biome-ignore lint/suspicious/noExplicitAny: none
const nextFolder = (children: any[], parentId: string) => {
for (const child of children ?? []) {
if (!isJSObject(child)) continue;
@@ -73,6 +76,7 @@ export function convertInsomniaV5(parsed: any) {
}
function importHttpRequest(
// biome-ignore lint/suspicious/noExplicitAny: none
r: any,
workspaceId: string,
parentId: string,
@@ -90,6 +94,7 @@ function importHttpRequest(
} else if (r.body?.mimeType === 'application/x-www-form-urlencoded') {
bodyType = 'application/x-www-form-urlencoded';
body = {
// biome-ignore lint/suspicious/noExplicitAny: none
form: (r.body.params ?? []).map((p: any) => ({
enabled: !p.disabled,
name: p.name ?? '',
@@ -99,6 +104,7 @@ function importHttpRequest(
} else if (r.body?.mimeType === 'multipart/form-data') {
bodyType = 'multipart/form-data';
body = {
// biome-ignore lint/suspicious/noExplicitAny: none
form: (r.body.params ?? []).map((p: any) => ({
enabled: !p.disabled,
name: p.name ?? '',
@@ -125,6 +131,7 @@ function importHttpRequest(
name: r.name,
description: r.meta?.description || undefined,
url: r.url,
// biome-ignore lint/suspicious/noExplicitAny: none
urlParameters: (r.parameters ?? []).map((p: any) => ({
enabled: !p.disabled,
name: p.name ?? '',
@@ -139,6 +146,7 @@ function importHttpRequest(
}
function importGrpcRequest(
// biome-ignore lint/suspicious/noExplicitAny: none
r: any,
workspaceId: string,
parentId: string,
@@ -148,6 +156,7 @@ function importGrpcRequest(
const updated = r.meta?.modified ?? r.updated;
const sortKey = r.meta?.sortKey ?? r.sortKey;
// biome-ignore lint/suspicious/noExplicitAny: none
const parts = r.protoMethodName.split('/').filter((p: any) => p !== '');
const service = parts[0] ?? null;
const method = parts[1] ?? null;
@@ -167,16 +176,19 @@ function importGrpcRequest(
method,
message: r.body?.text ?? '',
metadata: (r.metadata ?? [])
// biome-ignore lint/suspicious/noExplicitAny: none
.map((h: any) => ({
enabled: !h.disabled,
name: h.name ?? '',
value: h.value ?? '',
}))
// biome-ignore lint/suspicious/noExplicitAny: none
.filter(({ name, value }: any) => name !== '' || value !== ''),
};
}
function importWebsocketRequest(
// biome-ignore lint/suspicious/noExplicitAny: none
r: any,
workspaceId: string,
parentId: string,
@@ -203,17 +215,21 @@ function importWebsocketRequest(
};
}
// biome-ignore lint/suspicious/noExplicitAny: none
function importHeaders(obj: any) {
const headers = (obj.headers ?? [])
// biome-ignore lint/suspicious/noExplicitAny: none
.map((h: any) => ({
enabled: !h.disabled,
name: h.name ?? '',
value: h.value ?? '',
}))
// biome-ignore lint/suspicious/noExplicitAny: none
.filter(({ name, value }: any) => name !== '' || value !== '');
return { headers } as const;
}
// biome-ignore lint/suspicious/noExplicitAny: none
function importAuthentication(obj: any) {
let authenticationType: string | null = null;
let authentication = {};
@@ -234,6 +250,7 @@ function importAuthentication(obj: any) {
}
function importFolder(
// biome-ignore lint/suspicious/noExplicitAny: none
f: any,
workspaceId: string,
parentId: string,
@@ -249,7 +266,7 @@ function importFolder(
let environment: PartialImportResources['environments'][0] | null = null;
if (Object.keys(f.environment ?? {}).length > 0) {
environment = {
id: convertId(id + 'folder'),
id: convertId(`${id}folder`),
createdAt: created ? new Date(created).toISOString().replace('Z', '') : undefined,
updatedAt: updated ? new Date(updated).toISOString().replace('Z', '') : undefined,
workspaceId: convertId(workspaceId),
@@ -285,6 +302,7 @@ function importFolder(
}
function importEnvironment(
// biome-ignore lint/suspicious/noExplicitAny: none
e: any,
workspaceId: string,
isParent?: boolean,