Skip to content

Commit bd29004

Browse files
authored
feat: enable type-aware no-misused-spread rule, fix 8 violations (#22749)
1 parent 8aa0f9f commit bd29004

8 files changed

Lines changed: 22 additions & 10 deletions

File tree

.opencode/tool/github-pr-search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async function githubFetch(endpoint: string, options: RequestInit = {}) {
77
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
88
Accept: "application/vnd.github+json",
99
"Content-Type": "application/json",
10-
...options.headers,
10+
...(options.headers instanceof Headers ? Object.fromEntries(options.headers.entries()) : options.headers),
1111
},
1212
})
1313
if (!response.ok) {

.opencode/tool/github-triage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function githubFetch(endpoint: string, options: RequestInit = {}) {
2828
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
2929
Accept: "application/vnd.github+json",
3030
"Content-Type": "application/json",
31-
...options.headers,
31+
...(options.headers instanceof Headers ? Object.fromEntries(options.headers.entries()) : options.headers),
3232
},
3333
})
3434
if (!response.ok) {

.oxlintrc.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,15 @@
3737
"no-new": "off",
3838

3939
// Type-aware: catch unhandled promises
40-
"typescript/no-floating-promises": "warn"
40+
"typescript/no-floating-promises": "warn",
41+
// Warn when spreading non-plain objects (Headers, class instances, etc.)
42+
"typescript/no-misused-spread": "warn"
4143
},
4244
"options": {
4345
"typeAware": true
4446
},
45-
"ignorePatterns": ["**/node_modules", "**/dist", "**/.build", "**/.sst", "**/*.d.ts"]
47+
"options": {
48+
"typeAware": true
49+
},
50+
"ignorePatterns": ["**/node_modules", "**/dist", "**/.build", "**/.sst", "**/*.d.ts", "**/sdk.gen.ts"]
4651
}

packages/app/src/utils/server.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ export function createSdkForServer({
1616

1717
return createOpencodeClient({
1818
...config,
19-
headers: { ...config.headers, ...auth },
19+
headers: {
20+
...(config.headers instanceof Headers ? Object.fromEntries(config.headers.entries()) : config.headers),
21+
...auth,
22+
},
2023
baseUrl: server.url,
2124
})
2225
}

packages/console/app/src/routes/download/[channel]/[platform].ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ export async function GET({ params: { platform, channel } }: APIEvent) {
3737
const headers = new Headers(resp.headers)
3838
if (downloadName) headers.set("content-disposition", `attachment; filename="${downloadName}"`)
3939

40-
return new Response(resp.body, { ...resp, headers })
40+
return new Response(resp.body, { status: resp.status, statusText: resp.statusText, headers })
4141
}

packages/opencode/src/cli/cmd/tui/component/logo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ export function Logo() {
520520
const shadow = tint(theme.background, ink, 0.25)
521521
const attrs = bold ? TextAttributes.BOLD : undefined
522522

523-
return [...line].map((char, i) => {
523+
return Array.from(line).map((char, i) => {
524524
const h = field(off + i, y, frame)
525525
const n = wave(off + i, y, frame, lit(char)) + h
526526
const s = wave(off + i, y, dusk, false) + h

packages/opencode/src/server/ui/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export const UIRoutes = (): Hono =>
3737
}
3838
} else {
3939
const response = await proxy(`https://app.opencode.ai${path}`, {
40-
...c.req,
40+
raw: c.req.raw,
4141
headers: {
42-
...c.req.raw.headers,
42+
...Object.fromEntries(c.req.raw.headers.entries()),
4343
host: "app.opencode.ai",
4444
},
4545
})

packages/opencode/src/v2/session-event.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ export namespace SessionEvent {
3939
}) {
4040
static create(input: FileAttachment) {
4141
return new FileAttachment({
42-
...input,
42+
uri: input.uri,
43+
mime: input.mime,
44+
name: input.name,
45+
description: input.description,
46+
source: input.source,
4347
})
4448
}
4549
}

0 commit comments

Comments
 (0)