Always use plural names for properties representing collections (arrays/lists) in interfaces, types, and destructuring patterns. This ensures consistency between interface definitions and their usage throughout the codebase.
Always use plural names for properties representing collections (arrays/lists) in interfaces, types, and destructuring patterns. This ensures consistency between interface definitions and their usage throughout the codebase.
Example:
// โ Inconsistent naming
interface DigestEmailProps {
newsletter?: EmailItem[]; // singular for array
receipt?: EmailItem[]; // singular for array
}
// โ
Consistent plural naming
interface DigestEmailProps {
newsletters?: EmailItem[]; // plural matches array type
receipts?: EmailItem[]; // plural matches array type
}
// Usage remains consistent with interface
const { newsletters, receipts } = props;
This convention:
Enter the URL of a public GitHub repository