Ensure consistent naming patterns and approaches across similar functionality in the codebase. This includes using named constants instead of magic strings, aligning input handling patterns with existing code, maintaining consistent identifier formats, and following established conventions from libraries or existing implementations.
Ensure consistent naming patterns and approaches across similar functionality in the codebase. This includes using named constants instead of magic strings, aligning input handling patterns with existing code, maintaining consistent identifier formats, and following established conventions from libraries or existing implementations.
Key practices:
const CLEAR_QUEUE_SIGNAL = '__CLEAR_QUEUE__'
instead of using the raw stringExample from the discussions:
// Before: Magic string
if (trimmedValue === '__CLEAR_QUEUE__') {
setQueuedInput(null);
return;
}
// After: Named constant
import { CLEAR_QUEUE_SIGNAL } from './constants.js';
if (trimmedValue === CLEAR_QUEUE_SIGNAL) {
setQueuedInput(null);
return;
}
This approach improves code maintainability, reduces errors from typos in magic strings, and makes the codebase more predictable for developers working across different modules.
Enter the URL of a public GitHub repository