diff options
| author | Dax Raad <[email protected]> | 2026-01-11 18:53:34 -0500 |
|---|---|---|
| committer | Dax Raad <[email protected]> | 2026-01-11 18:53:39 -0500 |
| commit | 3a30773874ccb92d085eddbab66d053c5d4e6326 (patch) | |
| tree | b7831e670aa80bd1ea4cffb29b39dee85e24207d /STYLE_GUIDE.md | |
| parent | 0c0057a7deb8cde8df90e1899f39d42c6b9837ac (diff) | |
| download | opencode-3a30773874ccb92d085eddbab66d053c5d4e6326.tar.gz opencode-3a30773874ccb92d085eddbab66d053c5d4e6326.zip | |
tui: refactor event streaming to use SDK instead of manual RPC subscription
Diffstat (limited to 'STYLE_GUIDE.md')
| -rw-r--r-- | STYLE_GUIDE.md | 67 |
1 files changed, 65 insertions, 2 deletions
diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md index 8dd3be589..a46ce221f 100644 --- a/STYLE_GUIDE.md +++ b/STYLE_GUIDE.md @@ -4,8 +4,71 @@ - AVOID unnecessary destructuring of variables. instead of doing `const { a, b } = obj` just reference it as obj.a and obj.b. this preserves context - AVOID `try`/`catch` where possible -- AVOID `else` statements - AVOID using `any` type -- AVOID `let` statements - PREFER single word variable names where possible - Use as many bun apis as possible like Bun.file() + +# Avoid let statements + +we don't like let statements, especially combined with if/else statements. +prefer const + +This is bad: + +Good: + +```ts +const foo = condition ? 1 : 2 +``` + +Bad: + +```ts +let foo + +if (condition) foo = 1 +else foo = 2 +``` + +# Avoid else statements + +Prefer early returns or even using `iife` to avoid else statements + +Good: + +```ts +function foo() { + if (condition) return 1 + return 2 +} +``` + +Bad: + +```ts +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: + +```ts +const foo = 1 +const bar = 2 +const baz = 3 +``` + +Bad: + +```ts +const fooBar = 1 +const barBaz = 2 +const bazFoo = 3 +``` |
