Skip to content

Add pre-commit linting for staged UI files (Husky + lint-staged)#14

Merged
siarheirazuvalau merged 3 commits into
developfrom
bugfix/lint-files-on-commit
May 22, 2026
Merged

Add pre-commit linting for staged UI files (Husky + lint-staged)#14
siarheirazuvalau merged 3 commits into
developfrom
bugfix/lint-files-on-commit

Conversation

@siarheirazuvalau

@siarheirazuvalau siarheirazuvalau commented May 21, 2026

Copy link
Copy Markdown
Contributor

##Summary

Enable ESLint and Stylelint on staged TypeScript and SCSS files via Husky pre-commit hooks.

Summary by CodeRabbit

  • Chores
    • Added automated code quality checks during the commit process.
    • Updated code quality automation configuration for TypeScript files.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 21, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@siarheirazuvalau has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 53 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8f068f14-62a9-48da-893f-f6c984b373b8

📥 Commits

Reviewing files that changed from the base of the PR and between 076255b and 9986592.

📒 Files selected for processing (1)
  • ui/package.json

Walkthrough

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

Changes

Husky Git Hooks and Linting Setup

Layer / File(s) Summary
Husky initialization and lint-staged configuration
ui/package.json
prepare script installs Husky from the parent directory. The lint-staged rule for TypeScript files is updated to run only eslint --fix, removing the previous git add step.
Pre-commit linting hook
.husky/pre-commit
New hook script that navigates to the ui directory and runs npx lint-staged to lint staged files before each commit.
Post-commit index refresh hook
.husky/post-commit
New hook script that runs git update-index --again after commits to refresh the index state.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hops through hooks so grand,
Pre-commit lints, with steady hand,
Post-commit cleans the index bright,
Husky guards the code's delight! 🐰✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding pre-commit linting for UI files using Husky and lint-staged, which aligns with all file modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/lint-files-on-commit

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
ui/package.json (1)

15-15: 💤 Low value

Husky prepare script will fail when installing from a published tarball or outside the monorepo.

cd .. && husky install assumes the package is always installed from inside the repo with the parent directory being the git root. If ui/ is ever consumed as a standalone package (e.g., via npm install from a registry or in CI where only ui/ is checked out), cd .. will resolve to an unrelated directory and husky install will either fail or install hooks in the wrong place. Consider guarding with an is-ci check or only running when a .git directory exists in the parent.

Also note: husky install is the v7/v8 API. Husky v9 replaced it with just husky, and v10 will remove install entirely. Since husky is 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

📥 Commits

Reviewing files that changed from the base of the PR and between caaca0f and 076255b.

📒 Files selected for processing (3)
  • .husky/post-commit
  • .husky/pre-commit
  • ui/package.json

Comment thread .husky/post-commit Outdated
@siarheirazuvalau siarheirazuvalau merged commit 712da88 into develop May 22, 2026
3 checks passed
@siarheirazuvalau siarheirazuvalau deleted the bugfix/lint-files-on-commit branch May 22, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants