2.2 KiB
title, description, repository, label, language, comments_count, repository_stars
| title | description | repository | label | language | comments_count | repository_stars |
|---|---|---|---|---|---|---|
| Follow consistent naming patterns | Maintain consistent naming conventions throughout the codebase to improve readability and reduce confusion. Adhere to these guidelines: 1. **Function naming patterns**: Use established prefixes like `create` for factory functions, which accurately conveys their purpose and aligns with existing patterns. | nodejs/node | Naming Conventions | Markdown | 5 | 112178 |
Maintain consistent naming conventions throughout the codebase to improve readability and reduce confusion. Adhere to these guidelines:
-
Function naming patterns: Use established prefixes like
createfor factory functions, which accurately conveys their purpose and aligns with existing patterns.// Preferred const counter = createCounter('api.calls', { service: 'web' }); const timer = createTimer('api.request.duration', { service: 'web' }); // Avoid const counter = counter('api.calls', { service: 'web' }); -
Method capitalization: Document instance methods with lowercase first letters, reserving capitalization for static methods.
// Preferred (instance method) blockList.fromJSON(value) // Avoid (incorrect capitalization for instance method) BlockList.fromJSON(value) -
Semantic specificity: Choose specific method names that prevent collisions and clearly communicate purpose. Avoid overly generic names like
use()when more descriptive alternatives likeuseEventListener()oraddDisposableEventListener()are clearer. -
Domain-consistent terminology: Use consistent terminology across related APIs. For example, if most of your file system API uses "file descriptor" or "fd", maintain that terminology throughout rather than using alternatives like "handle" for the same concept.
-
Documentation formatting: Follow established documentation patterns. Don't introduce formatting inconsistencies like prefixing types with "Type:" when the rest of the documentation uses a different convention.
Consistent naming makes codebases easier to learn, navigate, and maintain while reducing cognitive load for developers.