Skip to content

Latest commit

History

History
71 lines (51 loc) · 1.08 KB

File metadata and controls

71 lines (51 loc) · 1.08 KB

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