bsc/.github/commitlint.config.js

45 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

2022-08-16 19:01:24 +08:00
const validateTypeNums = (parsedCommit) => {
2022-08-18 15:28:13 +08:00
const mergePrefix = "Merge pull request"
if (parsedCommit.raw.startsWith(mergePrefix)) {
console.log('this is a merge commit:' + parsedCommit.raw)
return [true,'']
}
2022-08-16 19:01:24 +08:00
if (!parsedCommit.type) {
2022-08-18 15:28:13 +08:00
return [false, 'invalid commit message, should be like "name: descriptions.", yours: "' + parsedCommit.raw + '"']
2022-08-16 19:01:24 +08:00
}
const types = parsedCommit.type.split(' ')
for (var i=0;i<types.length;i++){
if ((types[i].toLowerCase() == "wip") || (types[i].toLowerCase() == "r4r")) {
return [false, 'R4R or WIP is not acceptable, no matter upper case or lower case']
}
}
2022-08-18 15:28:13 +08:00
return [true,'']
2022-08-16 19:01:24 +08:00
}
module.exports = {
parserPreset: {
parserOpts: {
headerPattern: /^(.*):.*/,
2022-08-16 19:01:24 +08:00
}
},
extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
rules: {
'subject-empty':[2, 'always'],
'scope-empty':[2, 'always'],
'type-enum': [2, 'never'],
2022-08-17 15:19:50 +08:00
'type-case': [0, 'always'],
2022-08-16 19:01:24 +08:00
'function-rules/type-case': [2, 'always', validateTypeNums],
'header-max-length': [
2,
'always',
80,
2022-08-16 19:01:24 +08:00
],
},
helpUrl:
'https://github.com/bnb-chain/bsc/tree/develop/docs/lint/commit.md',
}