← ClaudeAtlas

stand-tslisted

TypeScript and JavaScript standards. Use when writing TS/JS code. Covers strict mode, type patterns, error handling, imports, naming, testing, React conventions, and package management with bun.
lgtm-hq/ai-skills · ★ 0 · AI & Automation · score 68
Install: claude install-skill lgtm-hq/ai-skills
# TypeScript / JavaScript Standards Standards for TypeScript and JavaScript code. ## Package Manager - Prefer `bun` over `npm` - Use `bun install` instead of `npm install` - Use `bun run` instead of `npm run` - Use `bunx` instead of `npx` ## Strict Mode - Enable `strict: true` in `tsconfig.json` - No `any` escape hatches without justification — if unavoidable, add a comment explaining why ## Type Patterns - Prefer `interface` for object shapes; use `type` for unions, intersections, and mapped types - Use `satisfies` over `as` for type narrowing — preserves the inferred type while validating the shape - Avoid `enum` — use `as const` objects instead: ```typescript // Good const Status = { Active: "active", Inactive: "inactive", } as const; type Status = (typeof Status)[keyof typeof Status]; // Avoid enum Status { Active = "active", Inactive = "inactive", } ``` - Prefer discriminated unions over optional fields for state modeling ## Error Handling - Use `unknown` in catch clauses, not `any`: ```typescript // Good catch (err: unknown) { if (err instanceof SpecificError) { ... } } // Bad catch (err: any) { ... } ``` - Never swallow errors with empty catch blocks - Prefer typed error results (`Result<T, E>` pattern) over thrown exceptions for expected failure paths ## Imports - Use type-only imports for types: `import type { Foo } from "./foo";` - Avoid barrel files (`index.ts` re-exports) in libraries — t