Skip to content

Commit 0c2561c

Browse files
committed
build: Add commit-lint
This commit introduces commitlint, a tool to enforce conventional commit messages. This is crucial for the automated release process (issue #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.
1 parent 90039d1 commit 0c2561c

5 files changed

Lines changed: 1358 additions & 313 deletions

File tree

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run commitlint ${1}

commitlint.config.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* This commitlint config file extends the conventional configuration
3+
* and adds the following customizations:
4+
*
5+
* - Ignores commit messages that start with "Merge"
6+
* - Allows the following commit types:
7+
* - build
8+
* - chore
9+
* - ci
10+
* - docs
11+
* - feat
12+
* - fix
13+
* - perf
14+
* - refactor
15+
* - revert
16+
* - style
17+
* - test
18+
* - Merge
19+
*
20+
* Please see the commitlint documentation for more information on how to use
21+
* this configuration file:
22+
* https://commitlint.js.org/reference/rules.html
23+
*
24+
*/
25+
const RuleConfigSeverity = {
26+
Disabled: 0,
27+
Warning: 1,
28+
Error: 2,
29+
};
30+
31+
module.exports = {
32+
ignores: [(message) => message.startsWith("Merge")],
33+
rules: {
34+
"type-enum": [
35+
2,
36+
"always",
37+
[
38+
"build",
39+
"chore",
40+
"ci",
41+
"docs",
42+
"feat",
43+
"fix",
44+
"perf",
45+
"refactor",
46+
"revert",
47+
"style",
48+
"test",
49+
],
50+
],
51+
"body-case": [RuleConfigSeverity.Disabled, "always"],
52+
"body-leading-blank": [RuleConfigSeverity.Warning, "always"],
53+
"body-max-line-length": [RuleConfigSeverity.Disabled, "always"],
54+
"footer-leading-blank": [RuleConfigSeverity.Warning, "always"],
55+
"footer-max-line-length": [RuleConfigSeverity.Disabled, "always"],
56+
"header-max-length": [RuleConfigSeverity.Disabled, "always"],
57+
"header-trim": [RuleConfigSeverity.Error, "always"],
58+
"scope-case": [RuleConfigSeverity.Error, "always", "lower-case"],
59+
"subject-case": [RuleConfigSeverity.Disabled, "always"],
60+
"subject-empty": [RuleConfigSeverity.Error, "never"],
61+
"subject-full-stop": [RuleConfigSeverity.Error, "never", "."],
62+
"type-case": [RuleConfigSeverity.Error, "always", "lower-case"],
63+
"type-empty": [RuleConfigSeverity.Error, "never"],
64+
},
65+
};

0 commit comments

Comments
 (0)