mirror of
https://github.com/wagoid/commitlint-github-action.git
synced 2025-11-08 00:16:56 +00:00
40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
/* eslint-disable import/no-extraneous-dependencies */
|
||
const { maxLineLength } = require('@commitlint/ensure')
|
||
|
||
const bodyMaxLineLength = 100
|
||
|
||
const validateBodyMaxLengthIgnoringDeps = (parsedCommit) => {
|
||
const { type, scope, body } = parsedCommit
|
||
const isDepsCommit =
|
||
type === 'chore' && (scope === 'deps' || scope === 'deps-dev')
|
||
|
||
return [
|
||
isDepsCommit || !body || maxLineLength(body, bodyMaxLineLength),
|
||
`body's lines must not be longer than ${bodyMaxLineLength}`,
|
||
]
|
||
}
|
||
|
||
module.exports = {
|
||
extends: ['@commitlint/config-conventional'],
|
||
plugins: ['commitlint-plugin-function-rules'],
|
||
rules: {
|
||
'body-max-line-length': [0],
|
||
'function-rules/body-max-line-length': [
|
||
2,
|
||
'always',
|
||
validateBodyMaxLengthIgnoringDeps,
|
||
],
|
||
'function-rules/body-jira-id-check': [
|
||
2, // level: error
|
||
'always',
|
||
(parsed) => {
|
||
const jiraRegex = parsed.body.match(/[A-Z]+[-\d]+/g);
|
||
const jiraIgnoreRegex = parsed.body.match(/I don’t have a ticket for this/g);
|
||
if ( jiraRegex != null || jiraIgnoreRegex != null) {
|
||
return [true];
|
||
}
|
||
return [false, 'The body doesnot have Jira ID OR ignore quote'];
|
||
},
|
||
],
|
||
},
|
||
}
|