Skip to content

flex-development/commitlint-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

commitlint-config

npm codecov module type: cjs+esm license conventional commits typescript vitest yarn

Shareable commitlint config enforcing conventional commits

Contents

What is this?

This package exports a shareable commitlint configuration that enforces conventional commits.

It also includes a set of utilities for customizing rules.

When should I use this?

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.

Install

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.

Use

echo '{\n  "extends": "@flex-development"\n}' > .commitlintrc.json
commitlint --from HEAD~1 --to HEAD --verbose

Customizing scopes and types

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.

API

This package exports the following identifiers:

The default export is config.

config

commitlint configuration object.

Properties:

  • defaultIgnores
  • formatter
  • helpUrl
  • ignores
  • parserPreset
  • plugins
  • prompt
  • rules

See the configuration reference for more details.

Utilities

max(array)

Returns the length of the longest string in the given array.

Parameters
  • {string[]} array — Array to evaluate
Returns

{number} Length of longest string in array.

Source

src/utils/max.ts

min(array)

Returns the length of the shortest string in the given array.

Parameters
  • {string[]} array — Array to evaluate
Returns

{number} Length of shortest string in array.

Source

src/utils/min.ts

scopes([extras])

Returns an array containing valid commit scopes.

Parameters
  • {(Set<string> | string[])?} [extras=[]] — Additional commit scopes
Returns

{LiteralUnion<Scope, string>[]} Commit scopes array.

Source

src/utils/scopes.ts

types([extras])

Returns an array containing valid commit types.

Parameters
  • {(Set<string> | string[])?} [extras=[]] — Additional commit types
Returns

{LiteralUnion<Type, string>[]} Commit types array.

Source

src/utils/types.ts

Types

This package is fully typed with TypeScript.

Enums

Interfaces

Type Definitions

Contribute

See CONTRIBUTING.md.

Sponsor this project

 

Packages

 
 
 

Contributors 3

  •  
  •  
  •