Skip to content

Add linting hook before push#2278

Merged
jcstein merged 1 commit intodocs-glow-upfrom
gb/add-git-hook
Oct 27, 2025
Merged

Add linting hook before push#2278
jcstein merged 1 commit intodocs-glow-upfrom
gb/add-git-hook

Conversation

@gbarros
Copy link
Copy Markdown
Contributor

@gbarros gbarros commented Oct 27, 2025

image

@gbarros gbarros requested review from Copilot and jcstein October 27, 2025 20:45
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @gbarros, 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!

This pull request enhances the development workflow by implementing a pre-push Git hook. This hook leverages the simple-git-hooks package to automatically execute the project's linting process before any code is pushed. The primary goal is to maintain high code quality and prevent common linting errors from being committed to the main branches, thereby streamlining code reviews and improving overall project stability.

Highlights

  • Pre-push Git Hook: A new pre-push Git hook has been introduced to automatically run linting checks before code is pushed to the remote repository.
  • simple-git-hooks Integration: The simple-git-hooks package has been added as a development dependency and configured to manage the Git hooks, specifically the pre-push hook.
  • Automated Linting: The pre-push hook is configured to execute npm run lint, ensuring that all code adheres to defined linting standards before being pushed.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

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 a pre-push Git hook to run linting before code is pushed to the repository. The implementation uses simple-git-hooks to manage the Git hook installation and configuration.

Key Changes:

  • Added simple-git-hooks package and configured it to run linting on pre-push
  • Created a pre-push hook script with skip mechanisms for CI/CD environments
  • Added a prepare script to automatically install Git hooks after npm install

Reviewed Changes

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

File Description
package.json Added simple-git-hooks dependency, configuration for pre-push hook, and prepare script for hook installation
.husky/pre-push Created pre-push hook script that runs linting with environment variable controls for skipping

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

Comment thread package.json
Comment on lines +13 to +15
"simple-git-hooks": {
"pre-push": "npm run lint"
},
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

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

The configuration duplicates the hook implementation already present in .husky/pre-push. With simple-git-hooks, you should use either the package.json configuration OR a manual hook script in .husky/, but not both. The simple-git-hooks package will generate hooks based on the package.json config, making the .husky/pre-push file redundant. Consider removing the .husky/pre-push file and relying solely on the package.json configuration, or remove this configuration block if you prefer maintaining the hook script manually.

Suggested change
"simple-git-hooks": {
"pre-push": "npm run lint"
},

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
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 introduces a pre-push git hook to run the linter, which is a great step towards maintaining code quality. The implementation uses simple-git-hooks and is set up correctly. I have a couple of suggestions to improve the new workflow: one to ensure the hook script is robust across different environments, and another to improve the performance of the linting step to ensure a smooth developer experience.

Comment thread .husky/pre-push
. "$SIMPLE_GIT_HOOKS_RC"
fi

npm run lint No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

For better portability and to adhere to POSIX standards, shell scripts and other text files should end with a newline character. Some tools might not process the last line correctly without it, which could cause this hook to fail in some environments.

Suggested change
npm run lint
npm run lint

Comment thread package.json
"postbuild": "pagefind --site .next/server/app --output-path public/_pagefind"
},
"simple-git-hooks": {
"pre-push": "npm run lint"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Running the linter on the entire project on every push can be time-consuming, especially as the project grows. This could lead to a frustrating developer experience and encourage developers to bypass the hook (e.g., with git push --no-verify).

Consider changing this to lint only the files that have been changed in the push. You could write a small script to achieve this, for example by using git diff to find changed files and passing them to ESLint.

Copy link
Copy Markdown
Member

@jcstein jcstein left a comment

Choose a reason for hiding this comment

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

LGTM and ty!

@jcstein jcstein merged commit bfc563b into docs-glow-up Oct 27, 2025
1 check passed
@jcstein jcstein deleted the gb/add-git-hook branch October 27, 2025 20:49
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.

3 participants