Back to all reviewers

Centralize configuration values

supabase/supabase
Based on 3 comments
Typescript

Extract and centralize configuration values instead of duplicating or hardcoding them throughout the codebase. This improves maintainability by ensuring changes only need to be made in one place and enforces consistency across the application.

Configurations Typescript

Reviewer Prompt

Extract and centralize configuration values instead of duplicating or hardcoding them throughout the codebase. This improves maintainability by ensuring changes only need to be made in one place and enforces consistency across the application.

Best practices:

  • Use shared configuration objects for common settings (like query options)
  • Extract hardcoded values into named constants or environment variables
  • Create structured environment checks for environment-specific configurations

Example - Before:

// Hardcoded values in multiple files
Sentry.init({
  dsn: 'https://3c27c63b42048231340b7d640767ad02@o398706.ingest.us.sentry.io/4508132895096832',
})

// Duplicated configuration
{
  enabled: enabled && typeof projectRef !== 'undefined',
  refetchOnWindowFocus: false,
}

// Simple environment check
export const DEFAULT_PROVIDER: CloudProvider =
  process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod' ? 'AWS_K8S' : 'AWS'

Example - After:

// Constants file
export const SENTRY_DSN = process.env.SENTRY_DSN || 'https://3c27c63b42048231340b7d640767ad02@o398706.ingest.us.sentry.io/4508132895096832'

// Shared configuration object
export const UNIFIED_LOGS_QUERY_OPTIONS = {
  enabled: enabled && typeof projectRef !== 'undefined',
  refetchOnWindowFocus: false,
}

// Structured environment check
export const DEFAULT_PROVIDER: CloudProvider =
  process.env.NEXT_PUBLIC_ENVIRONMENT &&
  ['staging', 'preview'].includes(process.env.NEXT_PUBLIC_ENVIRONMENT)
    ? 'AWS_K8S'
    : 'AWS'
3
Comments Analyzed
Typescript
Primary Language
Configurations
Category

Source Discussions