Skip to content

Commit 153d21e

Browse files
betegonclaude
andcommitted
fix(ci): resolve lint formatting and test failures
Fix 10 lint errors (trailing commas, line length, import ordering, Response.json) and 2 test failures caused by fetchProjectId requiring auth/region mocks when CLI flags are passed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 23cec1a commit 153d21e

File tree

4 files changed

+64
-11
lines changed

4 files changed

+64
-11
lines changed

src/commands/issue/list.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -938,10 +938,12 @@ async function handleResolvedTargets(
938938
const failures: { target: ResolvedTarget; error: Error }[] = [];
939939

940940
for (let i = 0; i < results.length; i++) {
941+
// biome-ignore lint/style/noNonNullAssertion: index within bounds
941942
const result = results[i]!;
942943
if (result.success) {
943944
validResults.push(result.data);
944945
} else {
946+
// biome-ignore lint/style/noNonNullAssertion: index within bounds
945947
failures.push({ target: activeTargets[i]!, error: result.error });
946948
}
947949
}
@@ -957,7 +959,7 @@ async function handleResolvedTargets(
957959
`${prefix}: ${first.message}`,
958960
first.status,
959961
first.detail,
960-
first.endpoint,
962+
first.endpoint
961963
);
962964
}
963965

@@ -1007,8 +1009,12 @@ async function handleResolvedTargets(
10071009
if (failures.length > 0) {
10081010
output.errors = failures.map(({ target: t, error: e }) =>
10091011
e instanceof ApiError
1010-
? { project: `${t.org}/${t.project}`, status: e.status, message: e.message }
1011-
: { project: `${t.org}/${t.project}`, message: e.message },
1012+
? {
1013+
project: `${t.org}/${t.project}`,
1014+
status: e.status,
1015+
message: e.message,
1016+
}
1017+
: { project: `${t.org}/${t.project}`, message: e.message }
10121018
);
10131019
}
10141020
writeJson(stdout, output);
@@ -1021,8 +1027,8 @@ async function handleResolvedTargets(
10211027
.join(", ");
10221028
stderr.write(
10231029
muted(
1024-
`\nNote: Failed to fetch issues from ${failedNames}. Showing results from ${validResults.length} project(s).\n`,
1025-
),
1030+
`\nNote: Failed to fetch issues from ${failedNames}. Showing results from ${validResults.length} project(s).\n`
1031+
)
10261032
);
10271033
}
10281034

src/lib/resolve-target.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ import { isAllDigits } from "./utils.js";
4949

5050
/** Convert a string or numeric ID to a number, or `undefined` if falsy/NaN. */
5151
export function toNumericId(
52-
id: string | number | undefined,
52+
id: string | number | undefined
5353
): number | undefined {
54-
if (id == null) return undefined;
54+
if (id === null) {
55+
return;
56+
}
5557
return Number(id) || undefined;
5658
}
5759

@@ -551,7 +553,7 @@ function resolveFromEnvVars(): {
551553
*/
552554
export async function fetchProjectId(
553555
org: string,
554-
project: string,
556+
project: string
555557
): Promise<number | undefined> {
556558
try {
557559
const projectInfo = await getProject(org, project);
@@ -567,7 +569,7 @@ export async function fetchProjectId(
567569
`sentry issue list ${org}/<project>`,
568570
[
569571
`Check the project slug at https://sentry.io/organizations/${org}/projects/`,
570-
],
572+
]
571573
);
572574
}
573575
return;

test/commands/issue/list.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ describe("issue list: partial failure handling", () => {
363363
"myproj"
364364
);
365365

366-
expect(stderr.output).toContain("Failed to fetch issues from org-two/myproj");
366+
expect(stderr.output).toContain(
367+
"Failed to fetch issues from org-two/myproj"
368+
);
367369
expect(stderr.output).toContain("Showing results from 1 project(s)");
368370
});
369371

test/lib/resolve-target.test.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88

99
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
1010
import { array, constantFrom, assert as fcAssert, property } from "fast-check";
11-
11+
import { DEFAULT_SENTRY_URL } from "../../src/lib/constants.js";
12+
import { setAuthToken } from "../../src/lib/db/auth.js";
13+
import { setOrgRegion } from "../../src/lib/db/regions.js";
1214
import {
1315
isValidDirNameForInference,
1416
resolveAllTargets,
1517
resolveOrg,
1618
resolveOrgAndProject,
1719
resolveOrgsForListing,
1820
} from "../../src/lib/resolve-target.js";
21+
import { mockFetch, useTestConfigDir } from "../helpers.js";
1922

2023
// ============================================================================
2124
// Arbitraries for Property-Based Testing
@@ -111,12 +114,18 @@ describe("isValidDirNameForInference edge cases", () => {
111114
// ============================================================================
112115

113116
describe("Environment variable resolution (SENTRY_ORG / SENTRY_PROJECT)", () => {
117+
useTestConfigDir("test-resolve-target-");
118+
119+
let originalFetch: typeof globalThis.fetch;
120+
114121
beforeEach(() => {
122+
originalFetch = globalThis.fetch;
115123
delete process.env.SENTRY_ORG;
116124
delete process.env.SENTRY_PROJECT;
117125
});
118126

119127
afterEach(() => {
128+
globalThis.fetch = originalFetch;
120129
delete process.env.SENTRY_ORG;
121130
delete process.env.SENTRY_PROJECT;
122131
});
@@ -171,6 +180,23 @@ describe("Environment variable resolution (SENTRY_ORG / SENTRY_PROJECT)", () =>
171180
test("resolveOrgAndProject: CLI flags override env vars", async () => {
172181
process.env.SENTRY_ORG = "env-org";
173182
process.env.SENTRY_PROJECT = "env-project";
183+
184+
await setAuthToken("test-token");
185+
await setOrgRegion("flag-org", DEFAULT_SENTRY_URL);
186+
globalThis.fetch = mockFetch(async (input, init) => {
187+
const req = new Request(input, init);
188+
if (req.url.includes("/api/0/projects/flag-org/flag-project/")) {
189+
return Response.json({
190+
id: "123",
191+
slug: "flag-project",
192+
name: "Flag Project",
193+
});
194+
}
195+
return new Response(JSON.stringify({ detail: "Not found" }), {
196+
status: 404,
197+
});
198+
});
199+
174200
const result = await resolveOrgAndProject({
175201
org: "flag-org",
176202
project: "flag-project",
@@ -236,6 +262,23 @@ describe("Environment variable resolution (SENTRY_ORG / SENTRY_PROJECT)", () =>
236262
test("resolveAllTargets: CLI flags override env vars", async () => {
237263
process.env.SENTRY_ORG = "env-org";
238264
process.env.SENTRY_PROJECT = "env-project";
265+
266+
await setAuthToken("test-token");
267+
await setOrgRegion("flag-org", DEFAULT_SENTRY_URL);
268+
globalThis.fetch = mockFetch(async (input, init) => {
269+
const req = new Request(input, init);
270+
if (req.url.includes("/api/0/projects/flag-org/flag-project/")) {
271+
return Response.json({
272+
id: "123",
273+
slug: "flag-project",
274+
name: "Flag Project",
275+
});
276+
}
277+
return new Response(JSON.stringify({ detail: "Not found" }), {
278+
status: 404,
279+
});
280+
});
281+
239282
const result = await resolveAllTargets({
240283
org: "flag-org",
241284
project: "flag-project",

0 commit comments

Comments
 (0)