Shareable commitlint
config enforcing conventional commits
- What is this?
- When should I use this?
- Install
- Use
- Rules
- Problems
body-full-stop
body-leading-blank
body-max-length
body-max-line-length
footer-leading-blank
footer-max-length
footer-max-line-length
header-full-stop
header-max-length
scope-case
scope-enum
scope-max-length
scope-min-length
subject-empty
subject-full-stop
subject-min-length
trailer-exists
type-case
type-empty
type-enum
type-max-length
type-min-length
- Problems
- API
config
defaultIgnores
formatter
helpUrl
ignores
max(array)
min(array)
parserPreset
plugins
prompt
rules
scopes([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/cli
From Git:
yarn add -D @flex-development/commitlint-config@flex-development/commitlint-config @commitlint/cli
See 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 --verbose
Due 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 config
You 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:
body
ends withvalue
-
rule:
never
-
value:
'.'
- condition:
body
begins with blank line - rule:
always
-
condition:
body
hasvalue
or less characters -
rule:
always
-
value:
Number.MAX_SAFE_INTEGER
-
condition:
body
lines hasvalue
or less characters -
rule:
always
-
value:
2050
- condition:
footer
begins with blank line - rule:
always
-
condition:
footer
hasvalue
or less characters -
rule:
always
-
value:
Number.MAX_SAFE_INTEGER
-
condition:
footer
lines hasvalue
or less characters -
rule:
always
-
value:
2050
-
condition:
header
ends withvalue
-
rule:
never
-
value:
'.'
-
condition:
header
hasvalue
or less characters -
rule:
always
-
value:
100
-
condition:
scope
is in case that is invalue
-
rule:
always
-
value:
['kebab-case', 'lower-case']
-
condition:
scope
is found invalue
-
rule:
always
-
value:
scopes()
-
condition:
scope
hasvalue
or less characters -
rule:
always
-
value:
max(scopes())
-
condition:
scope
hasvalue
or more characters -
rule:
always
-
value:
min(scopes())
- condition:
subject
is empty - rule:
never
-
condition:
subject
ends withvalue
-
rule:
never
-
value:
'.'
-
condition:
subject
hasvalue
or more characters -
rule:
always
-
value:
2
-
condition:
message
has trailervalue
-
rule:
always
-
value:
'Signed-off-by:'
-
description:
type
is in casevalue
-
rule:
always
-
value:
'lower-case'
- condition:
type
is empty - rule:
never
-
condition:
type
is found invalue
-
rule:
always
-
value:
types()
-
condition:
type
hasvalue
or less characters -
rule:
always
-
value:
max(types)
-
condition:
type
hasvalue
or more characters -
rule:
always
-
value:
min(types())
This package exports the following identifiers:
config
defaultIgnores
formatter
helpUrl
ignores
max
min
parserPreset
plugins
prompt
rules
scopes
types
The default export is config
.
commitlint
configuration object.
Properties:
defaultIgnores
formatter
helpUrl
ignores
parserPreset
plugins
prompt
rules
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
.