javascript-practices

eser's avatarfrom eser

JS/TS conventions for syntax, modules, and types. Use when writing or reviewing JavaScript/TypeScript code.

⭐83stars🔀4forks📁View on GitHub🕐Updated Jan 1, 2026

When & Why to Use This Skill

This Claude skill provides a comprehensive set of JavaScript and TypeScript conventions designed to standardize syntax, module structures, and type safety. By enforcing best practices such as strict equality, explicit file extensions, and consistent async handling, it helps developers maintain high-quality, readable, and bug-resistant codebases. It is an essential tool for ensuring architectural consistency and modernizing JS/TS development workflows.

Use Cases

  • Automated Code Auditing: Use the skill during the peer review process to automatically identify deviations from established JS/TS conventions, ensuring every pull request meets team standards.
  • Standardizing Modern TypeScript Adoption: Apply these rules when migrating projects to TypeScript to enforce strict typing, proper module imports, and modern runtime behaviors like globalThis.
  • Refactoring and Technical Debt Reduction: Utilize the guidelines to systematically update legacy code, replacing outdated patterns (like 'var' or truthy checks on non-booleans) with safer, modern alternatives.
  • Developer Onboarding and Training: Serve as a live style guide for new engineers, providing immediate feedback on coding patterns to align their output with the project's technical requirements.
namejavascript-practices
descriptionJS/TS conventions for syntax, modules, and types. Use when writing or reviewing JavaScript/TypeScript code.

JavaScript/TypeScript Practices

Conventions for JS/TS syntax, modules, types, and runtime behavior.

Quick Start

import * as path from "@std/path"; // namespace import
import { utils } from "./utils.ts"; // explicit extension

export function buildConfig() {} // direct named export
const port = config.port ?? 8000; // nullish coalescing

Key Principles

Modules: Direct named exports, namespace imports, explicit .ts extensions

Syntax: const over let, always semicolons, === strict equality, ?? over ||

Types: Number() over +, instanceof over typeof, prefer null over undefined

Runtime: import.meta.dirname, globalThis over window, optional projectRoot params

Async: Use return await consistently for better stack traces and correct error handling

Avoid: eval, prototype mutation, truthy/falsy checks on non-booleans

References

See rules.md for complete guidelines with examples.