or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

index.mddocs/

@commitlint/config-angular

@commitlint/config-angular is a shareable commitlint configuration that enforces the Angular commit convention for consistent commit message formatting. It provides comprehensive validation rules for commit message structure, type enforcement, and formatting constraints to maintain clean git history.

Package Information

  • Package Name: @commitlint/config-angular
  • Package Type: npm
  • Language: JavaScript (ESM)
  • Installation: npm install --save-dev @commitlint/config-angular @commitlint/cli

Core Imports

import config from "@commitlint/config-angular";

For CommonJS environments:

const config = require("@commitlint/config-angular");

Internal Implementation:

import typeEnum from "@commitlint/config-angular-type-enum";

export default {
  parserPreset: {
    parserOpts: { headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/ }
  },
  rules: {
    // ... other rules
    "type-enum": typeEnum.rules["type-enum"]
  }
};

Basic Usage

// commitlint.config.js
export default {
  extends: ['@commitlint/config-angular']
};

With package.json:

{
  "commitlint": {
    "extends": ["@commitlint/config-angular"]
  }
}

Capabilities

Configuration Object

The main export provides a complete commitlint configuration object for Angular commit convention enforcement.

/**
 * Default configuration object for Angular commit convention
 * Contains parser preset and validation rules
 */
const config = {
  parserPreset: {
    parserOpts: {
      headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/
    }
  },
  rules: {
    "subject-exclamation-mark": [2, "never"],
    "body-leading-blank": [1, "always"],
    "footer-leading-blank": [1, "always"],
    "header-max-length": [2, "always", 72],
    "scope-case": [2, "always", "lower-case"],
    "subject-case": [2, "never", ["sentence-case", "start-case", "pascal-case", "upper-case"]],
    "subject-empty": [2, "never"],
    "subject-full-stop": [2, "never", "."],
    "type-case": [2, "always", "lower-case"],
    "type-empty": [2, "never"],
    "type-enum": [2, "always", string[]]
  }
};

export default config;

Parser Preset

Configures commit message parsing for Angular convention format.

/**
 * Parser configuration for Angular commit messages
 * Supports format: type(scope): subject or type: subject
 */
const parserPreset = {
  parserOpts: {
    /** Pattern matching Angular commit format: type(scope): subject */
    headerPattern: /^(\w*)(?:\((.*)\))?!?: (.*)$/
  }
};

Supported Formats:

  • feat: add new feature
  • fix(auth): resolve login issue
  • docs(readme): update installation instructions

Validation Rules

Comprehensive set of rules enforcing Angular commit convention standards.

/**
 * Validation rules object with rule configurations
 * Each rule: [level, condition, value?]
 * level: 0 = disabled, 1 = warning, 2 = error
 * condition: 'always' | 'never'
 */
const rules = {
  // Error-level rules (level 2)
  "subject-exclamation-mark": [2, "never"],
  "header-max-length": [2, "always", 72],
  "scope-case": [2, "always", "lower-case"],
  "subject-case": [2, "never", ["sentence-case", "start-case", "pascal-case", "upper-case"]],
  "subject-empty": [2, "never"],
  "subject-full-stop": [2, "never", "."],
  "type-case": [2, "always", "lower-case"],
  "type-empty": [2, "never"],
  "type-enum": [2, "always", string[]],
  
  // Warning-level rules (level 1)
  "body-leading-blank": [1, "always"],
  "footer-leading-blank": [1, "always"]
};

Type Enumeration

The type enumeration is imported from @commitlint/config-angular-type-enum package dependency.

import typeEnum from "@commitlint/config-angular-type-enum";

/**
 * Type enum dependency providing allowed commit types
 * Contains rules object and value function
 */
const typeEnum = {
  rules: {
    "type-enum": [2, "always", string[]]
  },
  value: () => string[]
};

/**
 * Allowed commit types for Angular convention
 * Retrieved from @commitlint/config-angular-type-enum
 */
const allowedTypes = [
  "build",    // Build system changes
  "ci",       // CI configuration changes
  "docs",     // Documentation changes
  "feat",     // New features
  "fix",      // Bug fixes
  "perf",     // Performance improvements
  "refactor", // Code refactoring
  "revert",   // Reverts previous commits
  "style",    // Code style changes
  "test"      // Test additions/modifications
];

Rule Specifications

Error Rules (Level 2)

These rules will cause commits to fail:

subject-exclamation-mark

  • Condition: Never allow exclamation marks in subjects
  • Rationale: Angular convention doesn't use ! for breaking changes

header-max-length

  • Condition: Header must be ≤ 72 characters
  • Rationale: Maintains readability in git logs

scope-case

  • Condition: Scope must be lowercase
  • Examples: fix(auth) ✓, fix(Auth)

subject-case

  • Condition: Subject cannot be sentence-case, start-case, pascal-case, or upper-case
  • Examples: fix: add feature ✓, fix: Add Feature

subject-empty

  • Condition: Subject cannot be empty
  • Examples: fix: resolve bug ✓, fix:

subject-full-stop

  • Condition: Subject cannot end with period
  • Examples: fix: resolve issue ✓, fix: resolve issue.

type-case

  • Condition: Type must be lowercase
  • Examples: feat: new feature ✓, FEAT: new feature

type-empty

  • Condition: Type cannot be empty
  • Examples: feat: new feature ✓, : new feature

type-enum

  • Condition: Type must be one of allowed values from @commitlint/config-angular-type-enum
  • Implementation: typeEnum.rules["type-enum"] (imported from dependency)
  • Allowed: build, ci, docs, feat, fix, perf, refactor, revert, style, test

Warning Rules (Level 1)

These rules will show warnings but allow commits:

body-leading-blank

  • Condition: Body should start with blank line after header
  • Format:
    feat: add feature
    
    This is the body text.

footer-leading-blank

  • Condition: Footer should start with blank line before it
  • Format:
    feat: add feature
    
    Body text here.
    
    BREAKING CHANGE: details here

Usage Examples

// Valid commit messages
"feat: add user authentication"
"fix(auth): resolve token expiration issue"
"docs: update API documentation"
"test(utils): add unit tests for helpers"

// Invalid commit messages
"FEAT: add feature"              // type-case error
"feat: Add Feature"              // subject-case error
"feat: resolve issue."           // subject-full-stop error
"feat!: breaking change"         // subject-exclamation-mark error
"unknown: some change"           // type-enum error
"feat: this is a very long commit message that exceeds the maximum length limit" // header-max-length error

Dependencies

The configuration depends on @commitlint/config-angular-type-enum for type validation rules. This dependency is automatically resolved when the package is installed.

@commitlint/config-angular-type-enum API

/**
 * Type enum dependency providing Angular commit types
 * @see https://github.com/conventional-changelog/commitlint
 */
const typeEnum = {
  rules: {
    "type-enum": [2, "always", ["build", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test"]]
  },
  /** 
   * Function returning the array of allowed types
   * @returns {string[]} Array of allowed commit types
   */
  value: () => ["build", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test"]
};

export default typeEnum;

Integration

Typically used with:

  • @commitlint/cli - Command line interface
  • husky - Git hooks management
  • lint-staged - Run linters on staged files

Example integration:

{
  "scripts": {
    "prepare": "husky install"
  },
  "devDependencies": {
    "@commitlint/cli": "^19.0.0",
    "@commitlint/config-angular": "^19.0.0",
    "husky": "^8.0.0"
  }
}