or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-commitlint--cz-commitlint

Commitizen adapter using the commitlint.config.js for consistent and interactive commit message prompting

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@commitlint/cz-commitlint@19.8.x

To install, run

npx @tessl/cli install tessl/npm-commitlint--cz-commitlint@19.8.0

index.mddocs/

@commitlint/cz-commitlint

@commitlint/cz-commitlint is a Commitizen adapter that integrates with commitlint configuration to provide an interactive commit message prompt system. It bridges the gap between Commitizen's interactive commit creation and commitlint's commit message validation by using a single commitlint.config.js configuration file for both tools.

Package Information

  • Package Name: @commitlint/cz-commitlint
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install --save-dev @commitlint/cz-commitlint commitizen inquirer@9

Core Imports

This package is designed as a Commitizen adapter and does not export functions for direct programmatic use. Instead, it is configured as a Commitizen adapter in your package.json:

{
  "config": {
    "commitizen": {
      "path": "@commitlint/cz-commitlint"
    }
  }
}

The package exports only one function for internal Commitizen integration:

import { prompter } from "@commitlint/cz-commitlint";

Basic Usage

After installation and configuration, use the adapter through Commitizen commands:

# After installation and configuration
npm run commit
# or
yarn commit
# or
git-cz

The adapter workflow:

  1. Loads your existing commitlint.config.js configuration
  2. Generates interactive prompts based on your commitlint rules
  3. Validates responses according to your rules
  4. Formats the final commit message

Architecture

The adapter is built around several key internal components:

  • Prompter Interface: Main entry point that integrates with Commitizen
  • Rule Processing: Converts commitlint rules into interactive questions
  • Section Handling: Manages commit message sections (header, body, footer)
  • Question System: Generates and validates interactive prompts
  • Configuration Store: Manages rules and prompt settings

Capabilities

Commitizen Integration

The main and only public entry point for Commitizen that orchestrates the entire interactive commit process.

/**
 * Entry point for commitizen - the only exported function
 * @param inquirerIns - Inquirer instance passed by commitizen (unused)
 * @param commit - Callback to execute with complete commit message
 */
function prompter(
  inquirerIns: {
    prompt(questions: DistinctQuestion[]): Promise<Answers>;
  },
  commit: (message: string) => void
): void;

This function is automatically called by Commitizen when configured as an adapter. It loads your commitlint configuration and generates interactive prompts based on your rules.

Types

/**
 * Inquirer answer type
 */
interface Answers {
  [key: string]: any;
}

/**
 * Inquirer question type
 */
interface DistinctQuestion {
  name?: string;
  type?: string;
  message?: string | Function;
  default?: any;
  choices?: any;
  validate?: Function;
  filter?: Function;
  transformer?: Function;
  when?: Function | boolean;
  pageSize?: number;
  prefix?: string;
  suffix?: string;
}

Configuration

The adapter is configured through your existing commitlint.config.js file. You can customize prompts by adding a prompt section:

module.exports = {
  extends: ['@commitlint/config-conventional'],
  prompt: {
    questions: {
      type: {
        description: 'Select the type of change that you are committing:',
        enum: {
          feat: {
            description: 'A new feature'
          },
          fix: {
            description: 'A bug fix'
          },
          docs: {
            description: 'Documentation only changes'
          },
          style: {
            description: 'Changes that do not affect the meaning of the code'
          },
          refactor: {
            description: 'A code change that neither fixes a bug nor adds a feature'
          },
          perf: {
            description: 'A code change that improves performance'
          },
          test: {
            description: 'Adding missing tests or correcting existing tests'
          },
          build: {
            description: 'Changes that affect the build system or external dependencies'
          },
          ci: {
            description: 'Changes to our CI configuration files and scripts'
          },
          chore: {
            description: 'Other changes that do not modify src or test files'
          },
          revert: {
            description: 'Reverts a previous commit'
          }
        }
      },
      scope: {
        description: 'What is the scope of this change (e.g. component or file name)'
      },
      subject: {
        description: 'Write a short, imperative tense description of the change'
      },
      body: {
        description: 'Provide a longer description of the change'
      },
      isBreaking: {
        description: 'Are there any breaking changes?'
      },
      breakingBody: {
        description: 'A BREAKING CHANGE commit requires a body. Please enter a longer description of the commit itself'
      },
      breaking: {
        description: 'Describe the breaking changes'
      },
      isIssueAffected: {
        description: 'Does this change affect any open issues?'
      },
      issuesBody: {
        description: 'If issues are closed, the commit requires a body. Please enter a longer description of the commit itself'
      },
      issues: {
        description: 'Add issue references (e.g. "fix #123", "re #123".)'
      }
    },
    messages: {
      skip: '(press enter to skip)',
      max: '(max %d chars)',
      min: '(min %d chars)',
      emptyWarning: '%s is required',
      upperLimitWarning: '%s over limit by %d chars',
      lowerLimitWarning: '%s under limit by %d chars'
    },
    settings: {
      enableMultipleScopes: false,
      scopeEnumSeparator: ','
    }
  }
};

Integration with commitlint Rules

The adapter automatically converts your commitlint rules into appropriate interactive questions:

  • type-enum: Creates a list selection for commit types
  • scope-enum: Creates scope selection (list or multiple)
  • subject-max-length: Enforces maximum subject length with validation
  • body-max-line-length: Applies line wrapping to body text
  • footer-max-line-length: Applies line wrapping to footer text
  • type-case: Applies case transformation to type field
  • scope-case: Applies case transformation to scope field
  • subject-case: Applies case transformation to subject field

The adapter ensures consistency between commit creation and validation by using the same configuration file for both processes.