-
Notifications
You must be signed in to change notification settings - Fork 29
chore: integrate commitlint, husky, and commitizen for standardized commits #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
test
setup Commitlint, Husky, and Commitizen for standardized commit messages
WalkthroughThis change introduces a comprehensive commit message linting and automation system for the repository. It adds configuration and setup for Commitlint, Husky, Commitizen, and GitHub Actions to enforce conventional commit message standards. New configuration files and scripts are included for commit message validation both locally (via Git hooks) and in CI (via a GitHub Actions workflow). The Changes
Sequence Diagram(s)sequenceDiagram
participant Developer
participant Husky
participant Commitlint
participant Commitizen
participant GitHub Actions
Developer->>Commitizen: Run `npm run commit`
Commitizen->>Developer: Prompt for commit details (conventional format)
Developer->>Husky: Attempt commit
Husky->>Commitlint: Validate commit message (commit-msg hook)
Commitlint-->>Husky: Pass/Fail
Husky-->>Developer: Allow/Block commit
Developer->>GitHub Actions: Open/Update PR
GitHub Actions->>Commitlint: Lint all PR commit messages
Commitlint-->>GitHub Actions: Pass/Fail
GitHub Actions-->>Developer: PR check result
Assessment against linked issues
Possibly related issues
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
commitlint.config.jsOops! Something went wrong! :( ESLint: 9.25.0 A config object is using the "extends" key, which is not supported in flat config system. Instead of "extends", you can include config objects that you'd like to extend from directly in the flat config array. If you're using "extends" in your config file, please see the following: If you're not using "extends" directly (it may be coming from a plugin), please see the following: eslint.config.jsOops! Something went wrong! :( ESLint: 9.25.0 A config object is using the "extends" key, which is not supported in flat config system. Instead of "extends", you can include config objects that you'd like to extend from directly in the flat config array. If you're using "extends" in your config file, please see the following: If you're not using "extends" directly (it may be coming from a plugin), please see the following: Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (7)
.gitignore (2)
4-5: Ignore Node.js dependencies
Great addition of/node_modulesunder the new# dependenciessection to prevent tracking installed packages. Consider also ignoring other lockfiles used by alternative package managers (e.g.,yarn.lock,.pnpm-lock.yaml) to ensure consistency across different workflows.
33-33: Group lockfile ignore under dependencies
Thepackage-lock.jsonentry currently sits under# Config. For clarity and maintainability, you may want to relocate it to the# dependenciessection so all package-manager artifacts are collated together..github/workflows/commitlint.yml (1)
28-30: Commitlint invocation is appropriate
Linting commits between the base and head SHA with--verboseprovides clear feedback on commit message violations.YAML files should end with a newline character.
Please add a blank line after the lastruncommand to satisfy YAML lint rules.🧰 Tools
🪛 YAMLlint (1.35.1)
[error] 30-30: no new line character at the end of file
(new-line-at-end-of-file)
README.md (4)
45-48: Specify code block language for syntax highlighting
Please add a language identifier to the fenced code block:- ``` + ```bash🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
45-45: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
53-55: Add language specifier to the code block
Using a language marker improves readability:- ``` + ```bash
63-65: Include language for the Commitizen command snippet
Enhance clarity by specifying the shell:- ``` + ```bash🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
63-63: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
90-90: Convert bare URL into markdown link
Wrap the URL for consistency with markdown best practices:-Open the application in your browser. The inventory module will be accessible at http://localhost:3000/inventory. +Open the application in your browser. The inventory module will be accessible at [http://localhost:3000/inventory](http://localhost:3000/inventory).🧰 Tools
🪛 LanguageTool
[style] ~90-~90: Consider removing “of” to be more concise
Context: ... your browser. You will be able to view all of the items in your inventory, create purchas...(ALL_OF_THE)
🪛 markdownlint-cli2 (0.17.2)
90-90: Bare URL used
null(MD034, no-bare-urls)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (8)
.github/workflows/commitlint.yml(1 hunks).gitignore(2 hunks).husky/commit-msg(1 hunks).husky/pre-commit(1 hunks)README.md(2 hunks)commitlint.config.js(1 hunks)eslint.config.js(1 hunks)package.json(1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
.github/workflows/commitlint.yml
[error] 30-30: no new line character at the end of file
(new-line-at-end-of-file)
🪛 LanguageTool
README.md
[uncategorized] ~43-~43: The official spelling of this programming framework is “Node.js”.
Context: ...d npm** - Download and install from nodejs.org - Verify i...
(NODE_JS)
[grammar] ~76-~76: “Bug” is a singular noun. It appears that the verb form is incorrect.
Context: ... - feat: A new feature - fix: A bug fix - docs: Documentation changes - `styl...
(PCT_SINGULAR_NOUN_PLURAL_VERB_AGREEMENT)
[uncategorized] ~79-~79: Loose punctuation mark.
Context: ... changes (formatting, etc.) - refactor: Code changes that neither fix bugs nor ...
(UNLIKELY_OPENING_PUNCTUATION)
[style] ~90-~90: Consider removing “of” to be more concise
Context: ... your browser. You will be able to view all of the items in your inventory, create purchas...
(ALL_OF_THE)
🪛 markdownlint-cli2 (0.17.2)
README.md
45-45: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
52-52: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
63-63: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
90-90: Bare URL used
null
(MD034, no-bare-urls)
🔇 Additional comments (9)
.github/workflows/commitlint.yml (3)
1-6: Workflow trigger configuration looks correct
The workflow is appropriately named and set to run on pull_request events (opened, synchronize, reopened), ensuring commit message validation on all PR updates.
12-19: Checkout step is correctly configured
Usingactions/checkout@v4withfetch-depth: 0and submodules ensures full commit history is available for linting commit messages.
20-27: Node.js setup and dependency installation are solid
Setting up Node.js v18 and runningnpm ci --legacy-peer-depsguarantees a reproducible install of the linting tools.README.md (1)
38-41: Commit hook instructions are clear and comprehensive
The new section outlines prerequisites and setup steps for Husky and Commitizen, fitting seamlessly into the existing documentation.commitlint.config.js (5)
1-3: Extends standard Conventional Commit configuration
Leveraging@commitlint/config-conventionalprovides a solid base for commit message rules.
4-8: Body, footer, and header length rules are well-defined
Enforcing blank lines and max-line-length constraints helps maintain readable commit messages.
9-13: Subject casing rules are properly configured
Disallowing sentence-case, start-case, pascal-case, and upper-case ensures consistent subject formatting.
14-18: Subject and type presence rules are strict and appropriate
Preventing empty subjects and enforcing lowercase types aligns with Conventional Commits standards.
19-34: Type enumeration covers all relevant commit types
The predefined list of types is comprehensive and matches the README documentation.
| module.exports = { | ||
| extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], | ||
| parser: '@typescript-eslint/parser', | ||
| parserOptions: { | ||
| ecmaVersion: 2020, | ||
| sourceType: 'module', | ||
| }, | ||
| plugins: ['@typescript-eslint'] | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Include root and environment settings
The current ESLint configuration lacks the root flag and an env block. Without these, ESLint may not recognize globals (e.g., process, window) or correctly determine the project root.
Apply this diff to harden the config:
module.exports = {
+ root: true,
+ env: {
+ node: true,
+ es2020: true
+ },
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
parser: '@typescript-eslint/parser',
parserOptions: {📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| module.exports = { | |
| extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], | |
| parser: '@typescript-eslint/parser', | |
| parserOptions: { | |
| ecmaVersion: 2020, | |
| sourceType: 'module', | |
| }, | |
| plugins: ['@typescript-eslint'] | |
| }; | |
| module.exports = { | |
| root: true, | |
| env: { | |
| node: true, | |
| es2020: true | |
| }, | |
| extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], | |
| parser: '@typescript-eslint/parser', | |
| parserOptions: { | |
| ecmaVersion: 2020, | |
| sourceType: 'module', | |
| }, | |
| plugins: ['@typescript-eslint'] | |
| }; |
| "version": "1.0.0", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "prepare": "husky", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the prepare script to install Husky hooks
Husky v9 requires the install command to set up Git hooks. The current "prepare": "husky" invocation will not create the hooks.
Apply this diff:
- "prepare": "husky",
+ "prepare": "husky install",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "prepare": "husky", | |
| "prepare": "husky install", |
| @@ -0,0 +1 @@ | |||
| npx lint-staged | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Husky hook boilerplate
Husky hook scripts must start with the standard header to source the Husky runtime; otherwise the hook won’t execute.
Apply this diff:
- npx lint-staged
+ #!/usr/bin/env sh
+ . "$(dirname "$0")/_/husky.sh"
+ npx lint-staged📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| npx lint-staged | |
| #!/usr/bin/env sh | |
| . "$(dirname "$0")/_/husky.sh" | |
| npx lint-staged |
| @@ -0,0 +1 @@ | |||
| npx --no -- commitlint --edit $1 No newline at end of file | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add Husky hook boilerplate
Similarly, include the shebang and Husky shim in the commit-msg hook so commitlint is properly invoked.
- npx --no -- commitlint --edit $1
+ #!/usr/bin/env sh
+ . "$(dirname "$0")/_/husky.sh"
+ npx --no -- commitlint --edit "$1"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| npx --no -- commitlint --edit $1 | |
| #!/usr/bin/env sh | |
| . "$(dirname "$0")/_/husky.sh" | |
| npx --no -- commitlint --edit "$1" |
|
@drtechie Please Review it : ) |



Description
JIRA ID:
Github Issues: Fixes PSMRI/AMRIT#83
This pull request introduces automated commit message validation and linting using Commitlint, Husky, and Commitizen for the Inventory API project. The goal is to enforce a consistent commit message format (using the Conventional Commits standard) across all contributions. Additionally, this setup allows for easier collaboration and improved changelog generation in the future.
Changes include:
The primary motivation behind these changes is to standardize commit messages, improve collaboration, and lay the groundwork for automated changelog generation.
Type of Change
Additional Information
Testing
npm run commitcommand (via Commitizen) to ensure that the prompts guide contributors correctly. It works as expected, ensuring standardized commit messages..huskydirectory and ensuring that thecommit-msghook is triggering commitlint for validation.Screenshots/Logs
Summary by CodeRabbit
New Features
Documentation
Chores