Add pre-commit linting for staged UI files (Husky + lint-staged)#14
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThis PR establishes a complete Husky-based git hook workflow. It adds two Husky hook scripts (pre-commit and post-commit), updates the npm prepare script to install Husky, and simplifies the lint-staged configuration to remove redundant git staging commands. ChangesHusky Git Hooks and Linting Setup
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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: 1
🧹 Nitpick comments (1)
ui/package.json (1)
15-15: 💤 Low valueHusky
preparescript will fail when installing from a published tarball or outside the monorepo.
cd .. && husky installassumes the package is always installed from inside the repo with the parent directory being the git root. Ifui/is ever consumed as a standalone package (e.g., vianpm installfrom a registry or in CI where onlyui/is checked out),cd ..will resolve to an unrelated directory andhusky installwill either fail or install hooks in the wrong place. Consider guarding with anis-cicheck or only running when a.gitdirectory exists in the parent.Also note:
husky installis the v7/v8 API. Husky v9 replaced it with justhusky, and v10 will removeinstallentirely. Sincehuskyis pinned to^7.0.4, this is fine today, but worth flagging if you plan to upgrade.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ui/package.json` at line 15, The prepare script ("prepare" in package.json) runs `cd .. && husky install` unconditionally which breaks when ui/ is installed standalone; change it to run husky install only when the parent repo is a git repo or in a developer environment (e.g., test for the existence of ../.git or guard with a CI check like the CI/GITHUB_ACTIONS env var) so it no-ops for tarball/registry installs; ensure the script still invokes `husky install` (the current v7 API) only when the git check passes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.husky/post-commit:
- Around line 1-2: Confirm whether the post-commit hook's use of git
update-index --again is intentional; if lint-staged v10+ is in use (which
already re-stages fixed files) remove the hook as redundant, otherwise add a
clear comment above the git update-index --again explaining the specific
edge-case it addresses (e.g., older lint-staged versions or a known tool that
modifies files after commit) and note that it does not amend the just-made
commit but only updates the index for subsequent commits; if this behavior must
be preserved, consider documenting the required lint-staged/tool versions and
rationale in the hook.
---
Nitpick comments:
In `@ui/package.json`:
- Line 15: The prepare script ("prepare" in package.json) runs `cd .. && husky
install` unconditionally which breaks when ui/ is installed standalone; change
it to run husky install only when the parent repo is a git repo or in a
developer environment (e.g., test for the existence of ../.git or guard with a
CI check like the CI/GITHUB_ACTIONS env var) so it no-ops for tarball/registry
installs; ensure the script still invokes `husky install` (the current v7 API)
only when the git check passes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 65fbfb92-e1b8-4500-8c57-765e33be0ae4
📒 Files selected for processing (3)
.husky/post-commit.husky/pre-commitui/package.json
##Summary
Enable ESLint and Stylelint on staged TypeScript and SCSS files via Husky pre-commit hooks.
Summary by CodeRabbit