-
Notifications
You must be signed in to change notification settings - Fork 28
feat(commit): setup Husky, Commitlint,Commitzen #63
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
WalkthroughThis change introduces a comprehensive commit message linting and automation system to the repository. It adds configuration and setup for Commitlint, Husky, Commitizen, and lint-staged, along with a GitHub Actions workflow to enforce commit message standards on pull requests. The README is rewritten to document these new development workflows and tools, replacing previous project-specific build instructions. The new setup ensures that commit messages follow a standardized format both locally (via Git hooks) and in CI, and provides contributors with tools for guided commit creation. 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 (type, scope, subject, etc.)
Developer->>Husky: git commit
Husky->>Commitlint: Validate commit message (commit-msg hook)
Commitlint-->>Husky: Pass/Fail
Husky-->>Developer: Allow or block commit
Developer->>GitHub Actions: Open PR / push commits
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
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: 2
🧹 Nitpick comments (10)
.husky/pre-commit (1)
1-1: Add a shebang and error handling to the hook script.Husky hook scripts should include a shebang (e.g.,
#!/usr/bin/env sh) and optionally source the Husky environment to ensure consistent behavior:+#!/usr/bin/env sh +. "$(dirname "$0")/_/husky.sh" npx lint-staged.github/workflows/commit-lint.yml (1)
25-27: Consider caching Node.js dependencies in CI.To speed up the workflow, add an
actions/cachestep beforenpm cito cache~/.npmornode_modules:- name: Cache NPM modules uses: actions/cache@v3 with: path: ~/.npm key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} restore-keys: | ${{ runner.os }}-npm-README.md (8)
3-4: Break up lengthy introduction and fix missing punctuation/article.
Line 3: insert a comma after “in a standard way” for clarity.
Line 4: add “the” before “rest of the 18 resources.”
Consider splitting this long paragraph into two or more shorter ones to improve readability.🧰 Tools
🪛 LanguageTool
[uncategorized] ~3-~3: Possible missing comma found.
Context: ...nicians and organizations in a standard way regardless of the ways local EHRs repre...(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~4-~4: You might be missing the article “the” here.
Context: ... Contributors are working on developing rest of the 18 resources which will make AMR...(AI_EN_LECTOR_MISSING_DETERMINER_THE)
5-5: Adjust heading level for consistency.
Change### Key APIs in ECD service(H3) to## Key APIs in ECD serviceso that headings increment by only one level from the H1 title.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3(MD001, heading-increment)
14-16: Fix trailing space in link definition.
On line 14 remove the space before the period in the Developer Guide link—change(…setup) .to(…setup)..
26-27: Use consistent unordered list markers.
Lines 26–27 use dashes (- Node.js,- npm) whereas earlier lists use asterisks. Switch these to*for uniformity.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
26-26: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
27-27: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
34-37: Specify language for fenced code blocks.
The code fences on lines 34–37 and 40–42 currently lack a language identifier. Add e.g.```bash node --version npm --versionand
```bash npm cito enable proper syntax highlighting.
Also applies to: 40-42
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
34-34: Fenced code blocks should have a language specified
null(MD040, fenced-code-language)
49-62: Use consistent list syntax in commit conventions.
The commit-type list on lines 49–62 uses dashes (-) but earlier sections use asterisks. Switch these to*to maintain a single markdown style.🧰 Tools
🪛 LanguageTool
[grammar] ~53-~53: “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] ~56-~56: Loose punctuation mark.
Context: ... changes (formatting, etc.) -refactor: Code changes that neither fix bugs nor ...(UNLIKELY_OPENING_PUNCTUATION)
🪛 markdownlint-cli2 (0.17.2)
49-49: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
50-50: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
52-52: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
53-53: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
54-54: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
55-55: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
56-56: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
57-57: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
58-58: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
59-59: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
60-60: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
61-61: Unordered list style
Expected: asterisk; Actual: dash(MD004, ul-style)
63-65: Clean up trailing spaces and blank lines.
Remove the extra blank line at 63 and strip any trailing spaces on lines 65 for tighter formatting.
66-78: Consolidate community section and remove superfluous blank lines.
Lines 66–78 include many empty lines and layout markers. Collapse them into a succinct block, for example:## Join Our Community We’d love to have you join our community discussions and get real-time support! Join our [Discord server](https://discord.gg/FVQWsf5ENS) to connect with contributors, ask questions, and stay updated.🧰 Tools
🪛 markdownlint-cli2 (0.17.2)
73-73: Code block style
Expected: fenced; Actual: indented(MD046, code-block-style)
📜 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 (6)
.github/workflows/commit-lint.yml(1 hunks).husky/commit-msg(1 hunks).husky/pre-commit(1 hunks)README.md(1 hunks)commitlint.config.js(1 hunks)package.json(1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md
[uncategorized] ~3-~3: Possible missing comma found.
Context: ...nicians and organizations in a standard way regardless of the ways local EHRs repre...
(AI_HYDRA_LEO_MISSING_COMMA)
[uncategorized] ~4-~4: You might be missing the article “the” here.
Context: ... Contributors are working on developing rest of the 18 resources which will make AMR...
(AI_EN_LECTOR_MISSING_DETERMINER_THE)
[uncategorized] ~32-~32: The official spelling of this programming framework is “Node.js”.
Context: ...d npm** - Download and install from nodejs.org - Verify i...
(NODE_JS)
[grammar] ~53-~53: “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] ~56-~56: Loose punctuation mark.
Context: ... changes (formatting, etc.) - refactor: Code changes that neither fix bugs nor ...
(UNLIKELY_OPENING_PUNCTUATION)
🪛 markdownlint-cli2 (0.17.2)
README.md
5-5: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3
(MD001, heading-increment)
26-26: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
27-27: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
32-32: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
33-33: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
34-34: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
39-39: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
40-40: Fenced code blocks should have a language specified
null
(MD040, fenced-code-language)
43-43: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
45-45: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
46-46: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
49-49: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
50-50: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
52-52: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
53-53: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
54-54: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
55-55: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
56-56: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
57-57: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
58-58: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
59-59: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
60-60: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
61-61: Unordered list style
Expected: asterisk; Actual: dash
(MD004, ul-style)
73-73: Code block style
Expected: fenced; Actual: indented
(MD046, code-block-style)
🔇 Additional comments (2)
commitlint.config.js (1)
1-43: Commitlint rules are comprehensive and follow the conventional standard.The configuration covers body and footer formatting, header length, type and scope casing, and restricts allowed types and scopes appropriately.
.github/workflows/commit-lint.yml (1)
28-30: Approve commitlint invocation on PR branches.The job correctly checks out the code, installs dependencies, and runs
npx commitlintbetween the base and head SHAs with verbose output.
| @@ -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.
Fix the npx invocation in the commit-msg hook.
The current npx --no -- commitlint --edit $1 may not behave as intended. Use the recommended Husky pattern with a shebang, source Husky, and invoke Commitlint without the invalid --no flag:
+#!/usr/bin/env sh
+. "$(dirname "$0")/_/husky.sh"
-npx --no -- commitlint --edit $1
+npx --no-install 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-install commitlint --edit "$1" |
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "prepare": "husky", | ||
| "commit": "cz" | ||
| }, |
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
Update the prepare script to install Husky hooks.
The prepare script should invoke husky install to set up the Git hooks after install:
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1",
- "prepare": "husky",
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "prepare": "husky install",
"commit": "cz"
},📝 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.
| "test": "echo \"Error: no test specified\" && exit 1", | |
| "prepare": "husky", | |
| "commit": "cz" | |
| }, | |
| "scripts": { | |
| "test": "echo \"Error: no test specified\" && exit 1", | |
| "prepare": "husky install", | |
| "commit": "cz" | |
| }, |
|
@blazethunderstorm have you self-reviewed your PR? |
|
@drtechie will make the changes by today |
|
@drtechie the changes are already done in the file what should i do ? |



Implemented it for ECD-API
📋 Description
JIRA ID: Fixes PSMRI/AMRIT#80
This PR introduces commit message standardization for the FHIR-API project by setting up Commitlint, Husky, and Commitizen.
The goal is to enforce a consistent commit message format across the repository, improving collaboration, readability,
and enabling future automation (like changelogs and versioning).
These tools are now integrated:
PS: Implemented with the same standardization as for the UI repositories to ensure clean and well-maintained code.
✅ Type of Change
ℹ️ Additional Information
🧪 Testing & Validation:
PROOF(SCREENSHOTS)
Summary by CodeRabbit
New Features
consistent commit message standards.
Chores
dependencies management.