Prompt
Ensure consistent application of coding style conventions throughout the codebase, including naming patterns, type usage, code organization, and formatting standards.
Key areas to maintain consistency:
Naming Conventions:
- Use consistent casing for constants (e.g.,
STACKOVERFLOWnotStackOverflow) - Remove underscore prefixes from private members as per current standards
- Apply
readonlymodifier consistently to input signals and computed values
Type Usage:
- Prefer
unknownoveranyfor better type safety - Use consistent patterns for optional chaining and type assertions
Code Organization:
- Place documentation comments before decorators consistently
- Extract repeated constants to the top of files or shared utilities
- Use
async/awaitsyntax consistently instead ofPromise.resolve()
Example of consistent readonly usage:
// Consistent - all inputs marked as readonly
readonly docContent = input<DocContent | undefined>();
readonly urlFragment = toSignal(this.route.fragment);
readonly hasClosed = linkedSignal(() => { ... });
// Inconsistent - missing readonly modifiers
docContent = input<DocContent | undefined>();
urlFragment = toSignal(this.route.fragment);
Example of consistent constant extraction:
// Good - constants extracted and consistently named
const MAX_DISPLAY_LENGTH = 200;
const COPY_FEEDBACK_TIMEOUT = 2000;
const STACKOVERFLOW = 'https://stackoverflow.com/questions/tagged/angular';
// Avoid - magic numbers and inconsistent naming
setTimeout(() => { ... }, 2000);
export const StackOverflow = 'https://stackoverflow.com/questions/tagged/angular';
Consistency in style reduces cognitive load, improves maintainability, and makes the codebase more professional. Establish team conventions and apply them uniformly across all files.