Skip to content

Latest commit

History

History
80 lines (57 loc) · 1.38 KB

File metadata and controls

80 lines (57 loc) · 1.38 KB
  • 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, use obj.a and obj.b to preserve context
  • Avoid try/catch where possible
  • Avoid using the any type
  • Prefer single word variable names where possible
  • Use Bun APIs when possible, like Bun.file()

Avoid let statements

We don't like let statements, especially combined with if/else statements. Prefer const.

Good:

constfoo=condition ? 1 : 2

Bad:

letfooif(condition)foo=1elsefoo=2

Avoid else statements

Prefer early returns or using an iife to avoid else statements.

Good:

functionfoo(){if(condition)return1return2}

Bad:

functionfoo(){if(condition)return1elsereturn2}

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:

constfoo=1constbar=2constbaz=3

Bad:

constfooBar=1constbarBaz=2constbazFoo=3

Testing

You MUST avoid using mocks as much as possible. Tests MUST test actual implementation, do not duplicate logic into a test.