Skip to content

Commit

Permalink
build: Add commit-lint
Browse files Browse the repository at this point in the history
This commit introduces commitlint, a tool to enforce conventional commit
messages. This is crucial for the automated release process (issue VRPirates#32)
to work correctly, as it relies on conventional commit messages to
generate the changelog.

The commit includes the following changes:

- Adds `commitlint.config.js` file that defines commitlint's rules for
conventional commits. This config file ensures commits adhere to the
Conventional Commits specification, allowing for automated changelog
generation.
- Adds a `.husky/commit-msg` hook which ensures that commitlint is run
before each commit.
- Adds `@commitlint/cli` and `@commitlint/config-conventional` packages
to `package-lock.json` to enable commitlint functionality.
- Updates `package.json` to add a "commitlint" script, allowing
developers to run commitlint directly.

By enforcing conventional commits, this commit improves the project's
workflow, making releases more reliable and automated. It ensures the
changelog is accurate and consistent, making it easier for developers
and users to understand the project's history and changes.
  • Loading branch information
MikeRatcliffe committed Sep 30, 2024
1 parent 90039d1 commit 0c2561c
Show file tree
Hide file tree
Showing 5 changed files with 1,358 additions and 313 deletions.
1 change: 1 addition & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npm run commitlint ${1}
65 changes: 65 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* This commitlint config file extends the conventional configuration
* and adds the following customizations:
*
* - Ignores commit messages that start with "Merge"
* - Allows the following commit types:
* - build
* - chore
* - ci
* - docs
* - feat
* - fix
* - perf
* - refactor
* - revert
* - style
* - test
* - Merge
*
* Please see the commitlint documentation for more information on how to use
* this configuration file:
* https://commitlint.js.org/reference/rules.html
*
*/
const RuleConfigSeverity = {
Disabled: 0,
Warning: 1,
Error: 2,
};

module.exports = {
ignores: [(message) => message.startsWith("Merge")],
rules: {
"type-enum": [
2,
"always",
[
"build",
"chore",
"ci",
"docs",
"feat",
"fix",
"perf",
"refactor",
"revert",
"style",
"test",
],
],
"body-case": [RuleConfigSeverity.Disabled, "always"],
"body-leading-blank": [RuleConfigSeverity.Warning, "always"],
"body-max-line-length": [RuleConfigSeverity.Disabled, "always"],
"footer-leading-blank": [RuleConfigSeverity.Warning, "always"],
"footer-max-line-length": [RuleConfigSeverity.Disabled, "always"],
"header-max-length": [RuleConfigSeverity.Disabled, "always"],
"header-trim": [RuleConfigSeverity.Error, "always"],
"scope-case": [RuleConfigSeverity.Error, "always", "lower-case"],
"subject-case": [RuleConfigSeverity.Disabled, "always"],
"subject-empty": [RuleConfigSeverity.Error, "never"],
"subject-full-stop": [RuleConfigSeverity.Error, "never", "."],
"type-case": [RuleConfigSeverity.Error, "always", "lower-case"],
"type-empty": [RuleConfigSeverity.Error, "never"],
},
};
Loading

0 comments on commit 0c2561c

Please sign in to comment.