Use precise, consistent, and descriptive naming conventions throughout your code to enhance readability and maintainability. This includes:
// ❌ Bad const normalizeMethod = options.method?.toUpperCase() ?? ‘’
2. Choose function names that clearly describe their purpose without ambiguity:
```javascript
// ✅ Good
function addHTTPMethod(method, { acceptBody = true } = {}) {
// Implementation
}
// ❌ Bad (confusing with HTTP Accept header)
function acceptHTTPMethod(method, { hasBody = false } = {}) {
// Implementation
}
// ❌ Bad - inconsistent terminology contentTypeSchemas[mediaName] = compile({ schema: contentSchema, method, url, httpPart: ‘body’ })
4. Name properties to clearly indicate their relationships:
```javascript
// ✅ Good - clear relationship between host and hostname
host: {
get() { return this.raw.headers.host || this.raw.headers[':authority'] }
},
hostname: {
get() { return this.host.split(':')[0] }
},
port: {
get() { return this.host.split(':')[1] }
}
These conventions improve code understandability and reduce cognitive load for developers working in the codebase.
Enter the URL of a public GitHub repository