Rule

0 installs · 0 said it worked

PatrickJS@patrickjs·
CodingRule· for Cursor

TypeScript coding standards rules for consistent web code

A Cursor rules file that sets TypeScript best-practice standards for types, naming, organization, functions, error handling, and design patterns in modern web projects.

People use this for

  • typescript coding standards
  • typescript style guide cursor rules
  • strict typing rules for web
  • typescript naming conventions and types
  • help me enforce typescript best practices in my project
Name
typescript-coding-standards-rules-for-consistent-web-code
Works with
Cursor
License
CC0(as observed at the source)
Version
v1 · updated Nov 29, 2026
Imported · UnclaimedCC0

Imported on Nov 29, 2026 from github.com . License observed at the source on Nov 29, 2026: CC0.

Are you the author?Claim this profileRequest removal

Use this rule

$ curl -fsSL "https://promptcommunity.dev/api/v1/posts/typescript-coding-standards-rules-for-consistent-web-code-qkgf/export/mdc" -o .cursor/rules/typescript-coding-standards-rules-for-consistent-web-code.mdc

Then open a new session; Cursor picks it up from .cursor/rules/.

Download typescript-coding-standards-rules-for-consistent-web-code.mdc
Manual install

Save typescript-coding-standards-rules-for-consistent-web-code.mdc as .cursor/rules/typescript-coding-standards-rules-for-consistent-web-code.mdc for this project or ~/.cursor/rules/typescript-coding-standards-rules-for-consistent-web-code.mdc for every project, then start a new session.

Rule


description: "TypeScript coding standards and best practices for modern web development" globs: **/*.ts, **/*.tsx, **/*.d.ts alwaysApply: false

TypeScript Best Practices

Type System

  • Prefer interfaces over types for object definitions
  • Use type for unions, intersections, and mapped types
  • Avoid using any, prefer unknown for unknown types
  • Use strict TypeScript configuration
  • Leverage TypeScript's built-in utility types
  • Use generics for reusable type patterns

Naming Conventions

  • Use PascalCase for type names and interfaces
  • Use camelCase for variables and functions
  • Use UPPER_CASE for constants
  • Use descriptive names with auxiliary verbs (e.g., isLoading, hasError)
  • Prefix interfaces for React props with 'Props' (e.g., ButtonProps)

Code Organization

  • Keep type definitions close to where they're used
  • Export types and interfaces from dedicated type files when shared
  • Use barrel exports (index.ts) for organizing exports
  • Place shared types in a types directory
  • Co-locate component props with their components

Functions

  • Use explicit return types for public functions
  • Use arrow functions for callbacks and methods
  • Implement proper error handling with custom error types
  • Use function overloads for complex type scenarios
  • Prefer async/await over Promises

Best Practices

  • Enable strict mode in tsconfig.json
  • Use readonly for immutable properties
  • Leverage discriminated unions for type safety
  • Use type guards for runtime type checking
  • Implement proper null checking
  • Avoid type assertions unless necessary

Error Handling

  • Create custom error types for domain-specific errors
  • Use Result types for operations that can fail
  • Implement proper error boundaries
  • Use try-catch blocks with typed catch clauses
  • Handle Promise rejections properly

Patterns

  • Use the Builder pattern for complex object creation
  • Implement the Repository pattern for data access
  • Use the Factory pattern for object creation
  • Leverage dependency injection
  • Use the Module pattern for encapsulation

No result recorded yet. Added it? File a Tried-it report so the next person knows how it went in your editor.

Tried it

Reports from people who added this rule to their editor. They roll up into the badges above.

No one has filed a report yet. Try the prompt and be the first.

License: CC0v1 · published Nov 29, 2026

Comments

No comments yet. If you tried this prompt, say how it went.