Prompt
Choose specific, descriptive names for variables, methods, types, and other identifiers that clearly communicate their purpose and behavior. Avoid generic names, unnecessary abbreviations, and assumptions about usage context.
Key principles:
- Method names should accurately reflect their behavior and scope (e.g.,
_allNativeContextsinstead of_allContextswhen the method only returns native contexts) - Use descriptive type names instead of generic ones (e.g.,
InstalledBrowserInfoinstead ofOptions) - Avoid abbreviations in favor of clarity (e.g.,
typedArrayConstructorsinstead oftypedArrayCtors) - Choose unique, specific names to prevent conflicts (e.g.,
alreadyRegisteredinstead offoo) - Don’t assume specific use cases in naming (e.g., avoid
getAllByAriaif it’s not exclusively for aria purposes)
Example:
// Avoid generic or abbreviated names
type Options = { ... }; // ❌ Too generic
const typedArrayCtors = { ... }; // ❌ Unnecessary abbreviation
// Use descriptive, specific names
type InstalledBrowserInfo = { ... }; // ✅ Clear purpose
const typedArrayConstructors = { ... }; // ✅ Full, clear name
// Method names should reflect actual behavior
_allContexts() { return this._browserTypes().flatMap(...); } // ❌ Misleading scope
_allNativeContexts() { return this._browserTypes().flatMap(...); } // ✅ Accurate scope
This approach improves code readability, reduces confusion, and makes the codebase more maintainable by ensuring identifiers clearly communicate their intended purpose.