forked from ONEARMY/community-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommitlint.format.ts
31 lines (28 loc) · 909 Bytes
/
commitlint.format.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 ''
}
module.exports = formatter
// Fix type definition for formattable report
interface IFormatReport extends FormattableReport {
errorCount: number
valid: boolean
warningCount: number
}