Skip to content

SRVOCF-946: Add Husky pre-commit hook#6

Merged
openshift-merge-bot[bot] merged 4 commits into
openshift:masterfrom
Cragsmann:SRVOCF-946--husky-pre-commit
Jun 24, 2026
Merged

SRVOCF-946: Add Husky pre-commit hook#6
openshift-merge-bot[bot] merged 4 commits into
openshift:masterfrom
Cragsmann:SRVOCF-946--husky-pre-commit

Conversation

@Cragsmann

@Cragsmann Cragsmann commented Jun 19, 2026

Copy link
Copy Markdown

Summary

  • Add Husky pre-commit hook that runs yarn lint:fix, tsc --noEmit, and go vet/gofmt on backend/
  • Add type-check and prepare scripts to package.json
  • Add skipLibCheck: true to tsconfig.json (prevents false positives from third-party type declarations)
  • Hooks auto-install on yarn install via the prepare script

Test plan

  • yarn lint:fix passes
  • yarn type-check passes
  • Go vet and gofmt pass on backend/
  • Pre-commit hook runs successfully end-to-end

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 19, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 19, 2026

Copy link
Copy Markdown

@Cragsmann: This pull request references SRVOCF-946 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Add Husky pre-commit hook that runs yarn lint:fix, tsc --noEmit, and go vet/gofmt on backend/
  • Add type-check and prepare scripts to package.json
  • Add skipLibCheck: true to tsconfig.json (prevents false positives from third-party type declarations)
  • Hooks auto-install on yarn install via the prepare script

Test plan

  • yarn lint:fix passes
  • yarn type-check passes
  • Go vet and gofmt pass on backend/
  • Pre-commit hook runs successfully end-to-end

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot requested review from TheRealJon and logonoff June 19, 2026 12:17
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 19, 2026
@matejvasek

Copy link
Copy Markdown

Have you used our commit message standard as Stas requested on original PR?

@matejvasek

Copy link
Copy Markdown

Commit message of b390478 doesn't say much.
The commit message should describe what and why was done. Yes there is a Jira issue linked but git should work even if Jira was deleted tomorrow.

@matejvasek matejvasek left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please improve commit message.

Without local checks, lint errors, type failures, and unformatted
Go code only surface in CI or code review. This adds a Husky
pre-commit hook that catches these before they leave the
developer's machine.

The hook runs three checks in sequence, failing fast on the first
error: eslint/stylelint via "yarn lint:fix", TypeScript type-check
via "tsc --noEmit", and Go vet/gofmt on the backend directory.

Also adds skipLibCheck to tsconfig.json to avoid type errors from
third-party declaration files during the new type-check step.

Co-Authored-By: Claude <noreply@anthropic.com>
@Cragsmann Cragsmann force-pushed the SRVOCF-946--husky-pre-commit branch from b390478 to 4315f56 Compare June 23, 2026 10:53
@Cragsmann

Copy link
Copy Markdown
Author

Please improve commit message.

updated commit message

@Cragsmann Cragsmann requested a review from matejvasek June 23, 2026 10:55
Comment thread .husky/pre-commit Outdated
@matejvasek

Copy link
Copy Markdown

Where is commit-msg ?

@dsimansk

Copy link
Copy Markdown

Add commit-msg hook for conventional commits validation (type prefix, 50 char limit)

I wonder if this validation won't prevent us/claude from creating verbose commit messages.

lint:fix modifies files on disk but the changes are not
automatically re-staged. The commit would contain the unfixed
version while the fix is left as an unstaged working tree change.

Plain lint fails fast and lets the developer fix and re-stage
intentionally.

Co-Authored-By: Claude <noreply@anthropic.com>
@Cragsmann Cragsmann requested a review from matejvasek June 23, 2026 12:21
@matejvasek

Copy link
Copy Markdown

Add commit-msg hook for conventional commits validation (type prefix, 50 char limit)

I wonder if this validation won't prevent us/claude from creating verbose commit messages.

Isn't that only for the "title/first line"? The rest of the message can be pretty descriptive still.

@matejvasek

Copy link
Copy Markdown

Is Commit-msg in this PR?

@Cragsmann

Cragsmann commented Jun 24, 2026

Copy link
Copy Markdown
Author

Is Commit-msg in this PR?

It will be in the follow up PR #10

@logonoff

Copy link
Copy Markdown
Member

/uncc

@openshift-ci openshift-ci Bot removed the request for review from logonoff June 24, 2026 11:33
Comment thread .husky/pre-commit Outdated
Comment thread .husky/pre-commit
Without set -e, failures from yarn lint, yarn type-check, and
go vet were silently ignored. The hook would exit 0 and allow
the commit through. Also deduplicates the gofmt call and
switches shebang to bash for pipefail compatibility.

Co-Authored-By: Claude <noreply@anthropic.com>
@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 24, 2026
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 24, 2026
@matejvasek

Copy link
Copy Markdown

/lgtm

@Cragsmann Cragsmann requested a review from matejvasek June 24, 2026 13:51
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 24, 2026
@openshift-ci

openshift-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cragsmann, matejvasek

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [Cragsmann,matejvasek]

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

@openshift-ci

openshift-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Cragsmann: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot Bot merged commit e66dc44 into openshift:master Jun 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants