or run

npx @tessl/cli init
Log in

Version

Files

tile.json

task.mdevals/scenario-5/

Commit Configuration Validator

Build a tool that validates commit message configurations by reading commitlint rules and applying them to generate proper commit prompts.

Requirements

Your tool should read commitlint configuration files and use the rules to:

  1. Extract scope constraints: Read the scope-enum rule from commitlint configuration and make those scopes available for commit message generation
  2. Apply length limits: Extract header-max-length and subject-max-length rules and enforce these constraints
  3. Respect rule severity: Handle different rule severity levels (0=disable, 1=warning, 2=error) appropriately
  4. Generate valid commits: Produce commit messages that comply with the loaded commitlint rules

The tool should accept a commitlint configuration object and generate commit configuration options that enforce those rules.

Test Cases

  • When given a commitlint config with scope-enum rule containing ['api', 'ui', 'docs'], the generated options should include those exact scopes @test
  • When header-max-length is set to 72 in commitlint config with error severity (2), the generated options should enforce this limit @test
  • When a commitlint rule has severity level 0 (disabled), it should not affect the generated options @test
  • When subject-max-length is set to 50 with warning severity (1), the generated options should include this constraint @test

Implementation

@generates

API

/**
 * Commitlint rule configuration
 */
export interface CommitlintRule {
  severity: 0 | 1 | 2;  // 0 = disable, 1 = warning, 2 = error
  value: any;
}

/**
 * Commitlint configuration structure
 */
export interface CommitlintConfig {
  rules: {
    'scope-enum'?: [0 | 1 | 2, 'always' | 'never', string[]];
    'header-max-length'?: [0 | 1 | 2, 'always' | 'never', number];
    'subject-max-length'?: [0 | 1 | 2, 'always' | 'never', number];
    [key: string]: any;
  };
}

/**
 * Generated commit configuration options
 */
export interface CommitOptions {
  scopes?: string[];
  maxHeaderLength?: number;
  maxSubjectLength?: number;
}

/**
 * Processes commitlint configuration and extracts commit options
 * that can be used to generate conformant commit messages.
 *
 * @param config - The commitlint configuration object
 * @returns Commit options derived from the commitlint rules
 */
export function extractCommitOptions(config: CommitlintConfig): CommitOptions;

Dependencies { .dependencies }

czg { .dependency }

Provides standardized commit message generation with commitlint integration support.