Skip to content

Adding lint commit and husky to root configuration#4311

Open
dibyanshu-pal-kushwaha wants to merge 1 commit intokubernetes-sigs:mainfrom
dibyanshu-pal-kushwaha:adding-lint-commit-and-husky-to-root-configuration
Open

Adding lint commit and husky to root configuration#4311
dibyanshu-pal-kushwaha wants to merge 1 commit intokubernetes-sigs:mainfrom
dibyanshu-pal-kushwaha:adding-lint-commit-and-husky-to-root-configuration

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 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 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 succeed.

@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.

  • ✅ login: dibyanshu-pal-kushwaha / name: Dibyanshu Pal Kushwaha (35de70e)

@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.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 1, 2026
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 rebase against main to get rid of the merge commits?

@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch 2 times, most recently from 044bd4b to 7458fc0 Compare February 3, 2026 05:44
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 3, 2026
@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch 2 times, most recently from 6aa27bc to 3b300fc Compare February 3, 2026 05:59
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 3, 2026
@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch 2 times, most recently from 5fe2c9e to 42c58c9 Compare February 3, 2026 06:04
@dibyanshu-pal-kushwaha
Copy link
Author

@illume , Please review it , I have rebased it and now it is merge conflict free.

@illume
Copy link
Contributor

illume commented Feb 8, 2026

Thanks for that change.

Can you please ask in the headlamp kubernetes slack channel for someone else to review and test this?

@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch from 42c58c9 to aac9f67 Compare February 9, 2026 06:37
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2026
@M-DEV-1
Copy link

M-DEV-1 commented Feb 9, 2026

@dibyanshu-pal-kushwaha can anything be done about the failing tests? or are they due to some other change (not related to this PR)?

@dibyanshu-pal-kushwaha
Copy link
Author

I am working over it , trying to solve.

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2026
@dibyanshu-pal-kushwaha
Copy link
Author

dibyanshu-pal-kushwaha commented Feb 9, 2026

@M-DEV-1 I fixed the changes, run the frontend test locally , and other tests, too, it worked. Please have a look and help me if anything , I missed.

@illume
Copy link
Contributor

illume commented Feb 9, 2026

The frontend/src/lib/k8s/api/v2/multiplexer.ts change should be removed from here into to a separate PR.

Please always check the commits locally (no merge commits), you can you please rebase against main to get rid of the merge commits? Also, please always check the other things locally first (npm run format for example).

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.

Left some notes of things to tidy up.

@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch from 7a63132 to 0fb4ff1 Compare February 13, 2026 15:55
@dibyanshu-pal-kushwaha dibyanshu-pal-kushwaha force-pushed the adding-lint-commit-and-husky-to-root-configuration branch from 0fb4ff1 to 35de70e Compare February 13, 2026 16:04
@illume
Copy link
Contributor

illume commented Feb 14, 2026

Cool, looks like it's passing the Github checks now. Thanks for tidying up those things.

I will test it out in the coming days.

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