chore: Lint extensions folder.

This commit is contained in:
cpojer
2026-01-31 22:13:48 +09:00
parent 4f2166c503
commit 230ca789e2
221 changed files with 4006 additions and 1583 deletions

View File

@@ -40,7 +40,9 @@ export type MSTeamsUserResolution = {
};
function readAccessToken(value: unknown): string | null {
if (typeof value === "string") return value;
if (typeof value === "string") {
return value;
}
if (value && typeof value === "object") {
const token =
(value as { accessToken?: unknown }).accessToken ?? (value as { token?: unknown }).token;
@@ -55,7 +57,9 @@ function stripProviderPrefix(raw: string): string {
export function normalizeMSTeamsMessagingTarget(raw: string): string | undefined {
let trimmed = raw.trim();
if (!trimmed) return undefined;
if (!trimmed) {
return undefined;
}
trimmed = stripProviderPrefix(trimmed).trim();
if (/^conversation:/i.test(trimmed)) {
const id = trimmed.slice("conversation:".length).trim();
@@ -76,7 +80,9 @@ export function normalizeMSTeamsUserInput(raw: string): string {
export function parseMSTeamsConversationId(raw: string): string | null {
const trimmed = stripProviderPrefix(raw).trim();
if (!/^conversation:/i.test(trimmed)) return null;
if (!/^conversation:/i.test(trimmed)) {
return null;
}
const id = trimmed.slice("conversation:".length).trim();
return id;
}
@@ -95,7 +101,9 @@ function normalizeMSTeamsChannelKey(raw?: string | null): string | undefined {
export function parseMSTeamsTeamChannelInput(raw: string): { team?: string; channel?: string } {
const trimmed = stripProviderPrefix(raw).trim();
if (!trimmed) return {};
if (!trimmed) {
return {};
}
const parts = trimmed.split("/");
const team = normalizeMSTeamsTeamKey(parts[0] ?? "");
const channel =
@@ -110,7 +118,9 @@ export function parseMSTeamsTeamEntry(
raw: string,
): { teamKey: string; channelKey?: string } | null {
const { team, channel } = parseMSTeamsTeamChannelInput(raw);
if (!team) return null;
if (!team) {
return null;
}
return {
teamKey: team,
...(channel ? { channelKey: channel } : {}),
@@ -133,7 +143,7 @@ async function fetchGraphJson<T>(params: {
const res = await fetch(`${GRAPH_ROOT}${params.path}`, {
headers: {
Authorization: `Bearer ${params.token}`,
...(params.headers ?? {}),
...params.headers,
},
});
if (!res.ok) {
@@ -147,12 +157,16 @@ async function resolveGraphToken(cfg: unknown): Promise<string> {
const creds = resolveMSTeamsCredentials(
(cfg as { channels?: { msteams?: unknown } })?.channels?.msteams,
);
if (!creds) throw new Error("MS Teams credentials missing");
if (!creds) {
throw new Error("MS Teams credentials missing");
}
const { sdk, authConfig } = await loadMSTeamsSdkWithAuth(creds);
const tokenProvider = new sdk.MsalTokenProvider(authConfig);
const token = await tokenProvider.getAccessToken("https://graph.microsoft.com");
const accessToken = readAccessToken(token);
if (!accessToken) throw new Error("MS Teams graph token unavailable");
if (!accessToken) {
throw new Error("MS Teams graph token unavailable");
}
return accessToken;
}