Skip to content

Conversation

@zi0w
Copy link

@zi0w zi0w commented Jan 25, 2026

Summary

Fixes #2034

Adds an opt-in Git pre-commit hook that runs lint auto-fix (lint:fix or lint -- --fix) for only the packages touched in staged changes.
Also documents how to enable it via core.hooksPath in the maintainer’s guide.

Requirements (place an x in each [ ])

Changes

  • Add .githooks/pre-commit (opt-in): runs package-level lint auto-fix for staged changes only
  • Update .github/maintainers_guide.md: document how to enable the hook

Test plan

  1. Enable hook: git config core.hooksPath .githooks
  2. Modify a file under packages//... and stage it
  3. Run git commit and confirm the hook runs lint auto-fix and the commit succeeds.
test-image

@zi0w zi0w requested a review from a team as a code owner January 25, 2026 13:07
@salesforce-cla
Copy link

Thanks for the contribution! Before we can merge this, we need @zi0w to sign the Salesforce Inc. Contributor License Agreement.

@zi0w
Copy link
Author

zi0w commented Jan 25, 2026

I’ve signed the Salesforce CLA.
When you have a moment, could a maintainer approve the workflow run for this PR?

@codecov
Copy link

codecov bot commented Jan 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.09%. Comparing base (a1112e3) to head (c0d8de3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2475   +/-   ##
=======================================
  Coverage   93.09%   93.09%           
=======================================
  Files          40       40           
  Lines       11240    11240           
  Branches      713      713           
=======================================
  Hits        10464    10464           
  Misses        764      764           
  Partials       12       12           
Flag Coverage Δ
cli-hooks 95.23% <ø> (ø)
cli-test 94.79% <ø> (ø)
oauth 77.39% <ø> (ø)
socket-mode 61.87% <ø> (ø)
web-api 98.11% <ø> (ø)
webhook 96.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@hello-ashleyintech hello-ashleyintech self-requested a review January 26, 2026 18:42
@hello-ashleyintech
Copy link
Contributor

hi, @zi0w! Thank you so much for the contribution. I have run the workflow run for this PR, and it looks like there are a few failing tests across Node versions 18, 20, and 22 for the logger, web-api, and cli-test packages. Could you take a look at these failures at your earliest convenience?

Also, please confirm that you have signed the CLA using the same email and GitHub account as the one you've submitted the PR for - it looks like that check failed as well, so just want to verify whether I need to close or re-open the PR if this is reporting a false result.

@@ -0,0 +1,54 @@
#!/bin/sh
set -e
Copy link
Contributor

Choose a reason for hiding this comment

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

this implementation is very complex - is there a way we could simplify this?

@zi0w
Copy link
Author

zi0w commented Jan 27, 2026

Hi @hello-ashleyintech — thanks for running the workflows!

CLA: I already signed the Salesforce CLA using the same email/account as this PR, but it still shows cla:missing. Do you know if there’s a way for me to retry or trigger a re-check, or anything else I should do to resolve it?

CI failures: I’m looking into the Windows failures (Node 18/20/22) for logger, web-api, and cli-test now. I’ll review the logs and push an update once I find the cause.

Hook complexity: Agreed it’s a bit heavy. I’ll simplify the hook logic while keeping the same behavior (only run for staged packages/ changes + auto-fix + re-stage) and include that in the next commit.

@zi0w
Copy link
Author

zi0w commented Jan 27, 2026

Hi, @hello-ashleyintech!

Quick update:

CLA: Looks like the CLA check is now passing after the latest commit — thank you!

Hook complexity: I simplified the pre-commit hook to reduce parsing/branching while keeping the behavior the same. It derives the touched packages/ from staged files, runs lint:fix when available (otherwise falls back to lint -- --fix), and re-stages any auto-fixes. I also adjusted it so the lint output is visible during commits to make local verification/debugging easier.

CI failures: The Windows jobs were failing very quickly (~a few seconds) with the same message:
##[error]Could not find a part of the path 'D:\a'.
Given how quickly it fails and that the message points to the workspace path, this might be related to the GitHub Actions runner/workflow environment rather than the changes in this PR — but I don’t want to assume. Would you mind re-running the workflow once to see if it reproduces? If it still fails, I’ll revisit it based on the rerun result and we can figure out the next best step.

Thanks again for taking a look!

@hello-ashleyintech
Copy link
Contributor

@zi0w I have closed and re-opened the PR to bump the CLA check, and it looks like it's now working. I will now approve the workflows to run!

@zimeg
Copy link
Member

zimeg commented Jan 27, 2026

👋 #2478 might make adjacent changes related to linting in a monorepo. FWIW I'm not familiar with pre lint hooks-

@zi0w
Copy link
Author

zi0w commented Jan 28, 2026

Hi @zimeg — thanks for the heads-up!

Yep, this PR is an opt-in pre-commit hook that runs lint --write (via each package’s lint:fix / lint -- --fix) only for staged changes, and re-stages any auto-fixes. It shouldn’t change CI behavior directly, but I agree it’s adjacent to monorepo linting/workspace changes like #2478.

If there’s anything you’d like me to align with (e.g., preferred package detection or how lint commands should be invoked in the monorepo), I’m happy to adjust.

@zi0w
Copy link
Author

zi0w commented Jan 28, 2026

Hi @hello-ashleyintech — CLA check is now passing and all CI checks are green.

I also simplified the opt-in pre-commit hook while keeping the same behavior (lint:fix → fallback to lint -- --fix, then re-stage).
When you have a moment, would you be able to take a look / review the latest changes?

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

monorepo: add a linter --write precommit hook

3 participants