danger-plugin-conventional-commitlint
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

danger-plugin-conventional-commitlint

CI npm version semantic-release code style: prettier

A danger plugin to lint commit messages with commitlint

Usage

Install:

npm install --save-dev danger-plugin-conventional-commitlint

At a glance:

// dangerfile.js
import commitlint from 'danger-plugin-conventional-commitlint';
import configConventional from '@commitlint/config-conventional';

(async function dangerReport() {
  const commitlintConfig = {
    severity: 'warn',
  };
  await commitlint(configConventional.rules, commitlintConfig);
})();

Note: you must provide your own rules to the function

API

commitlint([rules], [options])

Options

severity

Type: String
Choices: 'fail' | 'warn' | 'message'
Default: 'fail'
Danger method to call when the commit message does not pass the linter


messageReplacer

Type:

(ruleOutcome: LintOutcome, commitMessage: string) => string;

Default:

There is a problem with the commit message > [Commit message] - [Error Messages]

Method to add a custom message. When not passed, a default message is shown. Example:

const messageReplacer = (
  ruleOutcome: LintOutcome,
  commitMessage: string
): string => {
  const errorsDescription = ruleOutcome.errors
    .map((error) => `<li>${error.message}</li>`)
    .join('');

  return `<p>Commit message: <b>"${commitMessage}"</b></p><ul>${errorsDescription}</ul> Suffix after commit message`;
};

Changelog

See the GitHub release history.

Contributing

See CONTRIBUTING.md.

Package Sidebar

Install

npm i danger-plugin-conventional-commitlint

Weekly Downloads

2,225

Version

3.0.0

License

MIT

Unpacked Size

43.5 kB

Total Files

5

Last publish

Collaborators

  • bearalliance