Skip to content

Instantly share code, notes, and snippets.

@alexx855
Last active December 2, 2025 15:52
Show Gist options
  • Select an option

  • Save alexx855/ceb9f3a4761f62fb37f44c270451b461 to your computer and use it in GitHub Desktop.

Select an option

Save alexx855/ceb9f3a4761f62fb37f44c270451b461 to your computer and use it in GitHub Desktop.

Code Principles

TypeScript

  • Strict type inference only. No as assertions, no any, no ! non-null assertions
  • No type annotations when inference works. Let TS infer return types, variable types
  • Use satisfies over as when type validation needed
  • ES modules only. No require(), no dynamic import(), no conditional imports
  • Static imports at file top.

Architecture

  • KISS, DRY, single responsibility
  • Functions over classes unless state/lifecycle needed
  • Fail fast. No fallbacks, no retry mechanisms, no silent error swallowing
  • Explicit errors over defensive coding

React

  • Avoid useEffect. Prefer event handlers, derived state, or lifecycle methods

Naming

Element Convention Example
Files/Dirs kebab-case user-profile.ts
Classes PascalCase UserService
Functions camelCase, verb-first fetchUser, handleClick
Variables camelCase userData
Booleans is/has/can prefix isLoading, hasError
Constants UPPER_SNAKE MAX_RETRIES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment