Before implementing new functionality, check if similar utilities or patterns already exist in the codebase. Reuse existing code rather than duplicating logic, and organize shared types and constants in centralized locations to prevent circular dependencies and maintain consistency.
Before implementing new functionality, check if similar utilities or patterns already exist in the codebase. Reuse existing code rather than duplicating logic, and organize shared types and constants in centralized locations to prevent circular dependencies and maintain consistency.
Key practices:
isPrerelease utility in packages/nx/src/command-line/release/utils/shared.ts, let’s not duplicate the logic”)Example of good practice:
// Instead of creating multiple similar selectors
export function getMigrationType(ctx: AutomaticMigrationState, migrationId: string) {
return ctx.nxConsoleMetadata?.completedMigrations?.[migrationId]?.type;
}
// Then use it in components with comparison
const isSuccessful = getMigrationType(ctx, id) === 'successful';
const isFailed = getMigrationType(ctx, id) === 'failed';
This approach reduces code duplication, improves maintainability, and ensures consistent behavior across the codebase.
Enter the URL of a public GitHub repository