Skip to content
Merged
1 change: 1 addition & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"typescript/no-useless-default-assignment": "error",
"jsx-a11y/interactive-supports-focus": "off",
"unicorn/prefer-spread": "error",
"unicorn/no-array-for-each": "error",
"typescript/no-misused-promises": "error",
"typescript/switch-exhaustiveness-check": [
"error",
Expand Down
4 changes: 3 additions & 1 deletion apps/games-api/src/leaderboard.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ describe("games leaderboard route", () => {
"kk",
"ll",
];
names.forEach((n, i) => rows.push([`${n}-${n}-100${i % 10}`, 300 - i]));
for (const [i, n] of names.entries()) {
rows.push([`${n}-${n}-100${i % 10}`, 300 - i]);
}
fetchMock.mockResolvedValue(jsonResponse(upstreamBody(rows)));

const res = await app.request(PATH, REQ, makeEnv());
Expand Down
14 changes: 7 additions & 7 deletions apps/local/src/lib/profile-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ export function mergeProfileChunks(
const frameMap = new Map<number, number>(),
stackMap = new Map<number, number>();
if (Array.isArray(profile["frames"]))
profile["frames"].forEach((frame, index) => {
if (!Object.keys(record(frame)).length) return;
for (const [index, frame] of profile["frames"].entries()) {
if (!Object.keys(record(frame)).length) continue;
const key = profileValueKey(frame);
let id = frameIds.get(key);
if (id === undefined) {
Expand All @@ -138,15 +138,15 @@ export function mergeProfileChunks(
frameIds.set(key, id);
}
frameMap.set(index, id);
});
}
if (Array.isArray(profile["stacks"]))
profile["stacks"].forEach((stack, index) => {
if (!Array.isArray(stack)) return;
stacks: for (const [index, stack] of profile["stacks"].entries()) {
if (!Array.isArray(stack)) continue;
const mapped: number[] = [];
for (const frame of stack) {
const id =
typeof frame === "number" ? frameMap.get(frame) : undefined;
if (id === undefined) return; // Broken indexes cannot silently describe another frame.
if (id === undefined) continue stacks; // Broken indexes cannot silently describe another frame.
mapped.push(id);
}
const key = JSON.stringify(mapped);
Expand All @@ -157,7 +157,7 @@ export function mergeProfileChunks(
stackIds.set(key, id);
}
stackMap.set(index, id);
});
}
const chunkThreads = new Map<string, Record<string, unknown>[]>();
if (Array.isArray(profile["samples"]))
for (const value of profile["samples"]) {
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
"@types/yauzl": "3.4.0",
"@typescript/typescript6": "catalog:",
"@vitest/coverage-v8": "catalog:",
"ast-types": "^0.16.3",
"binpatch": "^0.4.2",
"chalk": "^5.6.2",
"cli-highlight": "^2.1.11",
Expand All @@ -141,6 +142,7 @@
"pngjs": "^7.0.0",
"pretty-ms": "^9.3.0",
"qrcode-terminal": "^0.12.0",
"recast": "^0.23.21",
"semver": "^7.8.5",
"shell-quote": "^1.11.0",
"string-width": "^8.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1487,9 +1487,9 @@ function logResponse(response: {
log.debug(
`< HTTP ${response.status}${response.statusText ? ` ${response.statusText}` : ""}`,
);
response.headers.forEach((value, key) => {
for (const [key, value] of response.headers) {
log.debug(`< ${key}: ${value}`);
});
}
log.debug("<");
}

Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/lib/db/completion-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export function cacheCompletionEntities(
)
.get(kind, orgSlug) as { latest: number | null } | undefined;
const now = Math.max(Date.now(), (latest?.latest ?? 0) + valid.length);
valid.forEach((entity, index) => {
for (const [index, entity] of valid.entries()) {
runUpsert(
db,
"completion_cache",
Expand All @@ -127,7 +127,7 @@ export function cacheCompletionEntities(
},
["kind", "org_slug", "value"],
);
});
}
db.query(
`DELETE FROM completion_cache
WHERE kind = ? AND org_slug = ? AND rowid NOT IN (
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/lib/dsn/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import type { DsnDetectionResult } from "./types.js";
export function formatConflictError(result: DsnDetectionResult): string {
const lines = ["Error: Multiple Sentry DSNs detected in this project.\n"];

result.all.forEach((dsn, i) => {
for (const [i, dsn] of result.all.entries()) {
lines.push(` DSN ${i + 1}: ${dsn.raw}`);
lines.push(` Source: ${getDsnSourceDescription(dsn)}`);
if (dsn.projectId) {
lines.push(` Project ID: ${dsn.projectId}`);
}
lines.push("");
});
}

lines.push("To resolve, specify which project to use:");
lines.push(` ${sentry`<command> <org>/<project>`}`);
Expand Down
22 changes: 22 additions & 0 deletions packages/cli/src/lib/dsn/fs-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,25 @@ export async function isRegularFile(
return false;
}
}

/**
* Find the first of `basePath` + each extension that is a regular file, for
* config files whose extension isn't known yet (`next.config` →
* `next.config.mjs`).
*
* @param basePath - Path without the extension
* @param extensions - Extensions to try, in order, each with its leading dot
* @returns The first matching path, or undefined when none is a regular file
*/
export async function findFile(
basePath: string,
extensions: readonly string[] = [".js", ".ts", ".mjs", ".cjs"],
): Promise<string | undefined> {
for (const extension of extensions) {
const candidate = `${basePath}${extension}`;
if (await isRegularFile(candidate, "findFile")) {
return candidate;
}
}
return undefined;
}
8 changes: 4 additions & 4 deletions packages/cli/src/lib/formatters/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ function conditionRows(value: unknown, detector: boolean): Row[] {
const rows: Row[] = [["Logic", valueText(group["logicType"])]];
const conditions = group["conditions"];
if (Array.isArray(conditions) && conditions.length > 0) {
conditions.forEach((condition, index) => {
for (const [index, condition] of conditions.entries()) {
rows.push([`Condition ${index + 1}`, conditionText(condition, detector)]);
});
}
} else {
rows.push([
"Conditions",
Expand Down Expand Up @@ -150,11 +150,11 @@ function workflowSections(workflow: GetOrganizationWorkflowResponse): string[] {
...workflowGroupSections(workflow.triggers, "Triggers"),
];
if (workflow.actionFilters?.length) {
workflow.actionFilters.forEach((group, index) => {
for (const [index, group] of workflow.actionFilters.entries()) {
sections.push(
...workflowGroupSections(group, `Action filter ${index + 1}`),
);
});
}
} else {
sections.push(table([["Action filters", "none"]]));
}
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/lib/formatters/human.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1286,15 +1286,15 @@ function formatSpanSimple(span: TraceSpan, opts: FormatSpanOptions): void {
if (currentDepth < maxDepth) {
const children = span.children ?? [];
const childCount = children.length;
children.forEach((child, i) => {
for (const [i, child] of children.entries()) {
formatSpanSimple(child, {
lines,
prefix: childPrefix,
isLast: i === childCount - 1,
currentDepth: currentDepth + 1,
maxDepth,
});
});
}
}
}

Expand Down Expand Up @@ -1367,15 +1367,15 @@ export function formatSimpleSpanTree(
const displaySpans = truncated ? spans.slice(0, MAX_ROOT_SPANS) : spans;
const displayCount = displaySpans.length;

displaySpans.forEach((span, i) => {
for (const [i, span] of displaySpans.entries()) {
formatSpanSimple(span, {
lines,
prefix: "",
isLast: !truncated && i === displayCount - 1,
currentDepth: 1,
maxDepth: effectiveMaxDepth,
});
});
}

if (truncated) {
const remaining = totalRootSpans - MAX_ROOT_SPANS;
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/lib/games/snake-game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ export function renderSnake(
if (state.food) {
cells[state.food.y * state.width + state.food.x] = FOOD;
}
state.body.forEach((part, index) => {
for (const [index, part] of state.body.entries()) {
cells[part.y * state.width + part.x] = index === 0 ? HEAD : BODY;
});
}

const lines: string[] = [];
for (let row = 0; row < snakeTerminalRows(state.height); row++) {
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/lib/select-ui/picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,14 @@ function renderPicker(

const accent = chalk.hex(ACCENT);
const lines = [""];
titleLines.forEach((line, index) => {
for (const [index, line] of titleLines.entries()) {
const icon = padIcon(index === 0 ? ICONS.diamondOpen : "");
const counter =
index === 0 && isWindowed
? chalk.hex(MUTED_DIM)(` (${highlighted + 1}/${filtered.length})`)
: "";
lines.push(`${accent.bold(icon)}${chalk.bold(line)}${counter}`);
});
}
lines.push("");

const optionLines =
Expand Down
18 changes: 18 additions & 0 deletions packages/cli/src/lib/sentry-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,24 @@ export function buildEventSearchUrl(orgSlug: string, eventId: string): string {
return `${getSentryBaseUrl()}/organizations/${orgSlug}/issues/?query=event.id:${eventId}`;
}

/**
* Build URL to a project's issue stream in Sentry.
*
* @param orgSlug - Organization slug
* @param projectId - Numeric project ID
* @returns Full URL to the issues list filtered to the project
*/
export function buildProjectIssuesUrl(
orgSlug: string,
projectId: string,
): string {
const project = encodeURIComponent(projectId);
if (isSaaS()) {
return `${getOrgBaseUrl(orgSlug)}/issues/?project=${project}`;
}
return `${getSentryBaseUrl()}/organizations/${orgSlug}/issues/?project=${project}`;
}
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved

// Settings URLs

/**
Expand Down
8 changes: 8 additions & 0 deletions packages/cli/src/lib/sentry-web-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
buildMetricAlertsUrl as buildMetricAlertsUrlPure,
buildOrgSettingsUrl as buildOrgSettingsUrlPure,
buildOrgUrl as buildOrgUrlPure,
buildProjectIssuesUrl as buildProjectIssuesUrlPure,
buildProjectUrl as buildProjectUrlPure,
buildReleaseUrl as buildReleaseUrlPure,
buildReplayUrl as buildReplayUrlPure,
Expand Down Expand Up @@ -56,6 +57,13 @@ export function buildEventSearchUrl(orgSlug: string, eventId: string): string {
return render(() => buildEventSearchUrlPure(orgSlug, eventId));
}

export function buildProjectIssuesUrl(
orgSlug: string,
projectId: string,
): string {
return render(() => buildProjectIssuesUrlPure(orgSlug, projectId));
}

export function buildOrgSettingsUrl(orgSlug: string, hash?: string): string {
return render(() => buildOrgSettingsUrlPure(orgSlug, hash));
}
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/lib/sixel-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,9 @@ export function encodeImageToSixel(
// DCS: P1=0 aspect, P2=1 (unpainted = transparent), P3=0 grid; then raster
// attributes "1;1;W;H so the terminal reserves the right pixel box.
let out = `\x1bP0;1;0q"1;1;${width};${height}`;
palette.forEach(([r, g, b], i) => {
for (const [i, [r, g, b]] of palette.entries()) {
out += `#${i};2;${to100(r)};${to100(g)};${to100(b)}`;
});
}

const totalBands = Math.ceil(height / 6);
for (let band = 0; band < totalBands; band++) {
Expand Down
Loading
Loading