Skip to content

Commit 702f741

Browse files
authored
feat: enable oxlint suspicious category, fix 24 violations (#22727)
1 parent 665a843 commit 702f741

20 files changed

Lines changed: 49 additions & 22 deletions

File tree

.oxlintrc.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/nicolo-ribaudo/oxc-project.github.io/refs/heads/json-schema/src/public/.oxlintrc.schema.json",
3+
"categories": {
4+
"suspicious": "warn"
5+
},
36
"rules": {
47
// Effect uses `function*` with Effect.gen/Effect.fnUntraced that don't always yield
58
"require-yield": "off",
@@ -10,7 +13,24 @@
1013
// Intentional control char matching (ANSI escapes, null byte sanitization)
1114
"no-control-regex": "off",
1215
// SST and plugin tools require triple-slash references
13-
"triple-slash-reference": "off"
16+
"triple-slash-reference": "off",
17+
18+
// Suspicious category: suppress noisy rules
19+
// Effect's nested function* closures inherently shadow outer scope
20+
"no-shadow": "off",
21+
// Namespace-heavy codebase makes this too noisy
22+
"unicorn/consistent-function-scoping": "off",
23+
// Opinionated — .sort()/.reverse() mutation is fine in this codebase
24+
"unicorn/no-array-sort": "off",
25+
"unicorn/no-array-reverse": "off",
26+
// Not relevant — this isn't a DOM event handler codebase
27+
"unicorn/prefer-add-event-listener": "off",
28+
// Bundler handles module resolution
29+
"unicorn/require-module-specifiers": "off",
30+
// postMessage target origin not relevant for this codebase
31+
"unicorn/require-post-message-target-origin": "off",
32+
// Side-effectful constructors are intentional in some places
33+
"no-new": "off"
1434
},
1535
"ignorePatterns": ["**/node_modules", "**/dist", "**/.build", "**/.sst", "**/*.d.ts"]
1636
}

github/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ async function subscribeSessionEvents() {
542542
? JSON.stringify(part.state.input)
543543
: "Unknown"
544544
console.log()
545-
console.log(color + `|`, "\x1b[0m\x1b[2m" + ` ${tool.padEnd(7, " ")}`, "", "\x1b[0m" + title)
545+
console.log(`${color}|`, `\x1b[0m\x1b[2m ${tool.padEnd(7, " ")}`, "", `\x1b[0m${title}`)
546546
}
547547

548548
if (part.type === "text") {
@@ -776,7 +776,7 @@ async function assertPermissions() {
776776
console.log(` permission: ${permission}`)
777777
} catch (error) {
778778
console.error(`Failed to check permissions: ${error}`)
779-
throw new Error(`Failed to check permissions for user ${actor}: ${error}`)
779+
throw new Error(`Failed to check permissions for user ${actor}: ${error}`, { cause: error })
780780
}
781781

782782
if (!["admin", "write"].includes(permission)) throw new Error(`User ${actor} does not have write permissions`)

packages/app/src/context/global-sdk.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export const { use: useGlobalSDK, provider: GlobalSDKProvider } = createSimpleCo
128128
if (started) return run
129129
started = true
130130
run = (async () => {
131+
// oxlint-disable-next-line no-unmodified-loop-condition -- `started` is set to false by stop() which also aborts; both flags are checked to allow graceful exit
131132
while (!abort.signal.aborted && started) {
132133
attempt = new AbortController()
133134
lastEventAt = Date.now()

packages/app/src/utils/runtime-adapters.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ describe("runtime adapters", () => {
4646
})
4747

4848
test("resolves speech recognition constructor with webkit precedence", () => {
49+
// oxlint-disable-next-line no-extraneous-class
4950
class SpeechCtor {}
51+
// oxlint-disable-next-line no-extraneous-class
5052
class WebkitCtor {}
5153
const ctor = getSpeechRecognitionCtor({
5254
SpeechRecognition: SpeechCtor,

packages/console/app/src/routes/workspace/[id]/billing/reload-section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function ReloadSection() {
9090
}
9191
const info = billingInfo()!
9292
setStore("show", true)
93-
setStore("reload", info.reload ? true : true)
93+
setStore("reload", true)
9494
setStore("reloadAmount", info.reloadAmount.toString())
9595
setStore("reloadTrigger", info.reloadTrigger.toString())
9696
}

packages/desktop-electron/src/main/apps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function wslPath(path: string, mode: "windows" | "linux" | null): string
2828
const output = execFileSync("wsl", ["-e", "wslpath", flag, path])
2929
return output.toString().trim()
3030
} catch (error) {
31-
throw new Error(`Failed to run wslpath: ${String(error)}`)
31+
throw new Error(`Failed to run wslpath: ${String(error)}`, { cause: error })
3232
}
3333
}
3434

packages/function/src/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Env = {
1313
}
1414

1515
export class SyncServer extends DurableObject<Env> {
16+
// oxlint-disable-next-line no-useless-constructor
1617
constructor(ctx: DurableObjectState, env: Env) {
1718
super(ctx, env)
1819
}

packages/opencode/script/postinstall.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function findBinary() {
6464

6565
return { binaryPath, binaryName }
6666
} catch (error) {
67-
throw new Error(`Could not find package ${packageName}: ${error.message}`)
67+
throw new Error(`Could not find package ${packageName}: ${error.message}`, { cause: error })
6868
}
6969
}
7070

packages/opencode/src/bus/bus-event.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export namespace BusEvent {
2525
properties: def.properties,
2626
})
2727
.meta({
28-
ref: "Event" + "." + def.type,
28+
ref: `Event.${def.type}`,
2929
})
3030
})
3131
.toArray()

packages/opencode/src/cli/cmd/debug/agent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ function parseToolParams(input?: string) {
111111
} catch (evalError) {
112112
throw new Error(
113113
`Failed to parse --params. Use JSON or a JS object literal. JSON error: ${jsonError}. Eval error: ${evalError}.`,
114+
{ cause: evalError },
114115
)
115116
}
116117
}

0 commit comments

Comments
 (0)