Files
onearmy-community-platform/commitlint.format.ts
Luke Watts d3bb4afe59 chore(deps): pin to skip latest release
(cherry picked from commit 950e9be9407995ddff136d8a406060332d5e1d4e)
2023-01-20 19:41:03 -08:00

30 lines
881 B
TypeScript

import type { Formatter, FormattableReport } from '@commitlint/types'
// Custom formatter for commitlint message
export const formatter: Formatter = function (report, options) {
const { results, valid } = report as IFormatReport
if (results && !valid) {
console.log('\nCommit needs to be formatted as conventional commit')
console.log('\n<type>[optional scope]: <description>\n')
for (const result of results) {
if (result.errors) {
for (const error of result.errors) {
console.log(result.input)
console.log('\x1b[31m%s\x1b[0m', '✖ ' + error.message)
}
}
}
}
console.log('\n')
console.log(options.helpUrl)
console.log('\n')
return ''
}
// Fix type definition for formattable report
interface IFormatReport extends FormattableReport {
errorCount: number
valid: boolean
warningCount: number
}