Shareable commitlint config enforcing conventional commits
- What is this?
- When should I use this?
- Install
- Use
- Rules
- Problems
body-full-stopbody-leading-blankbody-max-lengthbody-max-line-lengthfooter-leading-blankfooter-max-lengthfooter-max-line-lengthheader-full-stopheader-max-lengthscope-casescope-enumscope-max-lengthscope-min-lengthsubject-emptysubject-full-stopsubject-min-lengthtrailer-existstype-casetype-emptytype-enumtype-max-lengthtype-min-length
- Problems
- API
configdefaultIgnoresformatterhelpUrlignoresmax(array)min(array)parserPresetpluginspromptrulesscopes([extras])types([extras])
- Types
- Contribute
This package exports a shareable commitlint configuration that enforces conventional commits.
It also includes a set of utilities for customizing rules.
This package can be used with @commitlint/cli and @commitlint/prompt-cli.
Commit parsing options can also be used with conventional-changelog and conventional-commits-parser.
yarn add -D @flex-development/commitlint-config @commitlint/cliFrom Git:
yarn add -D @flex-development/commitlint-config@flex-development/commitlint-config @commitlint/cliSee Git - Protocols | Yarn for details on requesting a specific branch, commit, or tag.
echo '{\n "extends": "@flex-development"\n}' > .commitlintrc.json
commitlint --from HEAD~1 --to HEAD --verboseDue to an unresolved commitlint issue, extended commitlint configurations do not concatenate scope-enum,
nor type-enum. Follow the example below to customize commit scopes and types losslessly.
touch .commitlintrc.cts/**
* @file Configuration - commitlint
* @module config/commitlint
* @see https://commitlint.js.org
*/
import {
RuleConfigSeverity as Severity,
type UserConfig
} from '@commitlint/types'
import { scopes } from '@flex-development/commitlint-config'
/**
* `commitlint` configuration object.
*
* @const {UserConfig} config
*/
const config: UserConfig = {
extends: ['@flex-development'],
rules: {
'scope-enum': [Severity.Error, 'always', scopes(['bundle', 'transpile'])]
}
}
export default configYou may need to set TS_NODE_PROJECT if running commitlint from the command line.
See docs/examples/commitlint.config.cjs for an example config written in pure CommonJS.
Rules not documented below are disabled by default. Consult the rules reference for a list of all rules.
The following rules are considered problems for @flex-development/commitlint-config and will yield a non-zero exit
code when not met.
-
condition:
bodyends withvalue -
rule:
never -
value:
'.'
- condition:
bodybegins with blank line - rule:
always
-
condition:
bodyhasvalueor less characters -
rule:
always -
value:
Number.MAX_SAFE_INTEGER
-
condition:
bodylines hasvalueor less characters -
rule:
always -
value:
2050
- condition:
footerbegins with blank line - rule:
always
-
condition:
footerhasvalueor less characters -
rule:
always -
value:
Number.MAX_SAFE_INTEGER
-
condition:
footerlines hasvalueor less characters -
rule:
always -
value:
2050
-
condition:
headerends withvalue -
rule:
never -
value:
'.'
-
condition:
headerhasvalueor less characters -
rule:
always -
value:
100
-
condition:
scopeis in case that is invalue -
rule:
always -
value:
['kebab-case', 'lower-case']
-
condition:
scopeis found invalue -
rule:
always -
value:
scopes()
-
condition:
scopehasvalueor less characters -
rule:
always -
value:
max(scopes())
-
condition:
scopehasvalueor more characters -
rule:
always -
value:
min(scopes())
- condition:
subjectis empty - rule:
never
-
condition:
subjectends withvalue -
rule:
never -
value:
'.'
-
condition:
subjecthasvalueor more characters -
rule:
always -
value:
2
-
condition:
messagehas trailervalue -
rule:
always -
value:
'Signed-off-by:'
-
description:
typeis in casevalue -
rule:
always -
value:
'lower-case'
- condition:
typeis empty - rule:
never
-
condition:
typeis found invalue -
rule:
always -
value:
types()
-
condition:
typehasvalueor less characters -
rule:
always -
value:
max(types)
-
condition:
typehasvalueor more characters -
rule:
always -
value:
min(types())
This package exports the following identifiers:
configdefaultIgnoresformatterhelpUrlignoresmaxminparserPresetpluginspromptrulesscopestypes
The default export is config.
commitlint configuration object.
Properties:
defaultIgnoresformatterhelpUrlignoresparserPresetpluginspromptrules
See the configuration reference for more details.
Returns the length of the longest string in the given array.
{string[]}array— Array to evaluate
{number} Length of longest string in array.
Returns the length of the shortest string in the given array.
{string[]}array— Array to evaluate
{number} Length of shortest string in array.
Returns an array containing valid commit scopes.
{(Set<string> | string[])?}[extras=[]]— Additional commit scopes
{LiteralUnion<Scope, string>[]} Commit scopes array.
Returns an array containing valid commit types.
{(Set<string> | string[])?}[extras=[]]— Additional commit types
{LiteralUnion<Type, string>[]} Commit types array.
This package is fully typed with TypeScript.
See CONTRIBUTING.md.