Skip to content

Conversation

@Subham-KRLX
Copy link
Contributor

Fixes #883

Description

Added a pre-commit hook that automatically sorts the proselint config JSON file using jq -S. This ensures the configuration keys remain alphabetically sorted for easier maintenance.

Changes

  • Created .github/linters/proselint-config.json with sorted proselint checks
  • Added pre-commit hook in .pre-commit-config.yaml to auto-sort JSON keys

Testing

  • Tested locally - hook successfully sorts unsorted JSON
  • Ran pre-commit run --all-files

@github-actions
Copy link
Contributor

Thanks for your first pull request! We appreciate your contribution.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Subham-KRLX, 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 development workflow by integrating a pre-commit hook designed to maintain the alphabetical order of keys within the proselint configuration JSON file. This automation prevents configuration drift and simplifies future updates to the linter settings. Additionally, it establishes an initial, well-ordered proselint-config.json file to standardize prose linting across the project.

Highlights

  • Automated Configuration Sorting: Introduced a pre-commit hook that automatically sorts the proselint configuration JSON file using jq -S, ensuring consistent alphabetical order of keys.
  • New Proselint Configuration File: Added a new proselint-config.json file under .github/linters/ which contains a comprehensive and pre-sorted list of proselint checks.
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.

@deepsource-io
Copy link

deepsource-io bot commented Nov 10, 2025

Here's the code health analysis summary for commits 2925672..8d6c716. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Python LogoPython✅ SuccessView Check ↗
DeepSource Secrets LogoSecrets✅ SuccessView Check ↗
DeepSource Shell LogoShell✅ SuccessView Check ↗
DeepSource Docker LogoDocker✅ SuccessView Check ↗
DeepSource JavaScript LogoJavaScript✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

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 introduces a useful pre-commit hook to automatically sort the proselint configuration file, which will help with maintainability. The implementation is straightforward, but I've identified a potential issue in the script that handles the sorting. The use of a hardcoded temporary file is unsafe and could lead to conflicts. I've provided a suggestion to make this more robust. Otherwise, the changes are good.

Copy link
Member

@jbampton jbampton left a comment

Choose a reason for hiding this comment

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

Do not change the proselint config by adding keys.

This is just to sort it

The config file already exists and should not be modified.
This PR only adds the pre-commit hook to sort it.
@jbampton jbampton marked this pull request as draft November 10, 2025 15:16
Copy link
Member

@jbampton jbampton left a comment

Choose a reason for hiding this comment

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

Don't delete files

@Subham-KRLX
Copy link
Contributor Author

@jbampton Fixed! I have restored the proselint-config.json file.
The pre-commit hook in .pre-commit-config.yaml to automatically sort JSON keys using jq -S

Copy link
Member

@jbampton jbampton left a comment

Choose a reason for hiding this comment

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

Can we sort but also maintain the same indentation ?

@Subham-KRLX
Copy link
Contributor Author

Subham-KRLX commented Nov 10, 2025

@jbampton Fixed Updated the jq command to use --indent 2 to maintain 2-space indentation while sorting the keys alphabetically. The JSON file now preserves the original indentation style instead of using tabs.

Copy link
Member

@jbampton jbampton left a comment

Choose a reason for hiding this comment

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

We need jq to indent with tabs

@jbampton
Copy link
Member

Can you fix the conflicts ?

@jbampton jbampton added this to Chess Nov 11, 2025
@jbampton jbampton moved this to In Progress in Chess Nov 11, 2025
@github-actions github-actions bot removed the infra label Nov 11, 2025
@jbampton jbampton marked this pull request as ready for review November 11, 2025 10:14
@jbampton jbampton self-assigned this Nov 11, 2025
@jbampton jbampton self-requested a review November 11, 2025 10:15
@jbampton
Copy link
Member

/gemini review

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 adds a pre-commit hook to automatically sort the proselint-config.json file, which is a great way to ensure consistent formatting. The implementation is straightforward. My review includes a suggestion to make the hook's implementation more idiomatic for pre-commit and improve its maintainability by avoiding a hardcoded file path in the script. This small change will make the hook more robust.

Comment on lines 37 to 40
entry: bash -c 'f=.github/linters/proselint-config.json; jq -S --tab . "$f" > "$f.tmp" && mv "$f.tmp" "$f"'
language: system
files: ^\.github/linters/proselint-config\.json$
pass_filenames: false
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current implementation with a hardcoded file path in the entry script works, but it's not idiomatic for pre-commit hooks and could be less maintainable. A better approach is to let pre-commit pass the filename to the script. This avoids duplicating the file path and makes the hook more reusable.

By removing pass_filenames: false, pre-commit will pass the matched filename as an argument ($1) to the entry script. This change makes the hook's configuration cleaner and easier to maintain if the file is ever renamed.

Additionally, since this hook has a system dependency on jq, it would be helpful to add a note about this requirement in the repository's contribution guidelines (e.g., CONTRIBUTING.md) for other contributors.

        entry: bash -c 'jq -S --tab . "$1" > "$1.tmp" && mv "$1.tmp" "$1"' --
        language: system
        files: ^\.github/linters/proselint-config\.json$

Copy link
Member

Choose a reason for hiding this comment

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

Please make this a manual hook since bash generally does not run on Windows

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have added hooks statement in .prettier-commit-config.yaml but yet it failes
Screenshot 2025-11-11 at 4 45 12 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"scripts": {
"format": "prettier --write "/*.{css,js,json,md,yaml,yml}"",
"check": "prettier --check "
/*.{css,js,json,md,yaml,yml}"", "lint": "eslint --config .github/linters/eslint.config.mjs .",
"lint:fix": "eslint --config .github/linters/eslint.config.mjs . --fix",
}

@github-actions github-actions bot added the infra label Nov 11, 2025
@github-actions github-actions bot added the ci label Nov 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Add pre-commit hook to sort the proselint config

2 participants