Back to all reviewers

Choose descriptive, unambiguous names

langgenius/dify
Based on 3 comments
TypeScript

Select variable, method, and property names that clearly communicate their purpose and avoid ambiguity. Prioritize semantic accuracy over brevity, and consider the context in which names will be used to prevent confusion.

Naming Conventions TypeScript

Reviewer Prompt

Select variable, method, and property names that clearly communicate their purpose and avoid ambiguity. Prioritize semantic accuracy over brevity, and consider the context in which names will be used to prevent confusion.

Key principles:

  • Use semantically accurate names that reflect the actual purpose (e.g., affectedNodes instead of effectNodes when referring to nodes that are affected by an operation)
  • Avoid naming conflicts by choosing distinct terms when similar concepts coexist (e.g., use inputs instead of variables when a variable property already exists)
  • Replace magic strings with enums or constants for better type safety and self-documentation

Example:

// Poor: ambiguous and uses magic strings
const effectNodes = findNodes(selector, nodes)
if (permission === 'only_me') { ... }

// Better: clear semantic meaning and structured types
const affectedNodes = findNodes(selector, nodes)
if (permission === DatasetPermission.ONLY_ME) { ... }

This approach reduces cognitive load, prevents misunderstandings, and makes code more maintainable by ensuring names accurately represent their underlying concepts.

3
Comments Analyzed
TypeScript
Primary Language
Naming Conventions
Category

Source Discussions