feat(githooks): add commitlint, husky and commitizen setup#40
feat(githooks): add commitlint, husky and commitizen setup#40DurgaPrasad-54 wants to merge 4 commits intoPSMRI:mainfrom
Conversation
📝 WalkthroughWalkthroughAdds commit message validation: commitlint config, Husky Changes
Sequence Diagram(s)sequenceDiagram
participant PR as Pull Request
participant GH as GitHub Actions
participant Runner as Runner
participant Node as Node.js (18)
participant NPM as npm
participant Commitlint as commitlint
PR->>GH: PR opened/synchronized/reopened
GH->>Runner: checkout repo (fetch-depth: 0)
GH->>Runner: fetch base branch, compute merge-base (FROM)
GH->>Runner: setup Node.js (v18)
Runner->>NPM: run `npm install --legacy-peer-deps`
Runner->>Commitlint: run `npx commitlint --from "$FROM" --to <headSHA> --verbose`
Commitlint-->>GH: report results/logs
GH-->>PR: annotate PR with pass/fail
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
package.json (2)
2-18: Consider marking this tooling manifest as private.If this
package.jsononly exists to drive local commit tooling in a git-submodule repo, adding"private": truewould reduce accidental npm publish risk from the new package metadata.Based on learnings: The Common-UI repository is designed to be used as a git submodule in other AMRIT applications.Suggested fix
{ "name": "common-ui", + "private": true, "version": "1.0.0",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package.json` around lines 2 - 18, The package manifest for "common-ui" should be marked private to prevent accidental npm publishes; update package.json by adding the "private": true field at the top-level (alongside "name", "version", "description", etc.) so the package is non-publishable; ensure the entry is a boolean true and placed at root of the JSON object (affecting the existing keys like "name": "common-ui" and "scripts") without changing other fields.
9-9: Use the Husky v9preparecommand form.The current Husky setup docs recommend running
huskyfromprepare; keepinghusky installhere carries forward the older setup path instead of the current v9 one. (typicode.github.io)Suggested fix
- "prepare": "husky install" + "prepare": "husky"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@package.json` at line 9, The package.json prepare script currently uses the older invocation "husky install"; update the "prepare" script in package.json to the Husky v9 recommended form by replacing that value with the v9 invocation (run the `husky` command recommended by the v9 docs) so the "prepare" script uses the current Husky v9 command rather than the legacy form.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/commit-lint.yml:
- Around line 20-23: The workflow currently pins the setup action to use Node.js
18 via "uses: actions/setup-node@v4" with "node-version: 18"; update the pinned
runtime to a supported LTS (e.g., change "node-version: 18" to "node-version:
20" or "node-version: '20.x'" or use "node-version: 'lts/*'") so the new CI
workflow does not rely on an EOL Node.js release and the actions/setup-node
usage remains the same.
In `@commitlint.config.js`:
- Around line 4-7: The rules 'body-leading-blank' and 'footer-leading-blank' are
currently set with severity 1 (warnings) so they won't block commits; update
their rule entries in commitlint.config.js to use severity 2 by changing
'body-leading-blank': [1, 'always'] and 'footer-leading-blank': [1, 'always'] to
'body-leading-blank': [2, 'always'] and 'footer-leading-blank': [2, 'always'] so
commitlint treats them as errors and fails the commit when violated.
In `@package.json`:
- Around line 6-10: The package.json currently defines a "test" npm script that
always exits with code 1 causing CI/bootstrap steps to fail; update the "test"
script (the "test" key in the scripts object) to a non-failing placeholder such
as a no-op or informative echo (for example: echo "No tests" && exit 0) or
remove the failing script entirely so running npm test does not return a failure
during installs and CI runs.
---
Nitpick comments:
In `@package.json`:
- Around line 2-18: The package manifest for "common-ui" should be marked
private to prevent accidental npm publishes; update package.json by adding the
"private": true field at the top-level (alongside "name", "version",
"description", etc.) so the package is non-publishable; ensure the entry is a
boolean true and placed at root of the JSON object (affecting the existing keys
like "name": "common-ui" and "scripts") without changing other fields.
- Line 9: The package.json prepare script currently uses the older invocation
"husky install"; update the "prepare" script in package.json to the Husky v9
recommended form by replacing that value with the v9 invocation (run the `husky`
command recommended by the v9 docs) so the "prepare" script uses the current
Husky v9 command rather than the legacy form.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c2df0e42-ef7d-474b-a9ee-969fcf398565
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (5)
.github/workflows/commit-lint.yml.gitignore.husky/commit-msgcommitlint.config.jspackage.json
There was a problem hiding this comment.
🧹 Nitpick comments (1)
commitlint.config.js (1)
36-36: Minor: Inconsistent indentation on closing brace.The closing brace uses 2-space indent while the rest of the object body uses 4-space indent. Consider aligning for consistency.
✏️ Suggested fix
- }; +};Note on pipeline failure: The ESLint failure is unrelated to this file's content — the CI workflow attempts to lint JS files but the project lacks an ESLint configuration. If commit linting is the only JavaScript tooling intended, consider either adding a minimal
.eslintrcor updating the CI workflow to exclude commitlint config files from ESLint checks.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@commitlint.config.js` at line 36, The closing brace and semicolon at the end of the exported config object in commitlint.config.js are indented with 2 spaces, causing inconsistent indentation; change the closing token "};" (the end of the module.exports object) to use 4-space indentation to match the rest of the object's body so the file's indentation is consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@commitlint.config.js`:
- Line 36: The closing brace and semicolon at the end of the exported config
object in commitlint.config.js are indented with 2 spaces, causing inconsistent
indentation; change the closing token "};" (the end of the module.exports
object) to use 4-space indentation to match the rest of the object's body so the
file's indentation is consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c0b40ad9-7017-499e-93ac-81cd87142a4d
📒 Files selected for processing (3)
.github/workflows/commit-lint.ymlcommitlint.config.jspackage.json
🚧 Files skipped from review as they are similar to previous changes (2)
- .github/workflows/commit-lint.yml
- package.json
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
eslint.config.js (2)
7-7: Empty rules object means no linting rules are enforced.With
rules: {}, ESLint will only validate syntax without enforcing any code quality rules. If this is intentional for a minimal setup, consider adding a comment to clarify the intent. Otherwise, consider extending a recommended configuration.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@eslint.config.js` at line 7, The ESLint config currently has an empty rules object (rules: {}) which disables all linting rules; update eslint.config.js to either populate the rules with at least a baseline (e.g., extend "eslint:recommended" or add a minimal ruleset) or, if intentionally empty, add a clear comment above the rules property explaining the intent (e.g., "Intentionally empty to only validate syntax") so reviewers know this is deliberate; locate the rules: {} entry in eslint.config.js and apply one of these fixes.
5-8: Add TypeScript parser configuration to eslint.config.js.The config targets
.tsfiles but doesn't configure the TypeScript parser. While@typescript-eslint/parserand@typescript-eslint/eslint-pluginare already in devDependencies, the eslint.config.js doesn't reference them. ESLint will fail to parse TypeScript-specific syntax without this configuration.♻️ Proposed configuration update
+const tseslint = require('@typescript-eslint/eslint-plugin'); +const tsParser = require('@typescript-eslint/parser'); + module.exports = [ { ignores: ['node_modules/**', 'dist/**'], }, { files: ['**/*.{js,ts}'], + languageOptions: { + parser: tsParser, + }, + plugins: { + '@typescript-eslint': tseslint, + }, rules: {}, }, ];Alternatively, if TypeScript linting isn't intended, limit the file scope to JavaScript:
- files: ['**/*.{js,ts}'], + files: ['**/*.js'],🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@eslint.config.js` around lines 5 - 8, The ESLint config currently lists files: ['**/*.{js,ts}'] but doesn't set a TypeScript parser or plugin, so add TypeScript parsing by updating eslint.config.js to set languageOptions.parser to '@typescript-eslint/parser', include '@typescript-eslint' in languageOptions.plugins, and add the recommended TypeScript configs (e.g., extend '@typescript-eslint/recommended' or set parserOptions.project if using type-aware rules) so .ts files parse correctly; alternatively, if you don't want TypeScript linting, narrow the files pattern to only js (remove .ts from files: ['**/*.js']) and keep rules as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@eslint.config.js`:
- Line 7: The ESLint config currently has an empty rules object (rules: {})
which disables all linting rules; update eslint.config.js to either populate the
rules with at least a baseline (e.g., extend "eslint:recommended" or add a
minimal ruleset) or, if intentionally empty, add a clear comment above the rules
property explaining the intent (e.g., "Intentionally empty to only validate
syntax") so reviewers know this is deliberate; locate the rules: {} entry in
eslint.config.js and apply one of these fixes.
- Around line 5-8: The ESLint config currently lists files: ['**/*.{js,ts}'] but
doesn't set a TypeScript parser or plugin, so add TypeScript parsing by updating
eslint.config.js to set languageOptions.parser to '@typescript-eslint/parser',
include '@typescript-eslint' in languageOptions.plugins, and add the recommended
TypeScript configs (e.g., extend '@typescript-eslint/recommended' or set
parserOptions.project if using type-aware rules) so .ts files parse correctly;
alternatively, if you don't want TypeScript linting, narrow the files pattern to
only js (remove .ts from files: ['**/*.js']) and keep rules as-is.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: aaba3a58-590f-4d42-92a4-23b51281bc41
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (3)
.github/workflows/commit-lint.ymleslint.config.jspackage.json
🚧 Files skipped from review as they are similar to previous changes (2)
- .github/workflows/commit-lint.yml
- package.json
|



📋 Description
JIRA ID:
This PR introduces commit message linting and automation to enforce a standardized commit structure across the repository. It integrates Commitlint, Husky, and Commitizen to ensure contributors follow the Conventional Commits specification.
✅ Type of Change
Summary by CodeRabbit