Conventional Changelog ESLint is a preset for the conventional-changelog system that provides standardized commit message parsing and changelog generation following ESLint's commit conventions. It enables automatic changelog generation for projects that follow ESLint's structured commit message format with specific tags and formatting rules.
npm install conventional-changelog-eslintimport createPreset from "conventional-changelog-eslint";
// Named exports also available
import { createParserOpts, createWriterOpts, whatBump } from "conventional-changelog-eslint";For CommonJS environments (though the package is ESM-only):
const createPreset = require("conventional-changelog-eslint").default;
const { createParserOpts, createWriterOpts, whatBump } = require("conventional-changelog-eslint");import conventionalChangelogCore from "conventional-changelog-core";
import createPreset from "conventional-changelog-eslint";
// Generate changelog using the ESLint preset
const preset = await createPreset();
for await (const chunk of conventionalChangelogCore({
config: preset
})) {
console.log(chunk.toString());
}The preset follows ESLint's specific commit message format:
Tag: Short description (fixes #1234)
Longer description here if necessaryCreates a complete preset configuration with parser, writer, and version bump logic.
/**
* Creates a preset configuration for conventional-changelog (default export)
* @returns Promise resolving to preset configuration object
*/
export default function createPreset(): Promise<PresetConfig>;
/**
* Create parser options for ESLint commit format
* @returns Parser configuration object
*/
export function createParserOpts(): ParserOptions;
/**
* Create writer options with templates for changelog generation
* @returns Promise resolving to writer configuration object
*/
export function createWriterOpts(): Promise<WriterOptions>;
/**
* Determine version bump level based on commit tags
* @param commits - Array of parsed commit objects
* @returns Bump result with level and reason
*/
export function whatBump(commits: CommitObject[]): BumpResult;
interface PresetConfig {
/** Parser options for commit message parsing */
parser: ParserOptions;
/** Writer options for changelog generation */
writer: WriterOptions;
/** Version bump logic function */
whatBump: (commits: CommitObject[]) => BumpResult;
}The preset's parser configuration handles ESLint's commit message format.
interface ParserOptions {
/** Regex pattern to parse ESLint commit format: /^(\w*):\s*(.*)$/ */
headerPattern: RegExp;
/** Maps regex groups to commit properties: ['tag', 'message'] */
headerCorrespondence: string[];
}The preset's writer configuration includes templates and formatting rules for changelog generation.
interface WriterOptions {
/** Main changelog template */
mainTemplate: string;
/** Header template for version sections */
headerPartial: string;
/** Commit entry template */
commitPartial: string;
/** Transform function for commit objects */
transform: (commit: CommitObject) => TransformedCommit | undefined;
/** Groups commits by this property */
groupBy: string;
/** Sort order for commit groups */
commitGroupsSort: string;
/** Sort order for commits within groups */
commitsSort: string[];
}
interface CommitObject {
/** ESLint commit tag (Fix, Update, New, etc.) */
tag?: string;
/** Commit message content */
message?: string;
/** Git commit hash */
hash: string;
/** Commit header line */
header?: string;
/** Issue references */
references?: Reference[];
}
interface TransformedCommit {
/** Shortened commit hash (7 characters) */
shortHash: string;
/** ESLint commit tag (transformed from original) */
tag?: string;
/** Commit message content (transformed from original) */
message?: string;
/** Git commit hash (original) */
hash?: string;
/** Commit header line (original) */
header?: string;
/** Issue references (original) */
references?: Reference[];
}
interface Reference {
/** Issue number */
issue: string;
/** Repository owner */
owner?: string;
/** Repository name */
repository?: string;
}The preset includes version bump logic that determines semantic version level based on commit tags.
interface BumpResult {
/** Bump level: 0 (major), 1 (minor), 2 (patch) */
level: number;
/** Human-readable reason for the bump decision */
reason: string;
}Bump Logic Rules:
Direct access to individual configuration functions is available via named exports.
Creates parser configuration for ESLint commit format parsing.
/**
* Create parser options for ESLint commit format
* @returns Parser configuration object with header pattern and correspondence
*/
function createParserOpts(): ParserOptions;Usage Example:
import { createParserOpts } from "conventional-changelog-eslint";
const parserOpts = createParserOpts();
// Returns: { headerPattern: /^(\w*):\s*(.*)$/, headerCorrespondence: ['tag', 'message'] }Creates writer configuration with Handlebars templates loaded from files.
/**
* Create writer options with templates for changelog generation
* @returns Promise resolving to writer configuration object with templates loaded
*/
function createWriterOpts(): Promise<WriterOptions>;Usage Example:
import { createWriterOpts } from "conventional-changelog-eslint";
const writerOpts = await createWriterOpts();
// Returns writer configuration with loaded templates and transform functionDirect access to the version bump determination logic.
/**
* Determine version bump level based on commit tags
* @param commits - Array of parsed commit objects with tag property
* @returns Bump result with level (0=major, 1=minor, 2=patch) and reason
*/
function whatBump(commits: CommitObject[]): BumpResult;Usage Example:
import { whatBump } from "conventional-changelog-eslint";
const commits = [
{ tag: 'Breaking', message: 'remove deprecated API' },
{ tag: 'New', message: 'add feature X' }
];
const result = whatBump(commits);
// Returns: { level: 0, reason: 'There are 1 breaking changes and 1 features' }The preset includes Handlebars templates for changelog formatting:
Structures the overall changelog with version headers and commit groups.
Structures the overall changelog:
{{> header}}
{{#each commitGroups}}
{{#if title}}
### {{title}}
{{/if}}
{{#each commits}}
{{> commit root=@root}}
{{/each}}
{{/each}}Formats version headers with links and dates:
{{#if isPatch}}##{{else}}#{{/if}} {{#if @root.linkCompare}}[{{version}}]({{@root.host}}/{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/compare/{{previousTag}}...{{currentTag}}){{else}}{{version}}{{/if}}{{#if title}} "{{title}}"{{/if}}{{#if date}} ({{date}}){{/if}}Formats individual commit entries with hash links and issue references:
* {{#if message}}{{message}}{{else}}{{header}}{{/if}}
{{~!-- commit hash --}} {{#if @root.linkReferences}}([{{shortHash}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}/{{@root.commit}}/{{hash}})){{else}}{{hash~}}{{/if}}
{{~!-- commit references --}}{{#if references}}, closes{{~#each references}} {{#if @root.linkReferences}}[{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}]({{#if @root.host}}{{@root.host}}/{{/if}}{{#if this.repository}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}{{else}}{{#if @root.owner}}{{@root.owner}}/{{/if}}{{@root.repository}}{{/if}}/{{@root.issue}}/{{this.issue}}){{else}}{{#if this.owner}}{{this.owner}}/{{/if}}{{this.repository}}#{{this.issue}}{{/if}}{{/each}}{{/if}}This preset is designed to work with:
Integration Example:
import conventionalChangelogCore from "conventional-changelog-core";
import createPreset from "conventional-changelog-eslint";
const preset = await createPreset();
// Generate changelog for current version
const changelogStream = conventionalChangelogCore({
config: preset,
releaseCount: 1
});
let changelog = "";
for await (const chunk of changelogStream) {
changelog += chunk.toString();
}
console.log(changelog);