Back to all reviewers

Use dynamic configuration access

discourse/discourse
Based on 4 comments
JavaScript

Always access configuration values through proper service APIs rather than hardcoding them or using unreliable access patterns. This ensures configuration remains maintainable and behaves consistently across different contexts.

Configurations JavaScript

Reviewer Prompt

Always access configuration values through proper service APIs rather than hardcoding them or using unreliable access patterns. This ensures configuration remains maintainable and behaves consistently across different contexts.

When accessing site settings or configuration values:

  • Use established service patterns like site service for configuration lookup
  • Avoid hardcoding configuration arrays or objects directly in code
  • Prefer reliable configuration access methods over workarounds

Example of proper configuration access:

// Instead of hardcoding:
const response = await ajax("/hashtags", {
  data: { slugs, order: ["category", "channel", "tag"] },
});

// Use service-based lookup:
const response = await ajax("/hashtags", {
  data: { slugs, order: this.site.hashtag_configurations.order },
});

This approach prevents issues where “the value was always false even when the site setting was true” and eliminates the need for temporary hardcoded values that developers “forgot to go back and replace.”

4
Comments Analyzed
JavaScript
Primary Language
Configurations
Category

Source Discussions