⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@dibyanshu-pal-kushwaha
Copy link

@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha commented Dec 28, 2025

Summary

This PR fixes the lack of automated commit message validation and integrates Husky for git hooks to ensure contribution guidelines are followed.

Related Issue

Fixes #4303

Changes

  • Added husky to devDependencies in package.json(root configuration)
  • Added lint:commit script to package.json(root configuration) to check commit messages against the main branch.
  • Updated the lint script in package.json by including lint:commit.
  • Created commitlint.config.js with a custom headlamp-format rule as mentioned in the commit guidelines for maintaining : format.
  • Removed husky from frontend/package.json to root package.json
  • Added .husky/commit-msg hook to trigger commitlint on commit creation.
  • Added CI integration in the github workflow
  • Updated the docs for the lint:commit in the commit guidelines

Steps to Test

  1. Run npm install to install dependencies and initialize husky.
    2.Try to create any commit with wrong format (for example : git commit -m "test commit")
  2. Terminal would give commit is blocked by showing proper error.
  3. Now create a valid commit(for eg : git commit -m "frontend: Homebutton: Change the color").
  4. Finally commits get succeeds.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Dec 28, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot
Copy link
Contributor

Welcome @dibyanshu-pal-kushwaha!

It looks like this is your first PR to kubernetes-sigs/headlamp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/headlamp has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Dec 28, 2025
@illume
Copy link
Contributor

illume commented Dec 28, 2025

Hey hey.

please check the contribution commit guidelines. There are some examples of commit messages that are good and bad in there.

We do not use fix and chore for example.

@illume
Copy link
Contributor

illume commented Dec 28, 2025

cool, thanks.

Please check the failed checks to see what the errors are?

Can you please rebase and squash your commits down to just the ones to be merged? Probably there should be one or two commits.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds automated commit message validation by integrating Husky git hooks and commitlint at the root level. The implementation aims to enforce the project's commit guidelines that require an <area>: <description> format for all commit messages.

Key Changes

  • Moved Husky from frontend to root configuration with upgraded version (v4.3.8 → v9.1.7)
  • Added lint:commit script to validate commit messages against the main branch
  • Created custom commitlint configuration with a headlamp-format rule to validate commit message structure
  • Set up git hooks for commit-msg validation and pre-commit linting

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
package.json Added husky to root devDependencies, created prepare and lint:commit scripts, upgraded concurrently version
package-lock.json Added extensive new dependencies for eslint, prettier, lint-staged, and related tooling
frontend/package.json Removed husky dependency and husky.hooks configuration, but contains critical JSON syntax errors with duplicate lint-staged configurations
commitlint.config.js Created custom headlamp-format rule to validate commit message format with regex pattern
.husky/commit-msg Added hook to run commitlint on commit message creation
.husky/pre-commit Added hook to run lint-staged on pre-commit
Comments suppressed due to low confidence (1)

frontend/package.json:233

  • There are three duplicate lint-staged configurations in this file (lines 126-157, 163-194, and 202-233). This is redundant and will cause confusion about which configuration is actually used. Only one lint-staged configuration should be present at the top level of package.json.
  "lint-staged": {
    "src/**/*.{js,jsx,ts,tsx}": [
      "eslint -c package.json --fix"
    ],
    "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../app/**/*.{ts,tsx}": [
      "eslint -c package.json --fix"
    ],
    "../app/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../plugins/headlamp-plugin/{bin,lib}/**/*.{ts,tsx}": [
      "eslint -c package.json --fix"
    ],
    "../plugins/headlamp-plugin/{bin,lib}/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../plugins/examples/**/*.{ts,tsx}": [
      "eslint -c package.json --fix --resolve-plugins-relative-to ."
    ],
    "../plugins/examples/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../e2e-tests/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../e2e-tests/**/*.{ts,tsx}": [
      "eslint -c package.json --fix --resolve-plugins-relative-to ."
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],"lint-staged": {
    "src/**/*.{js,jsx,ts,tsx}": [
      "eslint -c package.json --fix"
    ],
    "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../app/**/*.{ts,tsx}": [
      "eslint -c package.json --fix"
    ],
    "../app/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../plugins/headlamp-plugin/{bin,lib}/**/*.{ts,tsx}": [
      "eslint -c package.json --fix"
    ],
    "../plugins/headlamp-plugin/{bin,lib}/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../plugins/examples/**/*.{ts,tsx}": [
      "eslint -c package.json --fix --resolve-plugins-relative-to ."
    ],
    "../plugins/examples/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../e2e-tests/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../e2e-tests/**/*.{ts,tsx}": [
      "eslint -c package.json --fix --resolve-plugins-relative-to ."
    ]
  },
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  
  "lint-staged": {
    "src/**/*.{js,jsx,ts,tsx}": [
      "eslint -c package.json --fix"
    ],
    "src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../app/**/*.{ts,tsx}": [
      "eslint -c package.json --fix"
    ],
    "../app/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../plugins/headlamp-plugin/{bin,lib}/**/*.{ts,tsx}": [
      "eslint -c package.json --fix"
    ],
    "../plugins/headlamp-plugin/{bin,lib}/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../plugins/examples/**/*.{ts,tsx}": [
      "eslint -c package.json --fix --resolve-plugins-relative-to ."
    ],
    "../plugins/examples/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../e2e-tests/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
      "prettier --config package.json --write"
    ],
    "../e2e-tests/**/*.{ts,tsx}": [
      "eslint -c package.json --fix --resolve-plugins-relative-to ."
    ]
  },

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch 3 times, most recently from 88c3e35 to 60e40bf Compare December 28, 2025 20:28
@illume illume requested a review from Copilot December 28, 2025 20:33
@illume
Copy link
Contributor

illume commented Dec 28, 2025

@dibyanshu-pal-kushwaha Can you please check the comments by the copilot? Comment for ones that you have addressed “I have done this”, or write if it does not make sense “this does not make sense because of these reasons…”

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please address the open items?

I think also “frontend: Add nnn” should be disallowed.

Please add the areas you are changing, not just frontend. For example “frontend: resourceMap: Fix performance issue with clicking on items”. This is because many changes are in backend, so it does not give enough context really.

Same with “backend: Add feature” should be disallowed.

Please add the areas you are changing, not just “backend:”. For example “backend: auth: Add new test for logging in”. This is because many changes are in backend, so it does not give enough context really.

This is because many changes are in frontend or backend, so it does not give context really.

Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all of that.

I resolved all those open conversations you had finished, and will look into it in more detail later.

Probably the commits could be squashed into one again.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch from 8ad3773 to 5d1d93a Compare December 29, 2025 19:21
Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I marked some more comments resolved.

Check out your commit messages… there should be a capitalized verb, and also you have a space before the : which should not be there.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch from 5955ab6 to cfa9417 Compare December 31, 2025 07:41
Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work.

Note in the git commits style we use the verb at the beginning should be “imperative mood” like Add. Not past tense like Added.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: dibyanshu-pal-kushwaha
Once this PR has been reviewed and has the lgtm label, please assign yolossn for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

with:
node-version: '20'
- name: Install dependencies
run: npm ci
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dibyanshu-pal-kushwaha The husky install command in the workflow seems to be failing , might be perhaps because the husky dependency was removed from frontend and readjusted in the root package.json.

The test plugin workflow failure is simpler to resolve, I think, by running the update-dependencies command.

👍🏼 Hope this helps

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 7, 2026
@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch from 00a216e to 7a4f3ce Compare January 9, 2026 13:24
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 9, 2026
frontend: tsconfig: Update tsconfig.json
@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch from 5187952 to 3e6a0fa Compare January 11, 2026 15:45
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 11, 2026
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 11, 2026
@illume illume requested a review from Copilot January 11, 2026 16:04
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 11 changed files in this pull request and generated 8 comments.

Files not reviewed (2)
  • frontend/package-lock.json: Language not supported
  • plugins/headlamp-plugin/template/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (!description) {
return [false, 'Description must not be empty'];
}
if (description[0] !== description[0].toUpperCase()) {
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation logic for the description starting with a capital letter checks description[0] !== description[0].toUpperCase() which would fail for descriptions starting with numbers or special characters. For example, "frontend: HomeButton: 123 items added" would incorrectly fail this check since '1'.toUpperCase() === '1'. Consider using a more specific check like /^[A-Z]/.test(description) to ensure the description starts with an uppercase letter.

Suggested change
if (description[0] !== description[0].toUpperCase()) {
if (!/^[A-Z]/.test(description)) {

Copilot uses AI. Check for mistakes.
"concurrently": "^8.2.2"
"concurrently": "^8.2.2",
"husky": "^4.3.8",
"@commitlint/cli": "^19.5.0"
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package.json includes @commitlint/cli but is missing @commitlint/config-conventional or a similar config package that commitlint typically depends on. While a custom configuration is defined in commitlint.config.js, having a base config package is often recommended for better maintainability. However, since this PR implements a completely custom rule, this might be intentional. Just ensure that the custom configuration covers all necessary validation rules.

Suggested change
"@commitlint/cli": "^19.5.0"
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0"

Copilot uses AI. Check for mistakes.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have defined our custom convention that is defined in the commit guidelines of the Headlamp.That's why we dont require it.

Comment on lines +30 to +32
`Commits starting with "${area}" must follow format: ` +
`<${area}>: <sub-area>: <description>\n` +
`Example: "${area}: HomeButton: Fix navigation"`,
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message for strict areas uses string concatenation that could be improved for readability. The multi-line string concatenation with + operators makes the code harder to read. Consider using template literals for cleaner formatting: `Commits starting with "${area}" must follow format: <${area}>: <sub-area>: <description>\nExample: "${area}: HomeButton: Fix navigation"`

Suggested change
`Commits starting with "${area}" must follow format: ` +
`<${area}>: <sub-area>: <description>\n` +
`Example: "${area}: HomeButton: Fix navigation"`,
`Commits starting with "${area}" must follow format: <${area}>: <sub-area>: <description>\nExample: "${area}: HomeButton: Fix navigation"`,

Copilot uses AI. Check for mistakes.
if (description[0] !== description[0].toUpperCase()) {
return [false, 'Description must start with a capitalized verb'];
}
return [true,''];
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a spacing issue in the return statement. The return statement has return [true,'']; with no space after the comma. For consistency with JavaScript formatting conventions, this should be return [true, '']; with a space after the comma.

Suggested change
return [true,''];
return [true, ''];

Copilot uses AI. Check for mistakes.
npm run lint:commit
```

This command check all commit messages that exist after origin/main against our guidelines. The same check runs in our CI system for every Pull Request.
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a grammatical error in the documentation. The sentence "This command check all commit messages" is missing the verb conjugation. It should be "This command checks all commit messages" with an 's' on 'checks'.

Suggested change
This command check all commit messages that exist after origin/main against our guidelines. The same check runs in our CI system for every Pull Request.
This command checks all commit messages that exist after origin/main against our guidelines. The same check runs in our CI system for every Pull Request.

Copilot uses AI. Check for mistakes.
Comment on lines +9 to +13
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GitHub Actions versions used in this workflow are outdated. actions/checkout@v2 and actions/setup-node@v2 are deprecated and should be updated to their latest major versions (actions/checkout@v4 and actions/setup-node@v4) to ensure continued support and access to the latest features and security updates.

Suggested change
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4

Copilot uses AI. Check for mistakes.
`Example: "${area}: HomeButton: Fix navigation"`,
];
}
const description = parts.length >= 3 ? parts[2] : parts[1];
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic that extracts the description has an issue. When there are 3 or more parts, it only takes parts[2] as the description, but commit messages could have multiple colons in the description itself (e.g., "frontend: Component: Add feature: new functionality"). In this case, only "Add feature" would be validated while "new functionality" would be ignored. Consider joining all parts after the required ones: const description = parts.length >= 3 ? parts.slice(2).join(': ') : parts[1];

Suggested change
const description = parts.length >= 3 ? parts[2] : parts[1];
const description = parts.length >= 3 ? parts.slice(2).join(': ') : parts[1];

Copilot uses AI. Check for mistakes.
'Commit message must follow format: <area>: <description>',
];
}
const [area, subOrDesc, desc] = parts;
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused variable desc.

Suggested change
const [area, subOrDesc, desc] = parts;
const [area, subOrDesc] = parts;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "lint:commit" to check commits follow our guidelines

4 participants