// Clear, self-documenting function namefn calculate_version_hash(version_id: &str) -> String { // Implementation}// Good use of doc comments/// Fetches a project from the database by its ID or slug.////// # Arguments/// * `id_or_slug` - The project ID or slug to search for////// # Returns/// Returns the project if found, or Nonepub async fn get_project(id_or_slug: &str) -> Option<Project> { // Implementation}
// Use explicit types for function parameters and return valuesfunction getUserById(id: string): Promise<User | null> { return client.labrinth.users_v2.get(id)}// Use const for values that don't changeconst MAX_UPLOAD_SIZE = 5242880 // 5MB// Prefer arrow functions for callbacksconst items = users.map((user) => user.name)// Use template literalsconst message = `User ${username} logged in at ${timestamp}`
DO NOT use “heading” comments like // === Helper methods ===Use doc comments for public APIs, but avoid inline comments unless absolutely necessary for clarity. Code should aim to be self-documenting!
/// Fetches all versions for a given project.////// # Arguments/// * `project_id` - The ID of the project/// * `loaders` - Optional filter for mod loaders////// # Returns/// A vector of version objects////// # Errors/// Returns an error if the database query failspub async fn get_project_versions( project_id: &str, loaders: Option<Vec<String>>,) -> Result<Vec<Version>, DatabaseError> { // Implementation}
feat: add version filtering to project searchfix: resolve authentication token expiration issuedocs: update API client usage examplesrefactor: simplify project query logicperf: optimize database query for project listtest: add unit tests for version validation
feat: add multi-loader support to version creationAllows users to specify multiple mod loaders (Forge, Fabric, Quilt)for a single version, reducing duplicate uploads.Closes #1234
# All frontend checks (includes formatting, linting, type checking)pnpm prepr# Or run specific checks:pnpm prepr:frontend:web # Website onlypnpm prepr:frontend:app # App onlypnpm prepr:frontend:lib # Shared libraries only
cd apps/labrinth# Run clippy (must have ZERO warnings)cargo clippy -p labrinth --all-targets# Prepare SQLx offline query cachecargo sqlx prepare# Format codecargo fmt
NEVER runcargo sqlx prepare --workspace - only run it from apps/labrinth/