commitlint

package
v0.144.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TypeAllowed

func TypeAllowed(t string, allowed []string) bool

TypeAllowed reports whether t is one of the allowed commit types (case-insensitive). Exported so callers that pin a type BEFORE composing a message (gk commit's classifier groups) can validate it up front instead of discovering the type-enum violation after the fact.

Types

type Footer struct {
	Token string // "BREAKING CHANGE" / "Signed-off-by" / "Refs"
	Value string
}

Footer is one trailer line, key: value.

type Issue

type Issue struct {
	Code    string // stable identifier like "type-empty", "type-enum", "subject-max-length"
	Message string
}

Issue is a single lint failure.

func Lint

func Lint(m Message, r Rules) []Issue

Lint runs rules against a parsed message. Returns []Issue (empty = clean).

type Message

type Message struct {
	Type        string   // "feat", "fix", ...
	Scope       string   // inside parens, may be ""
	Breaking    bool     // "!" marker or BREAKING CHANGE footer
	Subject     string   // the one-liner after the colon
	Body        string   // raw body (between subject+blank and footers), may be ""
	Footers     []Footer // trailers at the end
	Raw         string   // original input
	HeaderValid bool     // whether the first line parsed cleanly
}

Message is a parsed commit message in Conventional Commits form.

func Parse

func Parse(raw string) Message

Parse parses a raw commit message. Even on header failure it returns a Message with HeaderValid=false so callers can still report the raw input.

type Rules

type Rules struct {
	AllowedTypes     []string
	ScopeRequired    bool
	MaxSubjectLength int // 0 → no limit
}

Rules is the set of lint rules to apply.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL