-
Notifications
You must be signed in to change notification settings - Fork 0
chore: add lint-staged with pre-commit hooks for src/ directory #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add husky (9.1.7) and lint-staged (16.2.3) dependencies
- Configure lint-staged to run eslint and prettier on src/**/*.{ts,tsx} files
- Add pre-commit hook to run lint-staged
- Add post-checkout hook to run yarn install
- Add pre-push hook to prevent direct pushes to main
- Add .venv to .prettierignore to fix lint:check
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
⚙️ Control Options:
|
📝 WalkthroughWalkthroughAdds Husky integration: a Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer
participant Git as Git
participant Husky as Husky Hooks
participant LStaged as lint-staged
participant JLPM as jlpm
rect rgb(235, 245, 255)
note over Dev,Git: Checkout flow
Dev->>Git: git checkout <branch>
Git->>Husky: trigger post-checkout
Husky->>JLPM: jlpm install
end
rect rgb(240, 255, 240)
note over Dev,Git: Commit flow
Dev->>Git: git commit
Git->>Husky: trigger pre-commit
Husky->>LStaged: jlpm lint-staged (run linters/formatters on staged TS files)
LStaged-->>Husky: exit code
Husky-->>Git: allow/deny commit
end
rect rgb(255, 245, 235)
note over Dev,Git: Push flow
Dev->>Git: git push
Git->>Husky: trigger pre-push
Husky->>Husky: read current branch
alt branch is "main"
Husky-->>Git: exit 1 (block push)
else other branch
Husky-->>Git: exit 0 (allow push)
end
end
Possibly related PRs
Suggested reviewers
Pre-merge checks✅ Passed checks (3 passed)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #18 +/- ##
=======================================
Coverage 18.50% 18.50%
=======================================
Files 13 13
Lines 200 200
Branches 27 27
=======================================
Hits 37 37
Misses 163 163 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Update pre-commit hook to use 'jlpm exec lint-staged' - Update post-checkout hook to use 'jlpm install' - Aligns with jupyterlab-deepnote's package manager setup
03048b0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (2)
.husky/post-checkout(1 hunks).husky/pre-commit(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-30T13:34:45.847Z
Learnt from: jamesbhobbs
PR: deepnote/deepnote#1
File: .husky/post-checkout:1-1
Timestamp: 2025-09-30T13:34:45.847Z
Learning: In the deepnote/deepnote repository, the .husky/post-checkout hook should remain minimal (just `pnpm install`) without explicit flags like `--frozen-lockfile` or guards. Explicit flags should only be used where needed, such as in CI workflows.
Applied to files:
.husky/post-checkout
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: check_release
- GitHub Check: build
🔇 Additional comments (1)
.husky/post-checkout (1)
1-1: Performance impact on frequent checkouts.Running install on every checkout (branch switch, pull, etc.) may slow down developer workflow, especially when dependencies haven't changed. Based on learnings, keeping the hook minimal is preferred.
Consider monitoring the performance impact in practice. If slowdowns occur, users can selectively bypass with
--no-verifyon checkouts or consider conditional execution based on package file changes.
The packageManager field was automatically added by yarn during initial development but should not be present since jupyterlab-deepnote uses jlpm (JupyterLab's yarn wrapper) for package management.
Add lint-staged configuration with pre-commit hooks for src/ directory
Summary
This PR adds lint-staged configuration to automatically format and lint TypeScript files in the
src/directory on pre-commit. This is the first of two PRs to sync code quality tooling with the main deepnote/deepnote repository.Key changes:
husky(9.1.7) andlint-staged(16.2.3) dependencies matching deepnote/deepnote versionseslint --cache --fixandprettier --writeonsrc/**/*.{ts,tsx}files onlypre-commit: runs lint-staged on staged filespost-checkout: runsjlpm installto keep dependencies in syncpre-push: blocks direct pushes to main branch.venvto.prettierignoreto prevent prettier from checking Python virtual environment filesReview & Testing Checklist for Human
.tsfile insrc/, stage it, and verify the hook runs eslint and prettier automatically on commitjlpm exec lint-stagedworks in git hook context (the CodeRabbit bot raised a concern about this)src/directory and ignores other TypeScript files in the project rootNotes
Link to Devin run: https://app.devin.ai/sessions/145f89c8cbc942d2970c5bc43a90149c
Requested by: @jamesbhobbs