Skip to content

husky and lint-staged#477

Merged
ritik4ever merged 2 commits into
ritik4ever:mainfrom
Jumongweb:main
May 28, 2026
Merged

husky and lint-staged#477
ritik4ever merged 2 commits into
ritik4ever:mainfrom
Jumongweb:main

Conversation

@Jumongweb
Copy link
Copy Markdown

@Jumongweb Jumongweb commented May 26, 2026

Closes #421
Implemented the Husky + lint-staged pre-commit flow.
Changed:
Added prepare: "husky" and lint-staged config in package.json (line 14)
Added Husky hook at .husky/pre-commit (line 1)
Added ESLint flat config for .ts/.tsx in eslint.config.mjs (line 1)
Added Prettier config in .prettierrc (line 1)
Documented setup, hook behavior, and WSL2 workflow in CONTRIBUTING.md (line 14)
Updated package-lock.json and yarn.lock with the new dev tooling
Verified:
npm run prepare installed Husky hooks
.husky/_/pre-commit runs lint-staged successfully
npx lint-staged --allow-empty exits cleanly with no staged files
A staged .ts file with an unfixable ESLint error blocked the commit path as expected

Summary by CodeRabbit

  • Documentation

    • Enhanced contribution guidelines with expanded development setup instructions, pre-commit check details, WSL2 guidance, and snapshot testing procedures.
  • Chores

    • Implemented automated code quality checks with linting and formatting enforcement.
    • Updated development dependencies and configurations.

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

@Jumongweb is attempting to deploy a commit to the ritik4ever's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 26, 2026

@Jumongweb Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Warning

Review limit reached

@ritik4ever, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 56 minutes and 40 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7b7ffa12-98f6-4f45-ba17-2c08907f280d

📥 Commits

Reviewing files that changed from the base of the PR and between fa01f5c and 0d3f0a0.

📒 Files selected for processing (2)
  • CONTRIBUTING.md
  • package.json
📝 Walkthrough

Walkthrough

This PR establishes automated code quality infrastructure by adding ESLint and Prettier configuration, integrating Husky with lint-staged to enforce linting on staged changes, and expanding developer documentation with setup instructions and pre-commit behavior guidance.

Changes

Pre-commit linting and code quality infrastructure

Layer / File(s) Summary
ESLint and Prettier configuration
eslint.config.mjs, .prettierrc
ESLint flat config ignores build artifacts and applies recommended rules from @eslint/js and typescript-eslint, with TypeScript-specific overrides for .ts/.tsx files (latest ECMAScript, combined browser/ES2024/Node globals, custom unused-variable handling). Prettier enforces single quotes and trailing commas.
Husky and lint-staged wiring
package.json, .husky/pre-commit
package.json adds prepare script for Husky installation, lint-staged config to run ESLint (--fix) and Prettier on staged TypeScript files, and devDependencies for Husky, lint-staged, ESLint, Prettier, and TypeScript tooling. .husky/pre-commit hook invokes npx lint-staged.
Developer setup and pre-commit documentation
CONTRIBUTING.md
Development environment setup instructions updated with separate root install, Git hook preparation, and backend/frontend dev commands. New pre-commit checks section explains Husky/lint-staged execution and error handling. Added WSL2-specific workflow and expanded testing documentation with snapshot testing details.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • The changes directly address the objectives of issue #421 (Add pre-commit hooks with Husky and lint-staged): Husky is installed via the prepare npm script, lint-staged runs ESLint and Prettier on .ts/.tsx files, commits are blocked on unfixable lint errors, and WSL2 compatibility is documented in CONTRIBUTING.md.

Poem

🐰 A rabbit hops through staged commits bright,
With ESLint and Prettier set just right,
Husky guards the code with pre-commit care,
No sloppy diffs shall ever pass through there!
Clean formatting blooms—a developer'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 'husky and lint-staged' directly reflects the main changes in the PR, which add these two tools for pre-commit linting and formatting.
Linked Issues check ✅ Passed The PR meets all acceptance criteria from issue #421: husky install configured as prepare script, lint-staged runs ESLint+Prettier on .ts/.tsx files, commits blocked on unfixable errors, and WSL2 workflow documented in CONTRIBUTING.md.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing pre-commit hooks with Husky and lint-staged as specified in issue #421; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/pre-commit:
- Line 1: Add a shebang as the very first line of the pre-commit script so the
shell is explicit (e.g. use /usr/bin/env bash), keeping the existing npx
lint-staged invocation intact; ensure the pre-commit script remains executable
(chmod +x) after the change so Husky and other environments run it reliably.

In `@package.json`:
- Around line 27-29: Update package.json dependencies: change the "lint-staged"
version from "^16.4.0" to "^17.0.5" so the project can pick up the latest 17.x
release; while here double-check that "globals" ("globals": "^17.6.0") and
"husky" ("husky": "^9.1.7") are intentionally set to those stable versions and
update them only if you want newer releases—modify the version strings for
"lint-staged", "globals", or "husky" in package.json accordingly and run
npm/yarn install to verify no breakages.
🪄 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: a849c172-d460-49b0-9cf1-c708feb2d781

📥 Commits

Reviewing files that changed from the base of the PR and between 946b9af and fa01f5c.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (5)
  • .husky/pre-commit
  • .prettierrc
  • CONTRIBUTING.md
  • eslint.config.mjs
  • package.json

Comment thread .husky/pre-commit
@@ -0,0 +1 @@
npx lint-staged
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add a shebang line for better portability.

The pre-commit hook script is missing a shebang line. While Husky may handle this automatically in some cases, including an explicit shebang ensures the script executes correctly across different environments.

🔧 Proposed fix to add shebang
+#!/bin/sh
 npx lint-staged
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
npx lint-staged
#!/bin/sh
npx lint-staged
🤖 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 @.husky/pre-commit at line 1, Add a shebang as the very first line of the
pre-commit script so the shell is explicit (e.g. use /usr/bin/env bash), keeping
the existing npx lint-staged invocation intact; ensure the pre-commit script
remains executable (chmod +x) after the change so Husky and other environments
run it reliably.

Comment thread package.json Outdated
Comment on lines +27 to +29
"globals": "^17.6.0",
"husky": "^9.1.7",
"lint-staged": "^16.4.0",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

What are the latest stable versions of globals, husky, and lint-staged npm packages as of May 2026?

💡 Result:

Latest stable versions as of 2026-05-26: 1) globals: 17.6.0 [1][2] 2) husky: 9.1.7 [3] 3) lint-staged: 17.0.5 [4][5] Notes: “Latest stable” here is taken as the latest published version shown on each package’s npm page / registry record (i.e., the top of version history). [1][3][5]

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
base="https://registry.npmjs.org"
for pkg_ver in \
  "globals@17.6.0" \
  "husky@9.1.7" \
  "lint-staged@16.4.0"
do
  pkg="${pkg_ver%@*}"
  ver="${pkg_ver#*@}"
  echo "== $pkg@$ver =="
  # If the version exists, the registry returns JSON; otherwise 404.
  curl -sS -o "/tmp/${pkg}_${ver}.json" -w "%{http_code}\n" \
    "$base/$pkg/$ver" | tail -n 1
  if [[ "$(cat "/tmp/${pkg}_${ver}.json" | head -c 1)" == "{" ]]; then
    # Extract version field if present
    node -e "const fs=require('fs'); const j=JSON.parse(fs.readFileSync('/tmp/${pkg}_${ver}.json','utf8')); console.log(j.version||'no version field')"
  else
    echo "No JSON returned"
  fi
done

Repository: ritik4ever/stellar-stream

Length of output: 165


Update lint-staged and re-check the other two versions in package.json

  • globals@^17.6.0 (17.6.0) and husky@^9.1.7 (9.1.7) resolve to published stable versions.
  • lint-staged@^16.4.0 (16.4.0) is valid, but the latest stable is 17.0.5; ^16.4.0 will not pick up 17.x, so bump to ^17.0.5 to stay current.
🤖 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 `@package.json` around lines 27 - 29, Update package.json dependencies: change
the "lint-staged" version from "^16.4.0" to "^17.0.5" so the project can pick up
the latest 17.x release; while here double-check that "globals" ("globals":
"^17.6.0") and "husky" ("husky": "^9.1.7") are intentionally set to those stable
versions and update them only if you want newer releases—modify the version
strings for "lint-staged", "globals", or "husky" in package.json accordingly and
run npm/yarn install to verify no breakages.

@ritik4ever ritik4ever merged commit 77687e5 into ritik4ever:main May 28, 2026
2 of 3 checks passed
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.

Add pre-commit hooks with Husky and lint-staged

2 participants