bsc/.github/commitlint.config.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2022-08-16 14:01:24 +03:00
const validateTypeNums = (parsedCommit) => {
2022-08-18 10:28:13 +03: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 14:01:24 +03:00
if (!parsedCommit.type) {
2022-08-18 10:28:13 +03:00
return [false, 'invalid commit message, should be like "name: descriptions.", yours: "' + parsedCommit.raw + '"']
2022-08-16 14:01:24 +03: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 10:28:13 +03:00
return [true,'']
2022-08-16 14:01:24 +03:00
}
module.exports = {
parserPreset: {
parserOpts: {
headerPattern: /^(.*):.*/,
2022-08-16 14:01:24 +03: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 10:19:50 +03:00
'type-case': [0, 'always'],
2022-08-16 14:01:24 +03:00
'function-rules/type-case': [2, 'always', validateTypeNums],
'header-max-length': [
2,
'always',
80,
2022-08-16 14:01:24 +03:00
],
},
helpUrl:
'https://github.com/bnb-chain/bsc/tree/develop/docs/lint/commit.md',
}