Skip to content

Commit

Permalink
Merge pull request #777 from ludsrill/ludsrill
Browse files Browse the repository at this point in the history
feat(build): #769.1 add commit lint config
  • Loading branch information
jpverde authored Dec 1, 2021
2 parents 182d9a3 + 434b512 commit 83357de
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
2 changes: 2 additions & 0 deletions makes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
lintGitCommitMsg = {
enable = true;
branch = "main";
parser = "/test/lint-commit-msg/lint-git-commit-msg-parser.js";
config = "/test/lint-commit-msg/lint-git-commit-msg-config.js";
};
lintGitMailMap = {
enable = true;
Expand Down
60 changes: 60 additions & 0 deletions test/lint-commit-msg/lint-git-commit-msg-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
const HEADERLENGTHMAX = 60;
const LINELENGTHMAX = 72;
const BODYLENGTHMIN = 15;

module.exports = {
parserPreset: './.commitlint-parser-preset',
rules: {

// Body
'body-leading-blank': [2, 'always'], // blank line between header and body
'body-empty': [2, 'never'], // body cannot be empty
'body-max-line-length': [2, 'always', LINELENGTHMAX], // body lines max chars LINELENGTHMAX
'body-min-length' : [2, 'always', BODYLENGTHMIN], // body more than BODYLENGTHMIN chars

// Footer
'footer-leading-blank': [2, 'always'], // blank line between body and footer
'footer-max-line-length': [2, 'always', LINELENGTHMAX], // footer lines max chars LINELENGTHMAX

// Header
'header-case': [2, 'always', 'lower-case'], // header lower case
'header-max-length': [2, 'always', HEADERLENGTHMAX], // header max chars HEADERLENGTHMAX

// Scope
'scope-empty': [2, 'never'], // scope always
'scope-enum': [
2,
'always',
[
'front', // Front-End change
'back', // Back-End change
'infra', // Infrastructure change
'conf', // Configuration files change
'build', // System component change (ci, scons, webpack...)
'job', // asynchronous or schedule tasks (backups, maintainance...)
'cross', // Mix of two or more scopes
'doc', // Documentation only changes
],
],

// Subject (commit title without type and scope)
'subject-case': [2, 'always', 'lower-case'], // subject lower-case
'subject-empty': [2, 'never'], // subject always

// Type
'type-empty': [2, 'never'], //type always
'type-enum': [
2,
'always',
[
'feat', // New feature
'perf', // Improves performance
'fix', // Bug fix
'rever', // Revert to a previous commit in history
'style', // Do not affect the meaning of the code (formatting, etc)
'refac', // Neither fixes a bug or adds a feature
'test', // Adding missing tests or correcting existing tests
],
],
},
};
6 changes: 6 additions & 0 deletions test/lint-commit-msg/lint-git-commit-msg-parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
parserOpts: {
headerPattern: /^(\w*)\((\w*)\):\s(#[0-9]\d*)(.\d+)?\s(.*)$/,
headerCorrespondence: [ 'type', 'scope', 'ticket', 'part', 'subject' ],
},
};

0 comments on commit 83357de

Please sign in to comment.