Skip to content

Commit aa6ce60

Browse files
chore(lint): Enable type-aware Oxlint rules disabled in #1556
Turn the nine type-aware rules back on and fix the violations they report: drop awaits on non-thenables, mark intentional fire-and-forget promises with void, await forgotten assertions, give sorts explicit comparators, stop stringifying unknown values to "[object Object]", and remove redundant type constituents. no-floating-promises allows node:test's test/describe helpers, restrict-template-expressions allows never, and unbound-method stays off in tests, where mock and identity assertions trip it. Fixes #1573 Co-Authored-By: BYK <burak.kaya@sentry.io>
1 parent 36d7aa5 commit aa6ce60

133 files changed

Lines changed: 822 additions & 652 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/tests/pr-risk-labels.test.mjs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ for (const risk of ["low", "medium", "high"]) {
119119
},
120120
async ({ run, labels }) => {
121121
await run();
122-
assert.deepEqual([...labels].sort(), ["area: auth", `risk: ${risk}`]);
122+
assert.deepEqual(
123+
[...labels].sort((a, b) => a.localeCompare(b)),
124+
["area: auth", `risk: ${risk}`],
125+
);
123126
},
124127
);
125128
});

‎.oxlintrc.json‎

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,33 @@
2020
"rules": {
2121
"no-unused-vars": "off",
2222
"typescript/return-await": ["error", "always"],
23-
"typescript/await-thenable": "off",
24-
"typescript/no-base-to-string": "off",
25-
"typescript/no-duplicate-type-constituents": "off",
26-
"typescript/no-floating-promises": "off",
27-
"typescript/no-misused-spread": "off",
28-
"typescript/no-redundant-type-constituents": "off",
29-
"typescript/require-array-sort-compare": "off",
30-
"typescript/restrict-template-expressions": "off",
31-
"typescript/unbound-method": "off",
23+
"typescript/no-floating-promises": [
24+
"error",
25+
{
26+
"allowForKnownSafeCalls": [
27+
{
28+
"from": "package",
29+
"package": "node:test",
30+
"name": ["test", "it", "describe", "suite"]
31+
}
32+
]
33+
}
34+
],
35+
"typescript/restrict-template-expressions": [
36+
"error",
37+
{
38+
"allowNever": true
39+
}
40+
],
3241
"jsx-a11y/interactive-supports-focus": "off"
3342
},
3443
"overrides": [
44+
{
45+
"files": ["**/*.test.{ts,tsx,mjs}", "**/test/**/*.{ts,tsx}"],
46+
"rules": {
47+
"typescript/unbound-method": "off"
48+
}
49+
},
3550
{
3651
"files": ["packages/mcp-cloudflare/src/client/**/*.tsx"],
3752
"rules": {

‎packages/cli/script/build.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ async function compileAllTargets(
418418
successes += 1;
419419
} catch (error) {
420420
console.error(
421-
` Post-processing ${getPackageName(target)} failed: ${error}`,
421+
` Post-processing ${getPackageName(target)} failed: ${String(error)}`,
422422
);
423423
failures += 1;
424424
}

‎packages/cli/src/commands/alert/issues/create.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import {
1111
} from "../../../lib/api-client.js";
1212
import { parseOrgProjectArg } from "../../../lib/arg-parsing.js";
1313
import { buildCommand, numberParser } from "../../../lib/command.js";
14-
import { ContextError, ValidationError } from "../../../lib/errors.js";
14+
import {
15+
ContextError,
16+
stringifyUnknown,
17+
ValidationError,
18+
} from "../../../lib/errors.js";
1519
import { CommandOutput } from "../../../lib/formatters/output.js";
1620
import { DRY_RUN_ALIASES, DRY_RUN_FLAG } from "../../../lib/mutate-command.js";
1721
import { resolveProjectBoundTargets } from "../../../lib/resolve-target.js";
@@ -244,9 +248,9 @@ export const createCommand = buildCommand({
244248
yield new CommandOutput({
245249
org: target.org,
246250
project: target.project,
247-
id: String(created.id ?? ""),
248-
name: String(created.name ?? flags.name),
249-
status: String(
251+
id: stringifyUnknown(created.id ?? ""),
252+
name: stringifyUnknown(created.name ?? flags.name),
253+
status: stringifyUnknown(
250254
created.status ?? (created.enabled === false ? "disabled" : "active"),
251255
),
252256
} satisfies CreateResult);

‎packages/cli/src/commands/alert/issues/edit.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import {
1212
} from "../../../lib/api-client.js";
1313
import { parseOrgProjectArg } from "../../../lib/arg-parsing.js";
1414
import { buildCommand, numberParser } from "../../../lib/command.js";
15-
import { ContextError, ValidationError } from "../../../lib/errors.js";
15+
import {
16+
ContextError,
17+
stringifyUnknown,
18+
ValidationError,
19+
} from "../../../lib/errors.js";
1620
import { CommandOutput } from "../../../lib/formatters/output.js";
1721
import { resolveProjectBoundTargets } from "../../../lib/resolve-target.js";
1822
import {
@@ -284,10 +288,10 @@ export const editCommand = buildCommand({
284288
...updated,
285289
org: target.org,
286290
project: target.project,
287-
id: String(updated.id ?? rule.id),
291+
id: stringifyUnknown(updated.id ?? rule.id),
288292
// The workflows endpoint returns `enabled` rather than `status`; map it
289293
// back to a status label so human/JSON output matches the create path.
290-
status: String(
294+
status: stringifyUnknown(
291295
updated.status ?? (updated.enabled === false ? "disabled" : "active"),
292296
),
293297
} satisfies EditResult);

‎packages/cli/src/commands/alert/issues/rule-resolve.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function parseIssueRuleArg(
4242
);
4343
}
4444

45-
const slashCount = [...trimmed].filter((c) => c === "/").length;
45+
const slashCount = trimmed.split("/").length - 1;
4646
if (slashCount === 0) {
4747
return { ref: trimmed, targetArg: undefined };
4848
}

‎packages/cli/src/commands/alert/metrics/create.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import type { SentryContext } from "../../../context.js";
88
import { createMetricAlertRule } from "../../../lib/api-client.js";
99
import { buildCommand, numberParser } from "../../../lib/command.js";
10-
import { ValidationError } from "../../../lib/errors.js";
10+
import { stringifyUnknown, ValidationError } from "../../../lib/errors.js";
1111
import { warning } from "../../../lib/formatters/colors.js";
1212
import { CommandOutput } from "../../../lib/formatters/output.js";
1313
import { DRY_RUN_ALIASES, DRY_RUN_FLAG } from "../../../lib/mutate-command.js";
@@ -222,8 +222,8 @@ export const createCommand = buildCommand({
222222
const created = await createMetricAlertRule(orgSlug, body);
223223
yield new CommandOutput({
224224
org: orgSlug,
225-
id: String(created.id ?? ""),
226-
name: String(created.name ?? flags.name),
225+
id: stringifyUnknown(created.id ?? ""),
226+
name: stringifyUnknown(created.name ?? flags.name),
227227
status: metricAlertStatusLabel(created.status),
228228
} satisfies CreateResult);
229229
},

‎packages/cli/src/commands/alert/metrics/edit.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
putMetricAlertRule,
1111
} from "../../../lib/api-client.js";
1212
import { buildCommand, numberParser } from "../../../lib/command.js";
13-
import { ValidationError } from "../../../lib/errors.js";
13+
import { stringifyUnknown, ValidationError } from "../../../lib/errors.js";
1414
import { warning } from "../../../lib/formatters/colors.js";
1515
import { CommandOutput } from "../../../lib/formatters/output.js";
1616
import { resolveOrgOnlyFromArg } from "../../../lib/resolve-target.js";
@@ -290,7 +290,7 @@ export const editCommand = buildCommand({
290290
yield new CommandOutput({
291291
...updated,
292292
org: orgSlug,
293-
id: String(updated.id ?? rule.id),
293+
id: stringifyUnknown(updated.id ?? rule.id),
294294
status: metricAlertStatusLabel(updated.status),
295295
} satisfies EditResult);
296296
},

‎packages/cli/src/commands/alert/metrics/rule-resolve.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export function parseMetricRuleArg(
4545
return { ref: trimmed, targetArg: undefined };
4646
}
4747

48-
const slashCount = [...trimmed].filter((c) => c === "/").length;
48+
const slashCount = trimmed.split("/").length - 1;
4949
if (slashCount > 1) {
5050
throw new ValidationError(
5151
`Metric alerts are org-scoped — use '<org>/<rule-id-or-name>', not '<org>/<project>/<rule>'.\nUse: ${usageHint}`,

‎packages/cli/src/commands/api.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import * as Sentry from "@sentry/node-core/light";
1111
import type { SentryContext } from "../context.js";
1212
import { appendSearchParams, rawApiRequest } from "../lib/api-client.js";
1313
import { buildCommand } from "../lib/command.js";
14-
import { OutputError, ValidationError } from "../lib/errors.js";
14+
import {
15+
OutputError,
16+
stringifyUnknown,
17+
ValidationError,
18+
} from "../lib/errors.js";
1519
import { filterFields } from "../lib/formatters/json.js";
1620
import { CommandOutput } from "../lib/formatters/output.js";
1721
import { validateEndpoint } from "../lib/input-validation.js";
@@ -1071,7 +1075,7 @@ export function formatApiResponse(data: unknown): string {
10711075
if (typeof data === "object") {
10721076
return JSON.stringify(data, null, 2);
10731077
}
1074-
return String(data);
1078+
return stringifyUnknown(data);
10751079
}
10761080

10771081
/**

0 commit comments

Comments
 (0)