Skip to content

chore: add husky pre-commit hook and configure lint-staged for code formatting#48

Merged
sonmessia merged 1 commit intomainfrom
chore/add-husky-precommit
Dec 7, 2025
Merged

chore: add husky pre-commit hook and configure lint-staged for code formatting#48
sonmessia merged 1 commit intomainfrom
chore/add-husky-precommit

Conversation

@sonmessia
Copy link
Copy Markdown
Owner

@sonmessia sonmessia commented Dec 7, 2025

Proposed changes

Add husky pre-commit hook
Types of changes

  • 🐛 Bug fix (non-breaking change which fixes an issue)

  • ✨ Feature (non-breaking change which adds functionality)

  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)

  • 📝 Docs (documentation only changes)

  • ♻️ Refactor (code improvement without changing functionality)

Checklist

  • Docker build successful (src/backend)

  • All tests passing (pytest)

  • Code follows project standards (Black, Ruff, MyPy)

  • Service boundaries maintained

  • .env.example updated (if environment variables changed)

  • No debug print statements left

Copilot AI review requested due to automatic review settings December 7, 2025 09:47
@sonmessia sonmessia merged commit 3d30161 into main Dec 7, 2025
5 of 6 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds Husky pre-commit hooks and configures lint-staged to automatically format code before commits. It sets up automated code quality checks for both the Python backend (using Black and Ruff) and the TypeScript/JavaScript frontend (using ESLint).

Key changes:

  • Adds Husky v9 and lint-staged v15 as development dependencies
  • Configures lint-staged to run Black and Ruff on Python files, and ESLint on frontend files
  • Creates a pre-commit hook that triggers lint-staged

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
package.json Defines root-level dependencies for Husky and lint-staged, and configures lint-staged patterns for backend and frontend files
package-lock.json Lockfile with all dependency versions and integrity hashes for Husky, lint-staged, and their transitive dependencies
.husky/pre-commit Pre-commit hook script that executes lint-staged on staged files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
"ruff check --fix"
],
"src/frontend/**/*.{ts,tsx,js,jsx}": [
"bash -c 'cd src/frontend && npx eslint --fix ${0}'"
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

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

The bash command for ESLint will not work correctly. When lint-staged passes file paths to this command, they will be passed as arguments (e.g., bash -c '...' arg1 arg2 arg3), but ${0} refers to the script name/path, not the arguments.

Additionally, since the command changes directory to src/frontend but receives file paths relative to the repository root (e.g., src/frontend/src/App.tsx), the paths won't resolve correctly.

Recommended fix - replace line 17 with:

"eslint --fix"

This will work because lint-staged will execute this command from within src/frontend directory when the glob pattern matches, and eslint will receive the correct relative file paths.

Suggested change
"bash -c 'cd src/frontend && npx eslint --fix ${0}'"
"eslint --fix"

Copilot uses AI. Check for mistakes.
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