Skip to content

Optimise pre-commit hook#15

Merged
mlanlazc merged 2 commits intomainfrom
milan/chore/optimise-pre-commit-hook
Jul 31, 2025
Merged

Optimise pre-commit hook#15
mlanlazc merged 2 commits intomainfrom
milan/chore/optimise-pre-commit-hook

Conversation

@mlanlazc
Copy link
Contributor

  • Add lint-staged to check only staged file instead of the whole codebase
  • pre-commit hook will now automatically fix autofixable eslint and prettier issues
  • optimise typecheck command:
    • --noEmit: Skips generating JavaScript output files, only does type checking
    • --skipLibCheck: Skips type checking of library declaration files (.d.ts files), which can be a significant time saver

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @mlanlazc, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've implemented several optimizations to the pre-commit hook to enhance developer experience and efficiency. The primary goal is to make the pre-commit checks faster and more focused by leveraging lint-staged to process only staged files, alongside improvements to the TypeScript type-checking process. Additionally, I've adjusted an environment variable related to storage types.

Highlights

  • Optimized Pre-Commit Hook: Switched from checking the entire codebase to only staged files using lint-staged, drastically speeding up commit checks.
  • Automated Code Formatting & Linting: The pre-commit hook now automatically fixes autofixable ESLint and Prettier issues, reducing manual intervention.
  • Faster TypeScript Type Checking: The typecheck command has been optimized with --noEmit and --skipLibCheck flags, accelerating the type-checking process during development.
  • Environment Variable Adjustment: The STORAGE_TYPE environment variable in app/env/server.ts has been restricted to only FILE_SYSTEM, removing the DATABASE option.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@mlanlazc mlanlazc force-pushed the milan/chore/optimise-pre-commit-hook branch from c414a9e to a6dde6a Compare July 31, 2025 11:58
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request significantly improves the pre-commit hook by introducing lint-staged to lint and format only staged files, and by optimizing the typecheck command. This will speed up the commit process for developers. I have one suggestion to further enhance the performance of the pre-commit hook by making the type check conditional.

Comment on lines 24 to 30
# Run typecheck (still needed for full project context)
echo "Running TypeScript typecheck..."
if ! pnpm typecheck; then
echo "❌ TypeScript type checking failed! Please review type errors."
echo "Once you're done, don't forget to add your changes to the commit! 🚀"
exit 1
fi
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While the optimizations to the typecheck command are great, the pre-commit hook still runs pnpm typecheck on every commit, regardless of which files were changed. This can be inefficient, for example when only documentation files are being committed.

To further optimize the hook, you could make the typecheck step conditional, so it only runs when TypeScript files (.ts or .tsx) are part of the staged changes.

# Run typecheck only if there are staged TypeScript files
if git diff --cached --name-only --diff-filter=ACM | grep -q -E '\.(ts|tsx)$'; then
  echo "Running TypeScript typecheck..."
  if ! pnpm typecheck; then
      echo "❌ TypeScript type checking failed! Please review type errors."
      echo "Once you're done, don't forget to add your changes to the commit! 🚀"
      exit 1
  fi
fi

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tested, it works, bravo Gemini 👏

@mlanlazc mlanlazc merged commit 31148c6 into main Jul 31, 2025
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.

2 participants