When using the Axios library in TypeScript, it is important to follow consistent naming conventions to improve code readability and maintainability. Specifically:

  1. Use the “on” prefix for Axios event handlers and callbacks, such as onUploadProgress and onDownloadProgress.
  2. Use domain-specific prefixes like “response” to clarify the scope of Axios-related functionality, such as responseEncoding and responseType.
  3. Maintain consistent naming patterns for similar Axios-related functionality, such as using the same parameter structure for authentication-related properties.
  4. Align Axios-specific naming with established conventions in the TypeScript ecosystem, such as using camelCase for properties and methods.

Following these practices will help developers working on your Axios-based code understand the purpose and usage of your API more intuitively. Provide clear, well-named Axios-related functionality to improve the developer experience.

Example:

// ✅ Good - Clear event handler naming with "on" prefix
const config: AxiosRequestConfig = {
  onUploadProgress: (progressEvent: ProgressEvent) => { /* ... */ },
  onDownloadProgress: (progressEvent: ProgressEvent) => { /* ... */ }
}

// ❌ Bad - Unclear purpose of the function
const config: AxiosRequestConfig = {
  uploadProgress: (progressEvent: ProgressEvent) => { /* ... */ },
  downloadProgress: (progressEvent: ProgressEvent) => { /* ... */ }
}

// ✅ Good - Consistent parameter structure and clear scope
const config: AxiosRequestConfig = {
  responseEncoding: 'utf-8',
  proxy: {
    auth: { username: 'mikeymike', password: 'rapunz3l' } // Matches other auth patterns
  }
}