Back to all reviewers

Explicit code organization patterns

vercel/ai
Based on 4 comments
TypeScript

Maintain clear and explicit code organization patterns by following these guidelines: 1. Use explicit property visibility in classes: - Prefer public properties over getters/setters when no additional logic is needed

Code Style TypeScript

Reviewer Prompt

Maintain clear and explicit code organization patterns by following these guidelines:

  1. Use explicit property visibility in classes:
    • Prefer public properties over getters/setters when no additional logic is needed
    • Use private fields (#) for truly internal state
    • Only use protected when inheritance is a core design requirement
  2. Keep imports and exports explicit:
    • Avoid wildcard exports (export *)
    • Import directly from source files rather than barrel files
    • Control what gets exported from each module

Example:

// โŒ Avoid
export * from './utils';
import { something } from './index';

class MyClass {
  private messages: Message[];
  getMessages() { return this.messages; }
}

// โœ… Better
export { generateId, parseConfig } from './utils';
import { something } from './something';

class MyClass {
  #internalState: string;
  messages: Message[]; // public property when no special handling needed
}

This pattern improves code maintainability, makes dependencies clear, and helps control your public API surface.

4
Comments Analyzed
TypeScript
Primary Language
Code Style
Category

Source Discussions