mirror of
https://github.com/anomalyco/opencode.git
synced 2026-02-01 22:48:16 +00:00
1.5 KiB
1.5 KiB
- To regenerate the JavaScript SDK, run
./packages/sdk/js/script/build.ts. - ALWAYS USE PARALLEL TOOLS WHEN APPLICABLE.
- The default branch in this repo is
dev.
Style Guide
- Keep things in one function unless composable or reusable
- Avoid unnecessary destructuring. Instead of
const { a, b } = obj, useobj.aandobj.bto preserve context - Avoid
try/catchwhere possible - Avoid using the
anytype - Prefer single word variable names where possible
- Use Bun APIs when possible, like
Bun.file() - Rely on type inference when possible; avoid explicit type annotations or interfaces unless necessary for exports or clarity
Avoid let statements
We don't like let statements, especially combined with if/else statements.
Prefer const.
Good:
const foo = condition ? 1 : 2
Bad:
let foo
if (condition) foo = 1
else foo = 2
Avoid else statements
Prefer early returns or using an iife to avoid else statements.
Good:
function foo() {
if (condition) return 1
return 2
}
Bad:
function foo() {
if (condition) return 1
else return 2
}
Prefer single word naming
Try your best to find a single word name for your variables, functions, etc. Only use multiple words if you cannot.
Good:
const foo = 1
const bar = 2
const baz = 3
Bad:
const fooBar = 1
const barBaz = 2
const bazFoo = 3
Testing
You MUST avoid using mocks as much as possible.
Tests MUST test actual implementation, do not duplicate logic into a test.