Skip to content

Commit

Permalink
commitlint.config: reject words in the middle
Browse files Browse the repository at this point in the history
  • Loading branch information
tehraninasab committed Oct 24, 2022
1 parent 5478dc4 commit eea72b6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions commitlint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,18 @@ module.exports = {
let colonFirstIndex = headerStr.indexOf(":");
let titleStartIndex = Math.max(0, colonFirstIndex + 1);
let title = headerStr.substring(titleStartIndex, headerStr.length).trim();
let firstWordInTitle = title.split(' ')[0];
offence = obviousWords.includes(firstWordInTitle);
let titleWords = title.split(' ');
let usedObviousWords = '';
for (let word of titleWords) {
if (obviousWords.includes(word)) {
offence = true;
usedObviousWords = usedObviousWords + ', ' + word
}
}

return [
!offence,
`Please don't use obvious words such as ${firstWordInTitle} in the commit title`
`Please don't use obvious words such as ${usedObviousWords} in the commit title`
];
},

Expand Down

0 comments on commit eea72b6

Please sign in to comment.