CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-commitlint--cli

Lint your commit messages with configurable rules and conventional commit support

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

configuration-presets.mddocs/

Configuration Presets

Pre-built rule configurations for popular commit conventions including conventional commits, Angular style, and workspace-specific scoping.

Capabilities

Conventional Commits Preset

Standard configuration following the Conventional Commits specification.

/**
 * @commitlint/config-conventional
 * Conventional commits preset with standard rules and type enforcement
 */
interface ConventionalConfig {
  extends: never;
  rules: {
    "body-leading-blank": [1, "always"];
    "body-max-line-length": [2, "always", 100];
    "footer-leading-blank": [1, "always"];
    "footer-max-line-length": [2, "always", 100];
    "header-max-length": [2, "always", 100];
    "header-trim": [2, "always"];
    "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[]];
  };
}

// Standard conventional commit types
const conventionalTypes = [
  "build",    // Changes that affect the build system or external dependencies
  "chore",    // Other changes that don't modify src or test files
  "ci",       // Changes to CI configuration files and scripts
  "docs",     // Documentation only changes
  "feat",     // A new feature
  "fix",      // A bug fix
  "perf",     // A code change that improves performance
  "refactor", // A code change that neither fixes a bug nor adds a feature
  "revert",   // Reverts a previous commit
  "style",    // Changes that do not affect the meaning of the code
  "test"      // Adding missing tests or correcting existing tests
];

Angular Commit Preset

Configuration following Angular's commit message conventions.

/**
 * @commitlint/config-angular
 * Angular commit message format with specific type enumeration
 */
interface AngularConfig {
  extends: never;
  rules: {
    "body-leading-blank": [1, "always"];
    "footer-leading-blank": [1, "always"];
    "header-max-length": [2, "always", 72];
    "header-trim": [2, "always"];
    "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[]];
  };
}

// Angular-specific commit types
const angularTypes = [
  "build", "ci", "docs", "feat", "fix", 
  "perf", "refactor", "style", "test"
];

Workspace Scope Presets

Configurations for monorepo and workspace-specific scope validation.

/**
 * @commitlint/config-lerna-scopes
 * Automatically derive scopes from Lerna packages
 */
interface LernaScopesConfig {
  extends: never;
  rules: {
    "scope-enum": [2, "always", string[]]; // Derived from lerna.json packages
  };
}

/**
 * @commitlint/config-nx-scopes
 * Automatically derive scopes from Nx workspace projects
 */
interface NxScopesConfig {
  extends: never;
  rules: {
    "scope-enum": [2, "always", string[]]; // Derived from workspace.json projects
  };
}

/**
 * @commitlint/config-pnpm-scopes
 * Automatically derive scopes from PNPM workspace packages
 */
interface PnpmScopesConfig {
  extends: never;
  rules: {
    "scope-enum": [2, "always", string[]]; // Derived from pnpm-workspace.yaml
  };
}

/**
 * @commitlint/config-rush-scopes
 * Automatically derive scopes from Rush monorepo projects
 */
interface RushScopesConfig {
  extends: never;
  rules: {
    "scope-enum": [2, "always", string[]]; // Derived from rush.json projects
  };
}

Type Enumeration Presets

Specialized presets focusing on type validation.

/**
 * @commitlint/config-angular-type-enum
 * Angular-specific type enumeration only
 */
interface AngularTypeEnumConfig {
  extends: never;
  rules: {
    "type-enum": [2, "always", [
      "build", "ci", "docs", "feat", "fix", 
      "perf", "refactor", "style", "test"
    ]];
  };
}

Pattern-specific Presets

Configurations for specific project patterns and tools.

/**
 * @commitlint/config-patternplate
 * Configuration for Patternplate projects
 */
interface PatternplateConfig {
  extends: never;
  rules: {
    // Patternplate-specific rules
    "type-enum": [2, "always", string[]]; // Custom type enumeration
  };
}

Preset Usage Examples

Basic Conventional Commits

// commitlint.config.js
module.exports = {
  extends: ["@commitlint/config-conventional"]
};

// This enables:
// - Standard conventional commit types
// - 100 character header limit
// - Subject case restrictions
// - Body and footer formatting rules

Angular Style Commits

// commitlint.config.js
module.exports = {
  extends: ["@commitlint/config-angular"]
};

// This enables:
// - Angular commit types
// - 72 character header limit (stricter)
// - Lowercase scope requirement
// - Angular-specific formatting

Monorepo with Lerna

// commitlint.config.js
module.exports = {
  extends: [
    "@commitlint/config-conventional",
    "@commitlint/config-lerna-scopes"
  ]
};

// This combines conventional commits with automatic scope detection
// Scopes are derived from packages defined in lerna.json

Nx Workspace

// commitlint.config.js
module.exports = {
  extends: [
    "@commitlint/config-conventional",
    "@commitlint/config-nx-scopes"
  ]
};

// Scopes automatically detected from Nx workspace projects
// Example valid: "feat(ui-components): add button component"

Custom Extension

// commitlint.config.js
module.exports = {
  extends: ["@commitlint/config-conventional"],
  rules: {
    // Override preset rules
    "header-max-length": [2, "always", 120], // Increase from 100
    "body-max-line-length": [2, "always", 120], // Increase from 100
    
    // Add custom rules
    "scope-enum": [2, "always", [
      "api", "ui", "core", "docs", "build", "ci"
    ]],
    "scope-empty": [2, "never"], // Require scope (overrides preset)
    
    // Custom type additions
    "type-enum": [2, "always", [
      // Include all conventional types
      "build", "chore", "ci", "docs", "feat", 
      "fix", "perf", "refactor", "revert", "style", "test",
      // Add custom types
      "wip", "hotfix"
    ]]
  }
};

Multi-preset Configuration

// commitlint.config.js
module.exports = {
  extends: [
    "@commitlint/config-conventional", // Base rules
    "@commitlint/config-lerna-scopes"  // Scope detection
  ],
  rules: {
    // Additional customizations
    "subject-case": [2, "always", ["lower-case", "kebab-case"]],
    "references-empty": [1, "never"], // Warn if no issue references
    
    // Workspace-specific rules
    "footer-max-line-length": [2, "always", 120],
    "body-max-line-length": [2, "always", 120]
  }
};

PNPM Workspace

// commitlint.config.js  
module.exports = {
  extends: [
    "@commitlint/config-conventional",
    "@commitlint/config-pnpm-scopes"
  ],
  rules: {
    // Require scope in workspace
    "scope-empty": [2, "never"],
    
    // Custom type for workspace management
    "type-enum": [2, "always", [
      "build", "chore", "ci", "docs", "feat", 
      "fix", "perf", "refactor", "revert", "style", "test",
      "workspace" // For workspace-level changes
    ]]
  }
};

Rush Monorepo

// commitlint.config.js
module.exports = {
  extends: [
    "@commitlint/config-conventional",
    "@commitlint/config-rush-scopes"
  ],
  rules: {
    // Rush-specific customizations
    "scope-case": [2, "always", "kebab-case"],
    "header-max-length": [2, "always", 80], // Shorter headers
    
    // Require references to work items
    "references-empty": [2, "never"]
  }
};

Preset Comparison

Feature Matrix

interface PresetComparison {
  preset: string;
  headerMaxLength: number;
  scopeRequired: boolean;
  typeEnumeration: string[];
  scopeDetection: "manual" | "automatic" | "none";
  bodyFormatting: boolean;
  footerFormatting: boolean;
}

const presetComparison: PresetComparison[] = [
  {
    preset: "@commitlint/config-conventional",
    headerMaxLength: 100,
    scopeRequired: false,
    typeEnumeration: ["build", "chore", "ci", "docs", "feat", "fix", "perf", "refactor", "revert", "style", "test"],
    scopeDetection: "none",
    bodyFormatting: true,
    footerFormatting: true
  },
  {
    preset: "@commitlint/config-angular",
    headerMaxLength: 72,
    scopeRequired: false,
    typeEnumeration: ["build", "ci", "docs", "feat", "fix", "perf", "refactor", "style", "test"],
    scopeDetection: "none",
    bodyFormatting: true,
    footerFormatting: true
  },
  {
    preset: "@commitlint/config-lerna-scopes",
    headerMaxLength: 0, // No header length rule
    scopeRequired: true,
    typeEnumeration: [],
    scopeDetection: "automatic",
    bodyFormatting: false,
    footerFormatting: false
  }
];

Installation Commands

# Conventional commits
npm install --save-dev @commitlint/config-conventional

# Angular style  
npm install --save-dev @commitlint/config-angular

# Lerna scopes
npm install --save-dev @commitlint/config-lerna-scopes

# Nx scopes
npm install --save-dev @commitlint/config-nx-scopes

# PNPM workspace scopes
npm install --save-dev @commitlint/config-pnpm-scopes

# Rush scopes
npm install --save-dev @commitlint/config-rush-scopes

# Multiple presets
npm install --save-dev \
  @commitlint/config-conventional \
  @commitlint/config-lerna-scopes

Preset Validation Examples

import { load } from "@commitlint/load";

// Load conventional preset
const conventionalConfig = await load({
  extends: ["@commitlint/config-conventional"]
});

// Load Angular preset  
const angularConfig = await load({
  extends: ["@commitlint/config-angular"]
});

// Load combined presets
const combinedConfig = await load({
  extends: [
    "@commitlint/config-conventional",
    "@commitlint/config-lerna-scopes"
  ]
});

docs

built-in-rules.md

cli-interface.md

commit-reading.md

configuration-presets.md

configuration-system.md

index.md

linting-engine.md

output-formatting.md

tile.json